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

Building Python AUR packages inside a virtualenv will install files inside the virtualenv #76

Closed
r-darwish opened this issue Dec 21, 2017 · 6 comments

Comments

@r-darwish
Copy link

r-darwish commented Dec 21, 2017

I ran yay -S python-pgspecial when inside a virtual environment in /tmp/virtualenv. After the installation was complete I ran yay -Ql python-pgspecial to see that the files were installed inside the virtualenv:

python-pgspecial /tmp/
python-pgspecial /tmp/virtualenv/
python-pgspecial /tmp/virtualenv/lib/
python-pgspecial /tmp/virtualenv/lib/python3.6/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial-1.8.0-py3.6.egg-info/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial-1.8.0-py3.6.egg-info/PKG-INFO
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial-1.8.0-py3.6.egg-info/SOURCES.txt
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial-1.8.0-py3.6.egg-info/dependency_links.txt
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial-1.8.0-py3.6.egg-info/requires.txt
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial-1.8.0-py3.6.egg-info/top_level.txt
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__init__.py
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/__init__.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/__init__.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/dbcommands.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/dbcommands.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/iocommands.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/iocommands.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/main.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/main.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/namedqueries.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/__pycache__/namedqueries.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/dbcommands.py
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/__init__.py
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/__pycache__/
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/__pycache__/__init__.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/__pycache__/__init__.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/__pycache__/commands.cpython-36.opt-1.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/__pycache__/commands.cpython-36.pyc
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/help/commands.py
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/iocommands.py
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/main.py
python-pgspecial /tmp/virtualenv/lib/python3.6/site-packages/pgspecial/namedqueries.py
@Morganamilo
Copy link
Contributor

I know this is a little old now but if you're still interested, does it happen with makepkg? and does it still happen with yay? I've never used virtualenv so I have no idea how it works or affects things.

@r-darwish
Copy link
Author

Thanks for replying. Basically most of what virtualenv does is set some environment variables when it is activated. The most notable thing that it does is appending the Python's virtualenv into PATH. Once pip (Python's package manager) is called, it installs packages into the virtualenv's directory. virtualenv is activated by sourceing its file into the current shell. It does not alter the system globally.

This seems to happen with makepkg as well, so this probably isn't yay's fault. However, pacaur seems to do something to overcome it, I'm just not sure what. Perhaps it's building as a different user, or perhaps it makes sure that its sub processes do not inherit their parent's environment variables.

Reproduction:

python3 -m venv /tmp/env
source /tmp/env/bin/activate
which python # Should be /tmp/env/bin/python
yay -S python-infinity # Or makepkg -si
pacman -Ql python-infinity # Files will be installed in /tmp/env

@Morganamilo
Copy link
Contributor

That's strange, if it's a makepkg problem then I guess it's not a Yay bug but if Pacaur can handle it then we could too.

@Morganamilo
Copy link
Contributor

I tested it just now and it installs on /tmp in Yay, Pacaur and makekg. Did you forget to run pacaur in env?

@r-darwish
Copy link
Author

Well, that's embarrassing. It turns our that the packages that I tested were already in pacaur's
cache, so trying to reinstall them inside a virtualenv didn't change anything as they were already
built.

Now I'm not really sure what to ask, as it seems that no other package manager overcomes this
situation. I can't think of any solution which will not involve hard-coding special treatment for
Python. I guess that it will make more sense if I ask in the Arch forums if this is something that
makepkg should handle.

@Morganamilo
Copy link
Contributor

Morganamilo commented Feb 18, 2018

I think its either an error with the pkgbuild or upstream and not really anything makepkg should support. My guess is the package finds the python path and installs there. Normally it would detect the dir to be /usr/lib/python3.6/ but the virtualenv overrides it and says the python dir is /tmp/virtualenv/lib/python3.6.

Hopefully that can be fixed easily by adding some sort of flag --pythonpath or something to the pkgbuild and have it figure out the actual python path.

This works, builds inside env, packages outside env.

#Enter virtualenv
makepkg --noarchive
#Exit virtualenv
makepkg --repackage

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

No branches or pull requests

2 participants