Skip to content

env.sh breaks python2 scripts #6

@mmunoz-gmv

Description

@mmunoz-gmv

The file init.rb includes the following code:

# Autoproj changes PYTHONUSERBASE, but we need access to Python packages installed at system level 
# (e.g., packages installed by TASTE at the default location), so we add the default user-site to 
# PYTHONPATH.
default_python3_user_base = `env -i python3 -m site --user-site`.chop
Autoproj.env_set 'PYTHONPATH', default_python3_user_base, "$AUTOPROJ_CURRENT_ROOT/install/lib/python"

The purpose of the code is that pip packages are installed within the ESROCOS install folder. However, the environment variable PYTHONPATH is used by all Python interpreters, which causes unintended consequences. In particular, the code adds the directory ~/.local/lib/python3.5/site-packages to the Python path, breaking any script intended for Python 2.7 (which is the case for some in TASTE).

Furthermore, the fact that autoproj changes PYTHONUSERBASE may cause problems with other tools that install Python packages, as TASTE does and possibly ROS.

One possible solution would be to let autoproj use the default PYTHONUSERBASE. It should be possibe to do this by setting the variable AUTOPROJ_PYTHONUSERBASE to the default. I think that this could be done in the init.rb script like shown below:

Autoproj.env_set 'AUTOPROJ_PYTHONUSERBASE', `env -i python -m site --user-base`.chop

However, I'm not sure that this is executed before or after the exporting of the variable. I'm not sure how to test this without modifying the master branch, as it affects the initial installation of ESROCOS.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions