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

failure to canonicalize name results in package installations failing #1410

Open
DeJayDev opened this issue May 14, 2024 · 3 comments
Open

Comments

@DeJayDev
Copy link

DeJayDev commented May 14, 2024

Describe the bug

Attempting to install anything results in error in name canonicalization.

I've reproduced this issue on with:

  • Ubuntu 22.04.4 LTS, using Python 3.10.12 with pipx 1.0.0 installed via apt.
  • Ubuntu 24.04 LTS, using Python 3.12.3 with pipx 1.4.3 installed via apt.
  • Ubuntu 24.04 LTS, using Python 3.12.3 with pipx 1.5.0 ran with the zipapp packaged pipx.

Note: These reproductions are on the same system. I opted to upgrade my operating system after noticing the insanely low pipx version being offered to 22.04 users.

I have run the Debian/Ubuntu Troubleshooting commands and isolated the issue to pipx by attempting package installation in the test_venv.

How to reproduce

pipx install --verbose poetry:

pipx >(setup:860): pipx version is 1.4.3
pipx >(setup:861): Default python interpreter is '/usr/bin/python3'
pipx >(package_name_from_spec:370): Determined package name: poetry
pipx >(package_name_from_spec:371): Package name determined in 0.0s
creating virtual environment...
pipx >(run_subprocess:168): running /usr/bin/python3 -m venv --without-pip /home/dejay/.local/pipx/venvs/poetry
pipx >(run_subprocess:168): running <checking pip's availability>
pipx >(run_subprocess:168): running /home/dejay/.local/pipx/venvs/poetry/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:168): running /home/dejay/.local/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
pipx >(run_subprocess:168): running /home/dejay/.local/pipx/venvs/poetry/bin/python --version
pipx >(_parsed_package_to_package_or_url:137): cleaned package spec: poetry
installing poetry...
pipx >(run_subprocess:168): running /home/dejay/.local/pipx/venvs/poetry/bin/python -m pip --no-input install poetry
pipx >(run_subprocess:168): running <fetch_info_in_venv commands>

pipx >(rmdir:55): removing directory /home/dejay/.local/pipx/venvs/poetry
Traceback (most recent call last):
  File "/usr/bin/pipx", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/lib/python3/dist-packages/pipx/main.py", line 921, in cli
    return run_pipx_command(parsed_pipx_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pipx/main.py", line 219, in run_pipx_command
    return commands.install(
           ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pipx/commands/install.py", line 91, in install
    venv.install_package(
  File "/usr/lib/python3/dist-packages/pipx/venv.py", line 256, in install_package
    self._update_package_metadata(
  File "/usr/lib/python3/dist-packages/pipx/venv.py", line 352, in _update_package_metadata
    venv_package_metadata = self.get_venv_metadata_for_package(package_name, get_extras(package_or_url))
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pipx/venv.py", line 338, in get_venv_metadata_for_package
    venv_metadata = inspect_venv(package_name, package_extras, self.bin_path, self.python_path, self.man_path)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pipx/venv_inspect.py", line 282, in inspect_venv
    root_dist = get_dist(root_req.name, venv_inspect_info.distributions)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pipx/venv_inspect.py", line 44, in get_dist
    if canonicalize_name(dist.metadata["name"]) == canonicalize_name(package):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/packaging/utils.py", line 47, in canonicalize_name
    value = _canonicalize_regex.sub("-", name).lower()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

Expected behavior

Ideally, the package is installed.

@huxuan
Copy link
Contributor

huxuan commented May 14, 2024

Hi @DeJayDev

Seems I can not reproduce the error (Windows 11 + WSL (Ubuntu 22.04) + pipx 1.5.0), is there anything I missed?

image

@DeJayDev
Copy link
Author

Thank you for checking, I'm actually not entirely sure what you could be missing. Typically I don't have any issues with pipx and hoped the trace could give a better idea of where I could start looking?

@huxuan
Copy link
Contributor

huxuan commented May 15, 2024

Actually, I have no idea just from the logs. There could be something wrong with the cache. I would suggest to remove all the installation of pipx managed applications and pipx itself, and then try to delete all the cache used by pipx and pip. If that does not help, we may have to debug into the pipx. It should be something like creating developing environment according to the contribution guide, try to reproduce the error with the cloned repo, and print corresponding information around the traceback.

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

No branches or pull requests

3 participants