Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux .so C-Extension works when importing functions into python; however, Mac OS X fails to import functions (i.e. import errors) #2907

Open
DaddyGrimmlin opened this Issue Mar 28, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@DaddyGrimmlin
Copy link

commented Mar 28, 2019

Using Python 3.6
Mac OS X Mojave
Linux CENTOS7

The C-extension was originally created on Linux machine and it works properly when importing it into another project. File Structure:

c_ext/
  __init__.py  <- imports functions from c_ext.so
    c_ext.so

python_func.py  <- from .c_ext import <func>

When executing the build_ext on Mac to create a mac binary the python_func is not able to import functions from the resultant binary.

@scoder

This comment has been minimized.

Copy link
Contributor

commented Mar 30, 2019

Do I see it correctly that python_func is not part of the c_ext package but tries to use a relative import? That can't work.

@DaddyGrimmlin

This comment has been minimized.

Copy link
Author

commented Mar 30, 2019

They are nested together under a parent package.

my_project/
init.py
python_func.py
c_ext/
init.py
c_ext.so

This works in Linux. I import the functions in the c_ext in the peer init.py, then in python_func.py I do from c_ext import python_func. If this is not the proper way to use a function defined in a c extension in python, then what is the proper way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.