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

Installing via venv/pip fails with pip._vendor.packaging.version.InvalidVersion #7836

Open
Massimo-B opened this issue Aug 22, 2024 · 22 comments

Comments

@Massimo-B
Copy link

As dev-db/pgadmin4 got removed from Portage due to yarn issues as mentioned in https://bugs.gentoo.org/794460#c20
I tried following https://ogris.de/howtos/gentoo-pgadmin4.html to install via venv/pip. But it's failing due to the kernel version?

$ python3 -m venv ~/opt/pgadmin4
$ . ~/opt/pgadmin4/bin/activate
$ pip install pgadmin4
Collecting pgadmin4
  Downloading pgadmin4-8.11-py3-none-any.whl.metadata (2.9 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
    status = _inner_run()
             ^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
    return self.run(options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/commands/install.py", line 379, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
                            ^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 397, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/resolvelib/resolvers.py", line 173, in _add_to_criteria
    if not criterion.candidates:
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/resolvelib/structs.py", line 156, in __bool__
    return bool(self._sequence)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 174, in __bool__
    return any(self)
           ^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 162, in <genexpr>
    return (c for c in iterator if id(c) not in self._incompatible_ids)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 53, in _iter_built
    candidate = func()
                ^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 186, in _make_candidate_from_link
    base: Optional[BaseCandidate] = self._make_base_candidate_from_link(
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 232, in _make_base_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
                                       ^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 303, in __init__
    super().__init__(
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 158, in __init__
    self.dist = self._prepare()
                ^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 247, in _prepare
    self._check_metadata_consistency(dist)
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 229, in _check_metadata_consistency
    list(dist.iter_dependencies(list(dist.iter_provided_extras())))
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py", line 220, in iter_dependencies
    elif any(req.marker.evaluate(context) for context in contexts):
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py", line 220, in <genexpr>
    elif any(req.marker.evaluate(context) for context in contexts):
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 325, in evaluate
    return _evaluate_markers(self._markers, current_environment)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 211, in _evaluate_markers
    groups[-1].append(_evaluate_markers(marker, environment))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 225, in _evaluate_markers
    groups[-1].append(_eval_op(lhs_value, op, rhs_value))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/markers.py", line 183, in _eval_op
    return spec.contains(lhs, prereleases=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py", line 552, in contains
    normalized_item = _coerce_version(item)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/specifiers.py", line 28, in _coerce_version
    version = Version(version)
              ^^^^^^^^^^^^^^^^
  File "/home/mb/opt/pgadmin4/lib/python3.12/site-packages/pip/_vendor/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: '{version}'")
pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.6.30-gentoo'

unames are free form, and expecting it not to contain -gentoo is wrong.

@Massimo-B Massimo-B added the Bug label Aug 22, 2024
@kpinc
Copy link

kpinc commented Aug 22, 2024

I've the same problem on Ubuntu 22 on MS Azure. The final line of the traceback is:

pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.5.0-1025-azure'

I am told that installation works with pip version 24.0 and fails with pip 24.2.

I know that it works with setuptools >= 66, which was where semantic versioning enforcement was turned on for python packages. (Which seems somehow related to the issue.)

libera.net's #python seems to think that the problem is
https://github.com/pgadmin-org/pgadmin4/blob/master/pkg/pip/setup_pip.py#L48
and that this
python-poetry/poetry#7418
is related.

@kpinc
Copy link

kpinc commented Aug 22, 2024

I am told that this is relevant:
pypa/packaging#774 (comment)

@liaohongxing
Copy link

debian sid :

pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.10.6-amd64'

@adityatoshniwal
Copy link
Contributor

This doesn't look like a pgAdmin issue. Installing with lower pip version works.

@adityatoshniwal adityatoshniwal closed this as not planned Won't fix, can't repro, duplicate, stale Aug 23, 2024
@kpinc
Copy link

kpinc commented Aug 23, 2024 via email

Josue-T added a commit to YunoHost-Apps/pgadmin_ynh that referenced this issue Aug 25, 2024
@adityatoshniwal
Copy link
Contributor

On Fri, 23 Aug 2024 03:51:02 -0700 Aditya Toshniwal @.> wrote: This doesn't look like a pgAdmin issue. Installing with lower pip version works.
This issue should not be closed. Pgadmin should not use pip's version parsing code to parse the kernel version, since pip has specific syntax requirements for version strings. Requirements that the kernel versions do not conform to. Pip may have it's own issue, and might, possibly, make the problem go away. But that does not mean that pgadmin is calling the library appropriate for parsing kernel version strings. Regards, Karl @.
> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein

pgAdmin isn't parsing any code. It might be some dependency python package.

@Massimo-B
Copy link
Author

If the issue is on pip side, please provide a installation guide via pip with a detailed description which pip-version pgAdmin depends on.

@adityatoshniwal
Copy link
Contributor

adityatoshniwal commented Aug 27, 2024

If the issue is on pip side, please provide a installation guide via pip with a detailed description which pip-version pgAdmin depends on.

pgAdmin is released on PyPi since long and there were no issues regarding pip version. Packages like pip may release packages any time even after pgAdmin is released and break things.

@Massimo-B
Copy link
Author

Ok, beside my inofficial page I was following,
this is a bug report against https://www.pgadmin.org/download/pgadmin-4-python/ as it almost does the same like my page and is broken as well.

What can we do? Upstream bug report to pip? Downgrade pip? Is it already solved by the YunoHost-Apps/pgadmin_ynh@65b8094 above?
I just tried again and it still fails.

@kpinc
Copy link

kpinc commented Aug 31, 2024 via email

@Massimo-B
Copy link
Author

You mentioned a possible work-around, that would be a change in pgAdmin4 to work-around the bug in pip?
Isn't that pip bug already filed as a bug report? I'm not the best person to describe that as I'm not that much into Python development.

@kpinc
Copy link

kpinc commented Sep 4, 2024 via email

@faridcher
Copy link

faridcher commented Sep 28, 2024

I also have this problem. I can't install pgadmin from Postgresql Debian repos.
I get:

Unsatisfied dependencies:
 pgadmin4-server : Depends: python3.11 but it is not installable
Error: Unable to correct problems, you have held broken packages.

It happened as soon as my Debian Python upgraded to 3.12.

I turned to pip in a virtual environment. I got the same error of this post. It seems pgadmin4 only supports python 3.11 as listed in Pypi page.
I downgraded my pip from 24.2 to 23 but it then failed to install any package with another error:

AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

I think pgadmin4 should cope with new changes in python3.12.

@SIP-Online
Copy link

Same problem under Debian 12, and surprised that it is still present despite this new version.
The only way to take advantage of pgAdmin4, and to install version 8.10:
pgadmin4==8.10

We are faced with a situation that everyone has been passing the buck for months, I have installed several projects like Odoo or Pretix, and none of them have caused problems.
So there is something to review on the construction of the package with pip3.
There is a share of responsibility of the staff, and also of the creator of the package: https://pypi.org/project/pgadmin4/

I hope we will have the opportunity to take advantage of a future version !

@kpinc
Copy link

kpinc commented Sep 30, 2024 via email

@SIP-Online
Copy link

This can be playable by doing a comparison between version 8.10 and version 8.11.
I am not a PIP expert, if we can make dependency conditions on package versions according to the OS/Kernel version, this will solve the problem.

Given the situation, I will immediately stick to it, and I will come back to you with a patch. 😉

@SIP-Online
Copy link

After research, it is fixed on my side, the culprit is linked to conditions for Darwin environments, the method is not adapted for example for the Python version of Debian 12.
A patch is therefore necessary, here is the method to redo a stable package:

pip3 install wheel
wget "https://files.pythonhosted.org/packages/bb/22/4635915e990edec92142e5610a344afc085345bc62350f47955d5ae5f778/pgadmin4-8.12-py3-none-any.whl"
python3 -m wheel unpack pgadmin4-8.12-py3-none-any.whl

sed -i '/darwin/ s/\([[:digit:]]\);.*/\1/' "pgadmin4-8.12/pgadmin4-8.12.dist-info/METADATA"
sed -i '/psycopg\[binary\]==3.1.19/d' "pgadmin4-8.12/pgadmin4-8.12.dist-info/METADATA"

python3 -m wheel pack --build-number 2 pgadmin4-8.12
pip3 install pgadmin4-8.12-2-py3-none-any.whl

This solution remains a bandage for those who are on a Linux environment, I leave this responsibility to the staff to find a BSD and Linux compatible patch.

@faridcher
Copy link

@SIP-Online thank you for the time and the patch

@adityatoshniwal
Copy link
Contributor

binary

Re-opening this to see how we can change pgAdmin build code to include this.

@ethereal-engineer
Copy link

After research, it is fixed on my side, the culprit is linked to conditions for Darwin environments, the method is not adapted for example for the Python version of Debian 12. A patch is therefore necessary, here is the method to redo a stable package:

pip3 install wheel
wget "https://files.pythonhosted.org/packages/bb/22/4635915e990edec92142e5610a344afc085345bc62350f47955d5ae5f778/pgadmin4-8.12-py3-none-any.whl"
python3 -m wheel unpack pgadmin4-8.12-py3-none-any.whl

sed -i '/darwin/ s/\([[:digit:]]\);.*/\1/' "pgadmin4-8.12/pgadmin4-8.12.dist-info/METADATA"
sed -i '/psycopg\[binary\]==3.1.19/d' "pgadmin4-8.12/pgadmin4-8.12.dist-info/METADATA"

python3 -m wheel pack --build-number 2 pgadmin4-8.12
pip3 install pgadmin4-8.12-2-py3-none-any.whl

This solution remains a bandage for those who are on a Linux environment, I leave this responsibility to the staff to find a BSD and Linux compatible patch.

Tested working on archlinuxarm (aarch64-ARCH)

@suisbuds
Copy link

suisbuds commented Oct 30, 2024

After research, it is fixed on my side, the culprit is linked to conditions for Darwin environments, the method is not adapted for example for the Python version of Debian 12. A patch is therefore necessary, here is the method to redo a stable package:

pip3 install wheel
wget "https://files.pythonhosted.org/packages/bb/22/4635915e990edec92142e5610a344afc085345bc62350f47955d5ae5f778/pgadmin4-8.12-py3-none-any.whl"
python3 -m wheel unpack pgadmin4-8.12-py3-none-any.whl

sed -i '/darwin/ s/\([[:digit:]]\);.*/\1/' "pgadmin4-8.12/pgadmin4-8.12.dist-info/METADATA"
sed -i '/psycopg\[binary\]==3.1.19/d' "pgadmin4-8.12/pgadmin4-8.12.dist-info/METADATA"

python3 -m wheel pack --build-number 2 pgadmin4-8.12
pip3 install pgadmin4-8.12-2-py3-none-any.whl

This solution remains a bandage for those who are on a Linux environment, I leave this responsibility to the staff to find a BSD and Linux compatible patch.

Tested working on arch linux (6.11.5-arch1-1 x86-64)

@kamikaze
Copy link

thanks for breaking pip install pgadmin4 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests