Invalid version: 'None' when re-installing/upgrading python-apt using pip when wheel module installed

Bug #2055194 reported by Philip Roche
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
New
Undecided
Unassigned
Xenial
New
Undecided
Unassigned
Bionic
New
Undecided
Unassigned
Focal
New
Undecided
Unassigned
Jammy
New
Undecided
Unassigned
Mantic
New
Undecided
Unassigned

Bug Description

[ Impact ]

 * It is not possible to upgrade or re-install python-apt using pip from the git+ssh://git.launchpad.net/ubuntu/+source/python-apt git repo if already installed and if wheel installed too.

 * On initial install it also is assigned version `0.0.0` which is incorrect

 * This applies to the Mantic, Jammy and earlier versions. It has been fixed in Noble

[ Test Plan ]

 * Attempt re-install of python-apt

[ Where problems could occur ]

 * Being unable to install python-apt

 * Being unable to upgrade python-apt

 * Being unable to re-install python-apt

[ Other Info ]

 * This been resolved upstream @ https://salsa.debian.org/apt-team/python-apt/-/commit/765772fad2d3611b952b6ad416c6b765739a902a and in `2.4.y` branch @ https://salsa.debian.org/apt-team/python-apt/-/tree/2.4.y?ref_type=heads

 * You can workaround this too by setting environment variable `DEBVER=2.4.11`

 * Reproducer

```
❯ python3 -m venv venv
❯ source venv/bin/activate
❯ python3 -m pip list
Package Version
---------- -------
pip 23.2
setuptools 68.1.2
❯ python3 -m pip install --upgrade git+ssh://git.launchpad.net/ubuntu/+source/python-apt@ubuntu/jammy-updates
Collecting git+ssh://git.launchpad.net/ubuntu/+source/python-apt@ubuntu/jammy-updates
  Cloning ssh://git.launchpad.net/ubuntu/+source/python-apt (to revision ubuntu/jammy-updates) to ./pip-req-build-t7t8vnsu
  Running command git clone --filter=blob:none --quiet ssh://git.launchpad.net/ubuntu/+source/python-apt /tmp/pip-req-build-t7t8vnsu
  warning: filtering not recognized by server, ignoring
  warning: filtering not recognized by server, ignoring
  Running command git checkout -b ubuntu/jammy-updates --track origin/ubuntu/jammy-updates
  Switched to a new branch 'ubuntu/jammy-updates'
  branch 'ubuntu/jammy-updates' set up to track 'origin/ubuntu/jammy-updates'.
  Resolved ssh://git.launchpad.net/ubuntu/+source/python-apt to commit f043e6bd4d2842d6693d48e0c68c7a63bd3be9ac
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: python-apt
  Building wheel for python-apt (pyproject.toml) ... done
  Created wheel for python-apt: filename=python_apt-0.0.0-cp311-cp311-linux_x86_64.whl size=1808770 sha256=472ff7d9bcdad50912dc42499d68bc5e958b9843c355c157ccf920021728c205
  Stored in directory: /tmp/pip-ephem-wheel-cache-nyc3gs5x/wheels/c7/db/d7/21a72eaa5719ab3ab1ca242d5d0e08aca4aa67eaddb3c9b8fa
Successfully built python-apt
Installing collected packages: python-apt
Successfully installed python-apt-0.0.0
❯ python3 -m pip list
Package Version
---------- -------
pip 23.2
python-apt 0.0.0
setuptools 68.1.2
# install wheel
❯ python3 -m pip install wheel
Collecting wheel
  Obtaining dependency information for wheel from https://files.pythonhosted.org/packages/c7/c3/55076fc728723ef927521abaa1955213d094933dc36d4a2008d5101e1af5/wheel-0.42.0-py3-none-any.whl.metadata
  Using cached wheel-0.42.0-py3-none-any.whl.metadata (2.2 kB)
Using cached wheel-0.42.0-py3-none-any.whl (65 kB)
Installing collected packages: wheel
Successfully installed wheel-0.42.0
❯ python3 -m pip list
Package Version
---------- -------
pip 23.2
python-apt 0.0.0
setuptools 68.1.2
wheel 0.42.0
# Now try re-install
❯ python3 -m pip install --upgrade git+ssh://git.launchpad.net/ubuntu/+source/python-apt@ubuntu/jammy-updates
Collecting git+ssh://git.launchpad.net/ubuntu/+source/python-apt@ubuntu/jammy-updates
  Cloning ssh://git.launchpad.net/ubuntu/+source/python-apt (to revision ubuntu/jammy-updates) to ./pip-req-build-lk856i6s
  Running command git clone --filter=blob:none --quiet ssh://git.launchpad.net/ubuntu/+source/python-apt /tmp/pip-req-build-lk856i6s
  warning: filtering not recognized by server, ignoring
  warning: filtering not recognized by server, ignoring
  Running command git checkout -b ubuntu/jammy-updates --track origin/ubuntu/jammy-updates
  Switched to a new branch 'ubuntu/jammy-updates'
  branch 'ubuntu/jammy-updates' set up to track 'origin/ubuntu/jammy-updates'.
  Resolved ssh://git.launchpad.net/ubuntu/+source/python-apt to commit f043e6bd4d2842d6693d48e0c68c7a63bd3be9ac
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [34 lines of output]
      Traceback (most recent call last):
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/_normalization.py", line 59, in safe_version
          return str(packaging.version.Version(v))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/_vendor/packaging/version.py", line 198, in __init__
          raise InvalidVersion(f"Invalid version: '{version}'")
      setuptools.extern.packaging.version.InvalidVersion: Invalid version: 'None'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-req-build-lk856i6s/setup.py", line 100, in <module>
          setup(name="python-apt",
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
                                       ^^^^^^^^^^^^
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/dist.py", line 480, in __init__
          self.patch_missing_pkg_info(attrs)
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/dist.py", line 469, in patch_missing_pkg_info
          dist._version = _normalization.safe_version(str(attrs['version']))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/_normalization.py", line 62, in safe_version
          return str(packaging.version.Version(attempt))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/venv/lib/python3.11/site-packages/setuptools/_vendor/packaging/version.py", line 198, in __init__
          raise InvalidVersion(f"Invalid version: '{version}'")
      setuptools.extern.packaging.version.InvalidVersion: Invalid version: 'None'
      W: [python3.1] DistUtilsExtra import error.
      W: [python3.1] Sphinx import error.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

# Now install the upstream version with the fix
❯ python3 -m pip install --upgrade git+https://salsa.debian.org/apt-team/python-apt.git@2.4.y
Collecting git+https://salsa.debian.org/apt-team/python-apt.git@2.4.y
  Cloning https://salsa.debian.org/apt-team/python-apt.git (to revision 2.4.y) to ./pip-req-build-3685qq5l
  Running command git clone --filter=blob:none --quiet https://salsa.debian.org/apt-team/python-apt.git /tmp/pip-req-build-3685qq5l
  Running command git checkout -b 2.4.y --track origin/2.4.y
  Switched to a new branch '2.4.y'
  branch '2.4.y' set up to track 'origin/2.4.y'.
  Resolved https://salsa.debian.org/apt-team/python-apt.git to commit 765772fad2d3611b952b6ad416c6b765739a902a
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: python-apt
  Building wheel for python-apt (setup.py) ... done
  Created wheel for python-apt: filename=python_apt-2.4.0-cp311-cp311-linux_x86_64.whl size=1808869 sha256=88a68a971f2906fb164d899e3a656f96c13b411e1c4817b8124570c8d7d8f8b6
  Stored in directory: /tmp/pip-ephem-wheel-cache-s8hfqwli/wheels/be/db/74/811f602d86304cd1d663bb8d2fac0576098fb5c1f1fcc574f5
Successfully built python-apt
Installing collected packages: python-apt
  Attempting uninstall: python-apt
    Found existing installation: python-apt 0.0.0
    Uninstalling python-apt-0.0.0:
      Successfully uninstalled python-apt-0.0.0
Successfully installed python-apt-2.4.0

# Now remove wheel
❯ python3 -m pip uninstall -y wheel
Found existing installation: wheel 0.42.0
Uninstalling wheel-0.42.0:
  Successfully uninstalled wheel-0.42.0

# Try re-install again without wheel present in virtual env
❯ python3 -m pip install --upgrade git+ssh://git.launchpad.net/ubuntu/+source/python-apt@ubuntu/jammy-updates
Collecting git+ssh://git.launchpad.net/ubuntu/+source/python-apt@ubuntu/jammy-updates
  Cloning ssh://git.launchpad.net/ubuntu/+source/python-apt (to revision ubuntu/jammy-updates) to ./pip-req-build-x6s9fyhw
  Running command git clone --filter=blob:none --quiet ssh://git.launchpad.net/ubuntu/+source/python-apt /tmp/pip-req-build-x6s9fyhw
  warning: filtering not recognized by server, ignoring
  warning: filtering not recognized by server, ignoring
  Running command git checkout -b ubuntu/jammy-updates --track origin/ubuntu/jammy-updates
  Switched to a new branch 'ubuntu/jammy-updates'
  branch 'ubuntu/jammy-updates' set up to track 'origin/ubuntu/jammy-updates'.
  Resolved ssh://git.launchpad.net/ubuntu/+source/python-apt to commit f043e6bd4d2842d6693d48e0c68c7a63bd3be9ac
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: python-apt
  Building wheel for python-apt (pyproject.toml) ... done
  Created wheel for python-apt: filename=python_apt-0.0.0-cp311-cp311-linux_x86_64.whl size=1808761 sha256=930dc876f56792a798aabcee00ca2760a6ea0b1bffe47e5d9edfa1fa03ed4c0e
  Stored in directory: /tmp/pip-ephem-wheel-cache-98tkauq_/wheels/c7/db/d7/21a72eaa5719ab3ab1ca242d5d0e08aca4aa67eaddb3c9b8fa
Successfully built python-apt
Installing collected packages: python-apt
  Attempting uninstall: python-apt
    Found existing installation: python-apt 2.4.0
    Uninstalling python-apt-2.4.0:
      Successfully uninstalled python-apt-2.4.0
Successfully installed python-apt-0.0.0

```

Philip Roche (philroche)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.