Project

General

Profile

Actions

Bug #13841

open

python tools should not add user's site directory

Added by Andy Fiddaman 16 days ago. Updated 16 days ago.

Status:
New
Priority:
Low
Assignee:
Category:
tools - gate/build tools
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

I came across a system where the user's local python lib contained a module called pkg at a higher version than the system's IPS pkg.
When building gate, package validation failed with:

Traceback (most recent call last):
  File "/data/omnios-build/omniosorg/bloody/illumos/usr/src/tools/proto/root_i386-nd/opt/onbld/bin/validate_pkg", line 41, in <module>
    from pkg import actions
ImportError: cannot import name 'actions' from 'pkg' (/data/omnios-build/.local/lib/python3.9/site-packages/pkg/__init__.py)

This is a different pkg

% ls ~/.local/lib/python3.9/site-packages/pkg
__init__.py                 pkgformat.py
__pycache__/                pkglist.py
apt_data_set_generator.py   repo.py
apt_repo.py                 repomd.py
apt_runner.py               runner.py
aptmd.py                    version.py
metalink.py
% python -mpip show pkg
Name: pkg
Version: 0.2
Summary: Python scripts dealing with software packages used in building applications and systems
Home-page: https://github.com/joaomdsc/pkg
Author: João Moreira de Sá Coutinho
Author-email: joao.moreiradsc@gmail.com
License: UNKNOWN
Location: /data/omnios-build/.local/lib/python3.9/site-packages
Requires:
Required-by:

Fundamentally, I don't think the python tools should be looking for modules in the building user's local python lib. This can be avoided using python's -s option or by setting the PYTHONNOUSERSITE environment variable.

       -s     Don't add user site directory to sys.path.

       PYTHONNOUSERSITE
              If this is set to a non-empty string it is equivalent to
              specifying the -s option (Don't add the user site directory to
              sys.path).

For a consistent build environment, we should also consider adding:

        -E     Ignore environment variables like PYTHONPATH and PYTHONHOME that
              modify the behaviour of the interpreter.

or unset these in nightly / bldenv.

Both of these options are available in Python 2.7 and above.

Actions #1

Updated by Andy Fiddaman 16 days ago

  • Assignee set to Andy Fiddaman
Actions #2

Updated by Electric Monk 16 days ago

  • Gerrit CR set to 1525
Actions

Also available in: Atom PDF