problem installing python package via setup.py --user

I’m running into an issue installing a specific python package (https://github.com/pazz/alot/) from source using python3 setup.py install --user. The package depends on gpg and gpgme but somehow setuptools does pick up system packages installed in /usr/lib64/python3.8/site-packages. So if I run the above script it tries to install python3-gpg from pypi into ~/.local/lib/python3.8/site-packages/ (which I don’t want because I have the system one installed). If I uninstall the the gpg package in $HOME starting alot fails with


Traceback (most recent call last):   
File "/home/jschrod/.local/bin/alot", line 6, in      
   from pkg_resources import load_entry_point
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3252, in      
   def _initialize_master_working_set():   
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3235, in _call_aside     
   f(*args, **kwargs)   
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set     
   working_set = WorkingSet._build_master()   
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 583, in _build_master     
   ws.require(__requires__)   
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 900, in require     
   needed = self.resolve(parse_requirements(requirements))   
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 786, in resolve     
   raise DistributionNotFound(req, requirers) 
pkg_resources.DistributionNotFound: The 'gpg' distribution was not found and is required by alot

Otherwise I have no problems importing gpg via python e.g.

python3 -m "import gpg"

returns without errors

I suspect this is somehow related to the issue discussed here: https://bugs.python.org/issue1294959 but I don’t have any solution except for maybe adding /usr/lib64/python3.8/site-packages to my PYTHONPATH

Hi
That’s a long and old issue… 15 years…

Why not install at a system level? Or you don’t have root access on the system?

If you do, here are some python3 builds;
https://build.opensuse.org/package/show/home:malcolmlewis:TESTING/python-alot
https://build.opensuse.org/package/show/home:malcolmlewis:TESTING/python-urwidtrees

I also see it available from PyPi.

So,
You have options to install from openSUSE
and
The official Python repositories
Before you need to consider compiling from source.

Unless you have a special reason to need something from latest source?

TSU

Well the PyPi version is very old and I prefer to follow git for this package. I think there is something wrong with setuptools in python though, because it does not detect some system packages, which is an issue that should be fixed I guess. I’ve filed a bug https://bugzilla.opensuse.org/show_bug.cgi?id=1168795 for anyone else running into this.

Agree with Malcolm,
Have you considered running setup.py without the “–user” option?

TSU

Hi
The ones I packaged up are the latest from git? Version: 0.9+git20200409.867e30ce