Skip to content

"No package metadata" during wheel build from source #9453

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

Open
1 task done
dgilman opened this issue Apr 20, 2025 · 9 comments
Open
1 task done

"No package metadata" during wheel build from source #9453

dgilman opened this issue Apr 20, 2025 · 9 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member

Comments

@dgilman
Copy link

dgilman commented Apr 20, 2025

Describe the bug

The issue here is that the wheel build of awscli v2 from a source distribution is now failing with this exception after updating to the latest prompt_toolkit 3.0.51. Note that this version of prompt_toolkit now uses pyproject.toml for its build system. The output from awscli2's build is:

$ python3.13 -m build --no-isolation --wheel --outdir my_awscli_dir

* Getting build dependencies for wheel...
* Building wheel...
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 407, in from_name
    return next(iter(cls.discover(name=name)))
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
    main()
    ~~~~^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
    json_out["return_val"] = hook(**hook_input["kwargs"])
                             ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
    return _build_backend().build_wheel(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        wheel_directory, config_settings, metadata_directory
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/backends/pep517.py", line 65, in build_wheel
    _inject_wheel_extras(os.path.join(wheel_directory, whl_filename))
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/backends/pep517.py", line 191, in _inject_wheel_extras
    _build_and_inject_ac_index(BUILD_DIR, extracted_wheel_dir)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/backends/pep517.py", line 219, in _build_and_inject_ac_index
    ac_index_build_name = _build_ac_index(build_dir)
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/backends/pep517.py", line 230, in _build_ac_index
    from awscli.autocomplete.generator import generate_index
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/awscli/autocomplete/generator.py", line 17, in <module>
    from awscli import clidriver
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/awscli/clidriver.py", line 52, in <module>
    from awscli.autoprompt.core import AutoPromptDriver
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/awscli/autoprompt/core.py", line 17, in <module>
    from awscli.autoprompt.prompttoolkit import PromptToolkitPrompter
  File "/opt/local/var/macports/build/_Users_david_macports-ports-local_python_py-awscli2/py313-awscli2/work/aws-cli-2.26.5/awscli/autoprompt/prompttoolkit.py", line 18, in <module>
    from prompt_toolkit.application import Application
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/prompt_toolkit/__init__.py", line 32, in <module>
    __version__ = metadata.version("prompt_toolkit")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 987, in version
    return distribution(distribution_name).version
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 960, in distribution
    return Distribution.from_name(distribution_name)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/__init__.py", line 409, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for prompt_toolkit

This appears to be the same issue brought up on the arch linux forums that also sometimes crops up with kubectl.

I am not sure exactly where the issue lies but I bring it up here because after digging into the issue a bit, I found that the issue happens when awscli2's backends/pep517.py is the backend_path used by pyproject_hooks to find the package metadata. In other words, if I:

  • take the bug fix in pyproject_metadata in this PR
  • but change how it instantiates the DistributionFinder.Context to DistributionFinder.Context(name=name) - or in other words, keep it from using awscli2's backends/pep517 as the backend_path, it correctly finds the import and the awscli2 build works. But that is clearly a bogus fix, it just disables your backends/pep517.py and I don't think upstream is supposed to do that.

This correlates with what people are saying on the Arch forums, and what I've seen locally: if I run a python REPL and just do metadata.version("prompt_toolkit") in there it finds the package OK, so there is something about how awscli2's backends/pep517.py is injected into the importlib mechanisms that makes the build tooling unable to find system packages.

I don't know enough about the pep517 build stuff to know conclusively where the problem is, maybe it is with prompt_toolkit, maybe it is with pyproject_hooks, maybe it is with your backends/ dir. But it is the combination of all three that is glitching this out.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

python -m build --no-isolation --wheel --outdir blah should build the wheel

Current Behavior

See exception above

Reproduction Steps

Run python -m build --no-isolation --wheel --outdir blah on python 3.13 with prompt_toolkit 3.0.51 installed.

Possible Solution

No response

Additional Information/Context

No response

CLI version used

n/a

Environment details (OS name and version, etc.)

macOS 15.4, python 3.13

@dgilman dgilman added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 20, 2025
@github-actions github-actions bot added the potential-regression Marking this issue as a potential regression to be checked by team member label Apr 20, 2025
@steven-esser
Copy link

Yep, experiencing this as well.

@evanstucker-hates-2fa
Copy link

Temporary workaround for people using Arch who still have the previous package cached - downgrade python-prompt_toolkit:

sudo pacman -U /var/cache/pacman/pkg/python-prompt_toolkit-3.0.50-1-any.pkg.tar.zst

@evanstucker-hates-2fa
Copy link

See also: prompt-toolkit/python-prompt-toolkit#1988

@adev-code adev-code self-assigned this Apr 21, 2025
@adev-code adev-code added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 21, 2025
@adev-code
Copy link

Hi @dgilman and all, thanks for bringing this up. We only support toolkit version from 3.0.24 to 3.0.38

"prompt-toolkit>=3.0.24,<3.0.39",
. It seems that the version you are using is out of range. Please downgrade to a version that we support. Let me know if there are an questions.

Please see @evanstucker-hates-2fa open issue prompt-toolkit/python-prompt-toolkit#1988 to the right repo.

@adev-code adev-code added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 22, 2025
@dgilman
Copy link
Author

dgilman commented Apr 25, 2025

I understand it is not supported. However, at some point, you’ll be bumping the package version yourself and run into the same issue. And although I don’t know exactly where the pep517 build tooling is breaking down evidence suggests that prompt_toolkit is a red herring because its metadata can be successfully retrieved by importlib when not running within the awscli2 build process.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Apr 25, 2025
@tema-mazy
Copy link

macport aws is broken .

$aws
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/init.py", line 407, in from_name
return next(iter(cls.discover(name=name)))
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/local/bin/aws", line 19, in
import awscli.clidriver
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/awscli/clidriver.py", line 73, in
from awscli.autoprompt.core import AutoPromptDriver
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/awscli/autoprompt/core.py", line 16, in
from awscli.autoprompt.prompttoolkit import PromptToolkitPrompter
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/awscli/autoprompt/prompttoolkit.py", line 18, in
from prompt_toolkit.application import Application
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/prompt_toolkit/init.py", line 32, in
version = metadata.version("prompt_toolkit")
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/init.py", line 987, in version
return distribution(distribution_name).version
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/init.py", line 960, in distribution
return Distribution.from_name(distribution_name)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/metadata/init.py", line 409, in from_name
raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for prompt_toolkit

@chadgeary
Copy link

alpine's aws-cli package is also broken

aws version
Traceback (most recent call last):
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 397, in from_name
    return next(cls.discover(name=name))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/aws", line 19, in <module>
    import awscli.clidriver
  File "/usr/lib/python3.12/site-packages/awscli/clidriver.py", line 67, in <module>
    from awscli.autoprompt.core import AutoPromptDriver
  File "/usr/lib/python3.12/site-packages/awscli/autoprompt/core.py", line 16, in <module>
    from awscli.autoprompt.prompttoolkit import PromptToolkitPrompter
  File "/usr/lib/python3.12/site-packages/awscli/autoprompt/prompttoolkit.py", line 18, in <module>
    from prompt_toolkit.application import Application
  File "/usr/lib/python3.12/site-packages/prompt_toolkit/__init__.py", line 32, in <module>
    __version__ = metadata.version("prompt_toolkit")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 889, in version
    return distribution(distribution_name).version
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 862, in distribution
    return Distribution.from_name(distribution_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/importlib/metadata/__init__.py", line 399, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for prompt_toolkit

@amberkushwaha
Copy link

this issue here is that the main source file interpretation has been manipulated in the coding file distribution.

@project0
Copy link

I am pretty certain the problem is with the aws-cli packaging. Executing the affected python code manually with global installed prompt toolkit dependency (using arch) the import works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue potential-regression Marking this issue as a potential regression to be checked by team member
Projects
None yet
Development

No branches or pull requests

8 participants