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

Dependencies.create_extension_list() cannot be called with ctx=None #2973

Open
dlon opened this issue May 28, 2019 · 1 comment

Comments

Projects
None yet
1 participant
@dlon
Copy link

commented May 28, 2019

I'd like to use this function outside of Cython. This line causes an AttributeError to be raised when ctx=None:

create_extension = ctx.options.create_extension or default_create_extension
@dlon

This comment has been minimized.

Copy link
Author

commented May 28, 2019

I'll explain why I'm using this.

For pygame, we have most of the source code in src_c/, including .pyx files. Relative cimports from subpackages (eg src_c/subpackage) do not work, because Cython tries to import the module src_c.package.module at runtime, or it fails with an error message about relative imports beyond root.

So I moved all the .pyx files into src_c/cython/pygame. Now it works, but cythonize() didn't let me output .c files to src_c/ rather than src_c/pygame, so I duplicated some of the code from cythonize() in our setup script. But I'd also like to check dependencies.

So I have two other suggestions:

  1. cythonize() might allow allow you to specify per-extension paths to .c files instead of using a hardcoded name.
  2. Relative cimports might do relative imports with the C API at runtime rather than absolute imports, if possible.
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.