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

system packages hide appimages one #26

Open
niess opened this issue Jun 10, 2019 · 2 comments
Open

system packages hide appimages one #26

niess opened this issue Jun 10, 2019 · 2 comments

Comments

@niess
Copy link

niess commented Jun 10, 2019

Let say that we generate a conda image with numpy packaged inside, e.g. as:

export CONDA_CHANNEL=anaconda
export CONDA_PACKAGES=numpy
./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin conda -i numpy.png -d numpy.desktop --output appimage

Then if there is a system install of numpy, in /usr/local/lib/python3.7/site-packages/ it will be loaded instead of the AppImage one. You can check this by running:

sudo pip3.7 install numpy
./numpy-x86_64.AppImage -c "import numpy; print(numpy)"
sudo pip3.7 uninstall numpy
./numpy-x86_64.AppImage -c "import numpy; print(numpy)"

The reason is that at its init Python thinks it is running from a system install and as so it adds this fixed location to is search path before the AppImage site packages. You can see this by running:

./numpy-x86_64.AppImage -c "import sys; print(sys.path)"

The last item is the AppImage site packages. It is preceded by the fixed /usr/local/lib/python3.7/site-packages/ search path.

Possible solution: remove this /usr/local/lib/python3.7/site-packages/ at Python's init by adding a sitecustomize.py file to the AppImage site packages. For example as here. Note that it might happen that someone explicitly requests this location by adding it to PYTHONPATH. In this case it should not be removed from the search path.

@TheAssassin
Copy link
Member

That's quite new to me. I was pretty sure that conda stuff really is isolated.

Your solution looks somewhat elegant to me, may I just copy that (giving credit, but using this project's license)? I'm pretty confident conda supports putting your own sitecustomize.py somewhere into the prefix.

@niess
Copy link
Author

niess commented Jun 11, 2019

@TheAssassin : I think that it is a problem in the Python path initialisation itself. It is not meant to operate with a variable install prefix, as we have with the AppImage. Then, Python fails to properly initialise its search path for site packages, and it sets a fallback.

Please feel free to copy / adapt the sitecustomize.py file. I change the whole license to MIT to be consistent with linuxdeploy.

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