pgadmin4
pgadmin4 copied to clipboard
Installing via venv/pip fails with pip._vendor.packaging.version.InvalidVersion
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.
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 https://github.com/python-poetry/poetry/issues/7418 is related.
I am told that this is relevant: https://github.com/pypa/packaging/issues/774#issuecomment-2216872147
debian sid :
pip._vendor.packaging.version.InvalidVersion: Invalid version: '6.10.6-amd64'
This doesn't look like a pgAdmin issue. Installing with lower pip version works.
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
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.
If the issue is on pip side, please provide a installation guide via pip with a detailed description which pip-version pgAdmin depends on.
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.
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 https://github.com/YunoHost-Apps/pgadmin_ynh/commit/65b809428b56e783dcc758bcf9ddd97458308779 above? I just tried again and it still fails.
On Fri, 30 Aug 2024 04:17:05 -0700 Massimo-B @.***> wrote:
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 https://github.com/YunoHost-Apps/pgadmin_ynh/commit/65b809428b56e783dcc758bcf9ddd97458308779 above? I just tried again and it still fails.
I was wrong. PGadmin4 is using the platform_version marker correctly, or at least correctly as far as historical usage goes.
Pip is broken. It may take quite some time for it to be fixed, since (it seems) there are problems with the specification. (It seems that using platform_version should, according to the spec, pretty much never work.)
As written, PGadmin4 will never work with whatever pip releases are broken in this fashion. That said, there may well be ways to work-around the problem. (E.g. https://github.com/adisbladis/nixpkgs/commit/b2da9da5330e7da219df0e47ab37ff16fd31f8ba)
It occurs to me that one possible work-around might be to re-order the tests in the requirement specifier occurring at: https://github.com/pgadmin-org/pgadmin4/blob/master/pkg/pip/setup_pip.py#L48 If pip's evaluation of requirement specifiers short-circuits and does not necessarily evaluate all the conditions, then putting the platform_release test last will solve the problem on all platforms but that of the ARM64 macOS.
This would go a long way toward mitigating the severity of the issue.
See also: https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers
Regards,
Karl @.***> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
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.
On Tue, 03 Sep 2024 23:41:23 -0700 Massimo-B @.***> wrote:
You mentioned a possible work-around, that would be a change in pgAdmin4 to work-around the bug in pip?
Yes. In the Pgadmin4 packaging.
Someone would have to try it and then submit a pull request.
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.
The problem with pip exists because of the pip bug already referenced having to do with enforcing python packaging standards. The change that fixed the pip bug exposed issues in the version comparison specification. It is unclear what the resolution will be and whether it will result in a change that will resolve Pgadmin4's issue.
Regards,
Karl @.***> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
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.
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 !
The pip issue linked to above now has another issue attached which requests that pip requirement specifications be evaluated lazily. https://github.com/pypa/packaging/pull/834 If this is changed in pip, then re-arranging the requirement specs of pgadmin4 would greatly mitigate the problem.
I imagine it will take pip some time to address the underlying issue because it is specification related. Meanwhile it would be nice to monitor the "lazy" issue and adjust the pgadmin4 packaging when it is resolved.
Or, figure out if there is another way to get the pgadmin4 packaging to have the requirements it needs without bumping into the pip issue.
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. 😉
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.
@SIP-Online thank you for the time and the patch
binary
Re-opening this to see how we can change pgAdmin build code to include this.
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.whlThis 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)
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.whlThis 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)
thanks for breaking pip install pgadmin4 :)
a script to automate this and easily install the latest wheel. just change the v parameter to the current pgadmin4 versions which is now 8.14:
v=8.14
wget "https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v$v/pip/pgadmin4-$v-py3-none-any.whl"
python3 -m wheel unpack pgadmin4-$v-py3-none-any.whl
sed -i '/darwin/ s/\([[:digit:]]\);.*/\1/' "pgadmin4-$v/pgadmin4-$v.dist-info/METADATA"
sed -i '/psycopg\[binary\]==3.1.19/d' "pgadmin4-$v/pgadmin4-$v.dist-info/METADATA"
python3 -m wheel pack --build-number 2 pgadmin4-$v
# activate a new venv
python3 -m venv venv/pgadmin4
source venv/pgadmin4/bin/activate
pip install ./pgadmin4-$v-2-py3-none-any.whl
# clean up
rm -r pgadmin4-$v-2-py3-none-any.whl
rm -r pgadmin4-$v
sudo mkdir /var/log/pgadmin /var/lib/pgadmin
sudo chown $USER:$USER /var/log/pgadmin /var/lib/pgadmin
pgadmin4
On Wed, 18 Dec 2024 09:15:52 -0800 Farid Cheraghi @.***> wrote:
a script to automate this and easily install the latest wheel. just change the
vparameter to the current pgadmin4 versions which is now 8.14:
You could submit an actual pull request that makes this change. It would break support for the Mac OS, but maybe it'd be accepted anyway because right now support for every OS is broken.
Regards,
Karl @.***> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
It appears that this issue is due to pgadmin4 not complying with PEP440 (https://peps.python.org/pep-0440/) for naming versions. Apparently, pip started enforcing this. They gave folks almost 10 years to comply with the standard naming structure for python packages. I found a workaround, but it isn't elegant, and it might break other things. The workaround involves changing the regex in the pip version checking. The correct answer is for pgadmin4 to comply with PEP440 like nearly every other python packages on the planet.
On Mon, 27 Jan 2025 05:54:29 -0800 brassnkeys @.***> wrote:
It appears that this issue is due to pgadmin4 not complying with PEP440 (https://peps.python.org/pep-0440/) for naming versions.
The workaround involves changing the regex in the pip version checking. The correct answer is for pgadmin4 to comply with PEP440 like nearly every other python packages on the planet.
Is that it, or is it that pgadmin packaging is using the pip version checking code to check the MacOS kernel version? It seems like pgadmin4's release (e.g., 8.14) is PEP440 compliant. Where's the lack of compliance?
It does have something to do with the enforcement of PEP440.
Maybe there's packaging (mis-?)usage that used to work and now does not? IIRC the pip issue linked somewhere in this thread has more information. I don't remember if I ever got to the actual root cause, thinking that someone at pgadmin would dig all the way into it and come up with a definitive answer.
Regards,
Karl @.***> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein
sudo chown USERNAME:USERNAME /var/log/pgadmin /var/lib/pgadmin
@faridcher since this is a script, will you consider changing USERNAME to $USER?
There was a recent commit around this https://github.com/pgadmin-org/pgadmin4/commit/74e776ba21e1a3794b56cf492cfedfb75ed648d7. This might fix in upcoming pgAdmin version.
Fixed in latest version.