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 TOML module installed for Python 3.11 #850

Closed
2 tasks
duckontheweb opened this issue Mar 14, 2022 · 2 comments
Closed
2 tasks

No TOML module installed for Python 3.11 #850

duckontheweb opened this issue Mar 14, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@duckontheweb
Copy link

Bug Description

I'm not very familiar with building Python packages in Rust using maturin, so apologies in advance if any of this is off-base...

Attempting to install the orjson package in Python 3.11.0a4 results in the error shown in "Steps to Reproduce" below. This error can be traced back to an attempt to import either tomllib or tomli in setup.py here. However, in a fresh Python 3.11 environment neither of these will be installed in the build system requirements because of the environment marker in pyproject.toml here.

Is there a reason for that environment marker, or could it be relaxed so that tomli is installed for Python 3.11 as well?

Thanks!

Your Python version (python -V)

Python 3.11.0a4

Your pip version (pip -V)

pip 22.0.4 from /path/redacted/pip (python 3.11)

What bindings you're using

pyo3

Does cargo build work?

  • Yes, it works

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

  • Yes

Steps to Reproduce

> pyenv virtualenv 3.11.0a4 orjson-build-test
> pyenv activate orjson-build-test
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
> pip install --upgrade pip
Requirement already satisfied: pip in ./.pyenv/versions/3.11.0a4/envs/orjson-build-test/lib/python3.11/site-packages (21.2.4)
Collecting pip
  Using cached pip-22.0.4-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.4
    Uninstalling pip-21.2.4:
      Successfully uninstalled pip-21.2.4
Successfully installed pip-22.0.4
> pip install orjson --no-cache-dir
Collecting orjson
  Downloading orjson-3.6.7.tar.gz (550 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 550.1/550.1 KB 6.2 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
ERROR: Exception:
Traceback (most recent call last):
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 339, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 94, in resolve
    result = self._result = resolver.resolve(
                            ^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
    return bool(self._sequence)
           ^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 155, in __bool__
    return any(self)
           ^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 143, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 47, in _iter_built
    candidate = func()
                ^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 215, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
                                       ^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 288, in __init__
    super().__init__(
    ^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 158, in __init__
    self.dist = self._prepare()
                ^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 227, in _prepare
    dist = self._prepare_distribution()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 299, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/utils/logging.py", line 62, in indent_log
    yield
    ^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 487, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 556, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/req/req_tracker.py", line 123, in track
    yield
    ^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 58, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(finder, build_isolation)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/distributions/sdist.py", line 45, in prepare_distribution_metadata
    self._install_build_reqs(finder)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/distributions/sdist.py", line 104, in _install_build_reqs
    build_reqs = self._get_build_requires_wheel()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/pep517/wrappers.py", line 153, in subprocess_runner
    yield
    ^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_internal/distributions/sdist.py", line 81, in _get_build_requires_wheel
    return backend.get_requires_for_build_wheel()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/pep517/wrappers.py", line 172, in get_requires_for_build_wheel
    return self._call_hook('get_requires_for_build_wheel', {
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/python3.11/contextlib.py", line 155, in __exit__
    self.gen.throw(typ, value, traceback)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/pep517/wrappers.py", line 28, in tempdir
    yield td
    ^^^^^^^^
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/pep517/wrappers.py", line 332, in _call_hook
    raise BackendUnavailable(data.get('traceback', ''))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
  File "/private/var/folders/td/xzlhhvqn6gn7_zmrjc0zfb6c0000gn/T/pip-build-env-snvt3erd/overlay/lib/python3.11/site-packages/maturin/__init__.py", line 21, in <module>
    import tomllib
    ^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'tomllib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/path/redacted/lib/python3.11/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 89, in _build_backend
    obj = import_module(mod_path)
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/redacted/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 915, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/private/var/folders/td/xzlhhvqn6gn7_zmrjc0zfb6c0000gn/T/pip-build-env-snvt3erd/overlay/lib/python3.11/site-packages/maturin/__init__.py", line 23, in <module>
    import tomli as tomllib
    ^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'tomli'
@duckontheweb duckontheweb added the bug Something isn't working label Mar 14, 2022
@duckontheweb
Copy link
Author

Ah, sorry. I'm just now finding PEP 680, which should solve this problem by making tomllib available in Python 3.11. Perhaps it just hasn't made its way into the alpha releases yet?

@messense
Copy link
Member

Yes, it missed the last alpha release cycle: python/cpython#31498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants