materials
materials copied to clipboard
Mac Mojave and Python 3.8 working branch
Hi, I have a branch to push to you with a working version of the python binding module with Mac Mojave and Python 3.8 using python.org version of python, (not brew)
Cheers Dave.
Notes here;
help on python c binding
dependencies
install python3.8 from python.org
pip3 install pybind11
pip3 install invoke
pip3 install Cython
security block
mac mojave blocks relative pathed libraries, here is the fix
def install_name_tool(dependent=None, depends=[]):
'''
make the lib full path to get around security blocking relative paths
'''
for dependson in depends:
full_path = os.path.abspath(dependson)
shell_str='install_name_tool -change {0} {1} {2}'.format(dependson, full_path, dependent)
print(' install_name_tool: {0}'.format(dependson))
invoke.run(shell_str)
mac G++ missing symbols
mac compile gets upset about missing symbols
ignore missing symbols on a mac
On Mac OS: the build command is almost the same but it also requires passing the -undefined dynamic_lookup flag so as to ignore missing symbols when building the module:
in task.py
def compile_python_module(cpp_name, extension_name):
invoke.run(
"g++ -O3 -Wall -Werror -shared -std=c++11 -fPIC "
"`python3.8-config --includes` "
"`python3 -m pybind11 --includes` "
"-undefined dynamic_lookup "
"-I . "
"{0} "
"-o {1}`python3.8-config --extension-suffix` "
"-L. -lcppmult -Wl,-rpath,.".format(cpp_name, extension_name)
)
compile and test
here is the output from a good compile and test run
$ invoke all
==================================================
= Building C Library
* Complete
==================================================
= Testing ctypes Module
In cmult : int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 48.0
In cmult : int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
==================================================
= Building CFFI Module
install_name_tool: libcmult.so
* Complete
==================================================
= Testing CFFI Module
In cmult : int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
==================================================
= Building C++ Library
install_name_tool: libcmult.so
install_name_tool: cffi_example.cpython-38-darwin.so
* Complete
==================================================
= Building PyBind11 Module
install_name_tool: libcmult.so
install_name_tool: cffi_example.cpython-38-darwin.so
install_name_tool: libcppmult.so
* Complete
==================================================
= Testing PyBind11 Module
In cppmul: int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
==================================================
= Building Cython Module
install_name_tool: libcmult.so
install_name_tool: cffi_example.cpython-38-darwin.so
install_name_tool: libcppmult.so
* Complete
==================================================
= Testing Cython Module
In cppmul: int: 6 float 2.3 returning 13.8
In Python: int: 6 float 2.3 return val 13.8
@eddo888 Wow! Super cool! I'd love to see it. Can you make a PR from your branch/fork?
Thanks! jima
Thanks
I tried to create a pull request from the forked repo on my mac. I get this error, prepared to admin I’m not much good at creating a pull request, any suggestions, I looked at the help and used source tree from atlassian to create the pull request,.
git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/python3.8_mac_mojave:refs/heads/python3.8_mac_mojave Pushing to [email protected]:realpython/materials.git ERROR: Permission to realpython/materials.git denied to eddo888. fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Completed with errors, see above
On 23 Apr 2020, at 10:53 am, Jim Anderson [email protected] wrote:
@eddo888 https://github.com/eddo888 Wow! Super cool! I'd love to see it. Can you make a PR from your branch/fork?
Thanks! jima
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realpython/materials/issues/108#issuecomment-618114132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAT5IL52KD4IV4NOYED2UV3RN6GPTANCNFSM4MNXU24A.
OK. Here's feedback from Dan:
Looks like he's trying to push the branch to the realpython/materials repo, he needs to create a fork under his account first:
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests
Thanks
I tried to create a pull request from the forked repo on my mac. I get this error, prepared to admin I’m not much good at creating a pull request, any suggestions, I looked at the help and used source tree from atlassian to create the pull request,.
git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/python3.8_mac_mojave:refs/heads/python3.8_mac_mojave Pushing to [email protected]:realpython/materials.git ERROR: Permission to realpython/materials.git denied to eddo888. fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists. Completed with errors, see above
On 23 Apr 2020, at 10:53 am, Jim Anderson [email protected] wrote:
@eddo888 https://github.com/eddo888 Wow! Super cool! I'd love to see it. Can you make a PR from your branch/fork?
Thanks! jima
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realpython/materials/issues/108#issuecomment-618114132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAT5IL52KD4IV4NOYED2UV3RN6GPTANCNFSM4MNXU24A.
You need to create the pull request through the GitHub UI, please see:
- https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request
- https://www.youtube.com/watch?v=rgbCcBNZcdQ
Thankyou, understood, however I don’t have the permissions to put a branch into your repo
On 19 May 2020, at 2:33 pm, Dan Bader [email protected] wrote:
You need to create the pull request through the GitHub UI, please see:
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request https://www.youtube.com/watch?v=rgbCcBNZcdQ https://www.youtube.com/watch?v=rgbCcBNZcdQ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/realpython/materials/issues/108#issuecomment-630573342, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAT5IL2XNYD6KNWBGHMVQFDRSID2JANCNFSM4MNXU24A.
@eddo888 No problem David, the first step is to fork the repository under your own account, as explained here: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork
Then you can create a pull request against this repo from your fork.
This seems like a nice addition. Maybe you guys should just add it, because eddo888 seems to have gone poof