-
Notifications
You must be signed in to change notification settings - Fork 212
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
Python packages specified via PYTHONPATH (such as ROS 2 Python packages) are considered in pixi environment even if they are related to the apt python installation #826
Comments
This is probably also related to #288, as the workaround of setting |
He @traversaro, thanks for the write up. We remember this issue as we also started with The discussion on what is should be default in isolation is indeed a hard one, we still have to figure that out. To help your users directly setting these variables can be set with the You could just generate a export PYTHONUSERBASE=intentionally-disabled
export PYTHONPATH= |
Indeed, I was aware of this for conda for a long time. The main difference I see between pixi and conda is about user expectation (or at least, how I started to introduce conda and pixi to our users). When I started to introduce conda, I always warned users that conda and apt are different things, it is important not to mix them, etc, etc (see https://github.com/robotology/robotology-superbuild/blob/master/doc/conda-forge.md and https://github.com/robotology/robotology-superbuild/blob/master/doc/install-mambaforge.md for example documents I pointed users to). So users are at least aware of possible conflicts. The pixi story is a bit different. Quoting from https://prefix.dev/blog/uv_in_pixi#our-goals-for-pixi, the goal of pixi presented to the users is to be able to start working on a project with just: Hence why I think it could make sense to think about what should be isolated by default in the
Cool, that is indeed much better then my solution! I will probably start adding it by default to any pixi package using Python packages. Just to understand, are these pixi activation scripts expected to run before any conda package activation script? Otherwise I am afraid of corrupting the value of |
Yeah I totally agree with you!
This is what the activation script looks like that we generate. As you can see we put the custom activation in last.
|
Ah, the problem is that for example in your use case |
Thanks @ruben-arts, we used your workaround in robotology/icub-models-generator#263 . Not sure if you want to keep this issue open or not, feel free to close if you think the problems discussed in the issue is tracked already somewhere else. |
Closing this in favor of #289 |
Checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pixi, using
pixi --version
.Reproducible example
You can test this on a Ubuntu 22.04 system, just follow the following steps:
The last command fails with:
Issue description
In a nutshell, if you have a pixi environment that uses python, it could pick some apt python packages if the users sets the
PYTHONPATH
environment variable in theirsetup.sh
. This is quite a common case for ROS 2 users, that typically just addsource /opt/ros/humble/setup.sh
in their.bashrc
(at least this is my experience. Note that this does not happen with regular Python apt packages, as those are installed in/usr
and are found automatically by the apt Python interprer, without the need to set anyPYTHONPATH
environment variable.To be clear, this is not a pixi-specific issue, as it the exact same behavior you have with conda/mamba. However, it is still an highly non intuitive behaviour for users, see for example robotology/icub-models-generator#262 . In particular, I could imagine that many ROS 2 users that want to experiment with pixi may encounter this problem, so I preferred to clearly report it here.
For the time being, the workaround I used in robotology/icub-models-generator#263 is to prepend every task with
export PYTHONPATH= &&
, however this is a bit cumbersome and it is not helpful if users execute commands viapixi shell
or non-task commands viapixi run
.Expected behavior
To be honest, I am not sure about this. For sure, this is related to #289 . However, I think that while for PATH it make sense to keep the system executables in the PATH (as users may want to use them in tasks and in
pixi shell
invocation), forPYTHONPATH
I am not sure if it could make sense to unset it by default, and just have an option (by default OFF) to propagate in the pixi environment thePYTHONPATH
system environment variable.The text was updated successfully, but these errors were encountered: