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

Setting `language_level=3` breaks `cimport` with one or more nested directory #2661

fish2000 opened this Issue Oct 16, 2018 · 2 comments


None yet
1 participant

fish2000 commented Oct 16, 2018

Basically, setting language_level=3 breaks cimport statements with one or more nested directory.

If you have mypackage/mycymod.pyx that does a cimport of mypackage/ext/stuff/mywrappers.pxd, like by doing from ext.stuff.mywrappers cimport MyThing, this works fine with language_level=2 but breaks with language_level=3, where all of a sudden the Cython compiler reports that it cannot find any of the .pxd files e.g. mypackage/ext/stuff/mywrappers.pxd.

It works, if you drop mywrappers.pxd down one level – but that’s a hack workaround.

I have created a GitHub repository containing a pretty minimalist example demonstrating this bug, with the language_level=2 setting in master and language_level=3 in another branch, inventively titled language_level_3. Here’s how one may readily check the bug:

$ cd /tmp
$ git clone
$ cd language_level/
$ ls -sF
$ ./rebuild # this runs `python build_ext --inplace`
$ git status # this will show updated code generated by cython
$ git reset --hard
$ git checkout language_level_3 # branch changes `language_level=3`
$ git pull
$ ls -sF
$ more # you can see the updated `language_level`
$ ./rebuild # This command will die with Cython compile errors!
$ git reset --hard
$ cd ..
$ rm -rf language_level

I first noticed this problem in my own project, Halogen, which uses Cython; I am stuck on language_level=2 at the moment because of this.


This comment has been minimized.

fish2000 commented Oct 16, 2018

It may behoove whoever investigates this to consider #2638 as well – it looks to be possibly somehow related.


This comment has been minimized.

fish2000 commented Oct 16, 2018

Here, also, is a gist with examples of the error messages in question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment