pypa / pipx

Install and Run Python Applications in Isolated Environments
https://pipx.pypa.io
MIT License
10.47k stars 414 forks source link

Consider stripping `+` from platform.python_version() #1573

Open bbhtt opened 3 hours ago

bbhtt commented 3 hours ago

Describe the bug

Install Poetry on debian testing with pipx install poetry fails with:

Traceback (most recent call last):
#13 10.17   File "/usr/local/bin/pipx", line 8, in <module>
#13 10.17 
#13 10.17     sys.exit(cli())
#13 10.18              ^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/main.py", line 1176, in cli
#13 10.18     return run_pipx_command(parsed_pipx_args, subparsers)
#13 10.18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/main.py", line 282, in run_pipx_command
#13 10.18     return commands.install(
#13 10.18            ^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/commands/install.py", line 99, in install
#13 10.18     venv.install_package(
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv.py", line 267, in install_package
#13 10.18     self.update_package_metadata(
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv.py", line 365, in update_package_metadata
#13 10.18     venv_package_metadata = self.get_venv_metadata_for_package(package_name, get_extras(package_or_url))
#13 10.18                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv.py", line 350, in get_venv_metadata_for_package
#13 10.18     venv_metadata = inspect_venv(package_name, package_extras, self.bin_path, self.python_path, self.man_path)
#13 10.18                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv_inspect.py", line 285, in inspect_venv
#13 10.18     app_paths_of_dependencies, man_paths_of_dependencies = _dfs_package_resources(
#13 10.18                                                            ^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv_inspect.py", line 163, in _dfs_package_resources
#13 10.18     app_paths_of_dependencies, man_paths_of_dependencies = _dfs_package_resources(
#13 10.18                                                            ^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv_inspect.py", line 146, in _dfs_package_resources
#13 10.18     dependencies = get_package_dependencies(dist, package_req.extras, venv_inspect_info.env)
#13 10.18                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/local/lib/python3.12/dist-packages/pipx/venv_inspect.py", line 61, in get_package_dependencies
#13 10.18     if req.marker.evaluate(eval_env):
#13 10.18        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/lib/python3/dist-packages/packaging/markers.py", line 325, in evaluate
#13 10.18     return _evaluate_markers(self._markers, current_environment)
#13 10.18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/lib/python3/dist-packages/packaging/markers.py", line 225, in _evaluate_markers
#13 10.18     groups[-1].append(_eval_op(lhs_value, op, rhs_value))
#13 10.18                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/lib/python3/dist-packages/packaging/markers.py", line 183, in _eval_op
#13 10.18     return spec.contains(lhs, prereleases=True)
#13 10.18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/lib/python3/dist-packages/packaging/specifiers.py", line 552, in contains
#13 10.18     normalized_item = _coerce_version(item)
#13 10.18                       ^^^^^^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/lib/python3/dist-packages/packaging/specifiers.py", line 28, in _coerce_version
#13 10.18     version = Version(version)
#13 10.18               ^^^^^^^^^^^^^^^^
#13 10.18   File "/usr/lib/python3/dist-packages/packaging/version.py", line 202, in __init__
#13 10.18     raise InvalidVersion(f"Invalid version: '{version}'")
#13 10.18 packaging.version.InvalidVersion: Invalid version: '3.12.7+'
#13 ERROR: process "/bin/sh -c python -m pip install --no-cache-dir --break-system-packages pipx &&     pipx install poetry" did not complete successfully: exit code: 1
------
 > [builder 3/5] RUN python -m pip install --no-cache-dir --break-system-packages pipx &&     pipx install poetry:
10.18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10.18   File "/usr/lib/python3/dist-packages/packaging/specifiers.py", line 552, in contains
10.18     normalized_item = _coerce_version(item)
10.18                       ^^^^^^^^^^^^^^^^^^^^^
10.18   File "/usr/lib/python3/dist-packages/packaging/specifiers.py", line 28, in _coerce_version
10.18     version = Version(version)
10.18               ^^^^^^^^^^^^^^^^
10.18   File "/usr/lib/python3/dist-packages/packaging/version.py", line 202, in __init__
10.18     raise InvalidVersion(f"Invalid version: '{version}'")
10.18 packaging.version.InvalidVersion: Invalid version: '3.12.7+'

How to reproduce

Run pipx install poetry

Expected behavior

It should correctly install.

bbhtt commented 3 hours ago

See https://github.com/pypa/pipx/blob/6f7fcabf90f538c6d6cc68bbdb07ba240fb52626/src/pipx/venv_inspect.py#L226

https://github.com/python-poetry/poetry/blob/341071a3f01379bf20682abf272c8fe8d10734e5/src/poetry/utils/env/system_env.py#L69

https://github.com/python/cpython/issues/99968

dukecat0 commented 3 hours ago

It seems like this is no longer an issue if you upgrade packaging to 24.2, which was released about 3 hours ago.