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

No module named 'setuptools_rust' for latest cryptography (35) #6411

Closed
alexchandel opened this issue Oct 12, 2021 · 10 comments
Closed

No module named 'setuptools_rust' for latest cryptography (35) #6411

alexchandel opened this issue Oct 12, 2021 · 10 comments

Comments

@alexchandel
Copy link

alexchandel commented Oct 12, 2021

This occurs when cryptography is required as a dependency.

$ python setup.py install
…
… # (several other wheels are installed first)
…
Searching for cryptography>=1.4
Reading https://pypi.org/simple/cryptography/
Downloading https://files.pythonhosted.org/packages/10/91/90b8d4cd611ac2aa526290ae4b4285aa5ea57ee191c63c2f3d04170d7683/cryptography-35.0.0.tar.gz#sha256=9933f28f70d0517686bd7de36166dda42094eac49415459d9bdf5e7df3e0086d
Best match: cryptography 35.0.0
Processing cryptography-35.0.0.tar.gz
Writing /var/folders/wf/3l4cbglx71b21jmrtv68q_f40000gn/T/easy_install-4i8xunke/cryptography-35.0.0/setup.cfg
Running cryptography-35.0.0/setup.py -q bdist_egg --dist-dir /var/folders/wf/3l4cbglx71b21jmrtv68q_f40000gn/T/easy_install-4i8xunke/cryptography-35.0.0/egg-dist-tmp-72hp_v_f

        =============================DEBUG ASSISTANCE==========================
        If you are seeing an error here please try the following to
        successfully install cryptography:

        Upgrade to the latest pip and try again. This will fix errors for most
        users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
        =============================DEBUG ASSISTANCE==========================
        
Traceback (most recent call last):
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 156, in save_modules
    yield saved
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 259, in run_setup
    _execfile(setup_script, ns)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 46, in _execfile
    exec(code, globals, locals)
  File "/var/folders/wf/3l4cbglx71b21jmrtv68q_f40000gn/T/easy_install-4i8xunke/cryptography-35.0.0/setup.py", line 14, in <module>
    version = {}
ModuleNotFoundError: No module named 'setuptools_rust'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/setup.py", line 19, in <module>
    setup(
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/install.py", line 67, in run
    self.do_egg_install()
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/install.py", line 117, in do_egg_install
    cmd.run(show_deprecation=False)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 408, in run
    self.easy_install(spec, not self.no_deps)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 650, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 697, in install_item
    self.process_distribution(spec, dist, deps)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 744, in process_distribution
    distros = WorkingSet([]).resolve(
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 766, in resolve
    dist = best[req.key] = env.best_match(
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1051, in best_match
    return self.obtain(req, installer)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1063, in obtain
    return installer(requirement)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 669, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 695, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 890, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 1162, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 1146, in run_setup
    run_setup(setup_script, args)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 262, in run_setup
    raise
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/usr/local/Cellar/python@3.9/3.9.7/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 137, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 169, in save_modules
    saved_exc.resume()
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 143, in resume
    raise exc.with_traceback(self._tb)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 156, in save_modules
    yield saved
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 259, in run_setup
    _execfile(setup_script, ns)
  File "/Users/alex/GitHub/microsoft-bonsai-api/Python/venv/lib/python3.9/site-packages/setuptools/sandbox.py", line 46, in _execfile
    exec(code, globals, locals)
  File "/var/folders/wf/3l4cbglx71b21jmrtv68q_f40000gn/T/easy_install-4i8xunke/cryptography-35.0.0/setup.py", line 14, in <module>
    version = {}
ModuleNotFoundError: No module named 'setuptools_rust'

Steps

  • git clone https://github.com/microsoft/microsoft-bonsai-api
  • cd microsoft-bonsai-api/Python
  • python -m venv venv
  • source venv/bin/activate
  • python -m pip install -U pip
  • python -m pip install -U wheel
  • python -m pip install -U setuptools
  • python setup.py build
  • python setup.py install

Version

  • vanilla Python 3.9.7 in a venv
  • pip 21.3 (latest)
  • setuptools 58.2.0 (latest)
  • wheel 0.37.0 (latest)

Notes

pip install cryptography by itself succeeds, however its dependency on setuptools_rust doesn't seem to be resolved correctly when cryptography is installed as a dependency (the normal use case) by setup.py.

@alexchandel
Copy link
Author

Note this is a frequent problem (#5753, #5778, #5869, …) across platforms and versions.

@alex
Copy link
Member

alex commented Oct 12, 2021

The supported method for installing cryptography is with pip, installing via setuptools (meaning easy_install) is not supported.

Using pip install . instead of python setup.py install on your package is likely to resolve this.

@alex alex closed this as completed Oct 12, 2021
@alexchandel
Copy link
Author

What about setups that require cryptography for test_require? pip install . won't cover these.

@alexchandel
Copy link
Author

@alex Also why isn't your wheel installed when installing with setup.py? (It grabs cryptography-35.0.0.tar.gz instead)

@alexchandel
Copy link
Author

Does anyone even know why it fails with setup.py, or why dependents fail to find cryptography's wheel?

@alex
Copy link
Member

alex commented Oct 12, 2021

I don't think setuptools (easy_install) supports installing from wheels, or perhaps it's wheel support is somehow out of date. I'd make sure you're running the most recent version of setuptools.

@alexchandel
Copy link
Author

alexchandel commented Oct 12, 2021

I did, one of the replication steps is python -m pip install -U setuptools. And in my example, setup.py will install a dozen wheels for other dependents before reaching cryptography.

@tiran
Copy link
Contributor

tiran commented Oct 12, 2021

setuptools' tests_require feature uses easy_install under the hood. Easy install is deprecated and broken. Your problem is a manifestation of the bad state of easy install. See pypa/setuptools#931 for upstream discussion.

@alexchandel
Copy link
Author

@tiran I actually just now tried the above replication steps with pip install . instead of the setup.py calls, and pip still missed cryptography's wheel. pip downloaded cryptography-35.0.0.tar.gz and began installing build dependencies.

Again see my replication steps, I'm using latest versions of everything.

@reaperhulk
Copy link
Member

I can't replicate this. git clone https://github.com/microsoft/microsoft-bonsai-api && cd microsoft-bonsai-api/Python && python3 -m venv .venv && .venv/bin/pip install -U pip && .venv/bin/pip install . works with wheels on a macOS system as well as on a glibc-based Linux.

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

No branches or pull requests

4 participants