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

import failure with cython master #144

Closed
tacaswell opened this issue Mar 31, 2020 · 10 comments
Closed

import failure with cython master #144

tacaswell opened this issue Mar 31, 2020 · 10 comments

Comments

@tacaswell
Copy link

With cython master (and cpython master, but that seems to not matter here)

Process Python finished
Python 3.9.0a5+ (heads/master:71a3522ef8, Mar 26 2020, 23:28:49) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cytoolz
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-fe6152314c51> in <module>
----> 1 import cytoolz

~/source/other_source/cytoolz/cytoolz/__init__.py in <module>
     22 from . import curried  # sandbox
     23 
---> 24 functoolz._sigs.update_signature_registry()
     25 
     26 from ._version import __version__, __toolz_version__

AttributeError: partially initialized module 'cytoolz' has no attribute 'update_signature_registry' (most likely due to a circular import)

In [3]: import cytoolz
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-fe6152314c51> in <module>
----> 1 import cytoolz

~/.virtualenvs/bleeding/lib/python3.9/site-packages/cytoolz/__init__.py in <module>
     17 
     18 # Always-curried functions
---> 19 flip = functoolz.flip = curry(functoolz.flip)
     20 memoize = functoolz.memoize = curry(functoolz.memoize)
     21 

NameError: name 'functoolz' is not defined

This works correctly with the latest cython on pypi (0.29.16).

I noticed this a month or two ago but only just now tracked down the source of the problem. I am unfortunately out of my depth to try and debug this.

@eriknw
Copy link
Member

eriknw commented Mar 31, 2020

Fascinating. Thanks for the report @tacaswell . This is obviously not good.

@tacaswell
Copy link
Author

It is possible that this should actually go to cython, but started here to try and get y'alls help for a more minimal better bug report to cython.

@haobibo
Copy link

haobibo commented May 19, 2020

Hi @eriknw, (cc @tacaswell)

I encountered the same here: https://travis-ci.com/github/QPod/docker-images/jobs/336516414#L2013

Environment (docker image qpod/qpod:py-std):

  • docker image of ubuntu:latest
  • conda: latest version installed
  • Python packages installed: Cython, toolz, cytoolz

Running conda info will trigger this error: conda -> conda._vendor -> conda._vendor.toolz -> cytoolz

I also found that when __init__.py exist along with __init__.pxd the bug will occur, while if I delete the __init__.py file, the bug will be gone.

@eriknw Could you please advise how to automatically remove the __init__.py file when __init__.pxd exist?

@eriknw
Copy link
Member

eriknw commented Sep 23, 2020

Things work for me with Cython 0.29.16 and 0.29.17 (and the latest 0.29.21). Can y'all confirm this has been resolved?

@haobibo, ideally, one should be able to have both __init__.py and __init__.pxd. The first one lets you from cytoolz import ... from Python. The second lets you from cytoolz cimport ... from Cython. We don't need to compile any code, so we use a pure Python file __init__.py instead of __init__.pyx.

If @tacaswell and cytoolz was the reason a regression was detected in Cython, then hooray!

@tacaswell
Copy link
Author

Installing the released version still fails with:

(bleeding) ~                                                                                                                                      
✔ 23:16:56 $ pip install cytoolz                                                                                                                  
Collecting cytoolz
  Downloading cytoolz-0.11.0.tar.gz (477 kB)
     |████████████████████████████████| 477 kB 3.5 MB/s 
Requirement already satisfied: toolz>=0.8.0 in ./.virtualenvs/bleeding/lib/python3.10/site-packages (from cytoolz) (0.10.0)
Building wheels for collected packages: cytoolz
  Building wheel for cytoolz (setup.py) ... done
  Created wheel for cytoolz: filename=cytoolz-0.11.0-cp3_10-cp310-linux_x86_64.whl size=1957159 sha256=f1cc820bfc06c4d62b55026bceb9dd01059b0a43b449090ca9713d38b06d06d1
  Stored in directory: /home/tcaswell/.cache/pip/wheels/0d/e0/df/624ca76a946a9818a0d88d4012c60b42b8af3c8711e0263113
Successfully built cytoolz
Installing collected packages: cytoolz
Successfully installed cytoolz-0.11.0
(bleeding) ~                                                                                                                                      
✔ 23:17:46 $ ipython                                                                                                                              
Python 3.10.0a0 (heads/main:7af072c3b6, Sep 23 2020, 11:02:21) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.0.dev -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cytoolz
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-fe6152314c51> in <module>
----> 1 import cytoolz

~/.virtualenvs/bleeding/lib/python3.10/site-packages/cytoolz/__init__.py in <module>
     20 memoize = functoolz.memoize = curry(functoolz.memoize)
     22 from . import curried  # sandbox
---> 24 functoolz._sigs.update_signature_registry()
     26 from ._version import __version__, __toolz_version__

AttributeError: partially initialized module 'cytoolz' has no attribute 'update_signature_registry' (most likely due to a circular import)

In [2]: 

but installing from the current main/master seems to work. Not sure if it is due to a changes in cytoolz or something in the build process.

@tacaswell
Copy link
Author

@haobibo can you try with pip install --upgrade --pre cython (you should pull 3.0a6)?

@haobibo
Copy link

haobibo commented Oct 14, 2020

@tacaswell seems still not working.

Here we have installed: https://travis-ci.com/github/QPod/docker-images/jobs/399234704#L1816

  • Cython 3.0a6
  • cytoolz 0.11.0

But still encounter the same error: https://travis-ci.com/github/QPod/docker-images/jobs/399234704#L2012

AttributeError: partially initialized module 'cytoolz' has no attribute 'update_signature_registry' (most likely due to a circular import)

@iam-agf
Copy link

iam-agf commented Apr 13, 2021

This problem AttributeError: partially initialized module 'cytoolz' has no attribute 'update_signature_registry' also appears when trying to install mini/ana-conda. Has it been solved?

@da-woods
Copy link

I suspect this will be fixed by cython/cython#4392

@tacaswell
Copy link
Author

I am seeing that with cython main branch + current CPython main branch (py311) cytoolz will import!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants