Skip to content

Real script directory leaks to sys.path and breaks hermeticity. #16

Description

@zhe-tao

Problem

In short, we (in the end) run a script with the command

python $@

But python prepends the real script directory to sys.path:

python script.py command line: prepend the script’s directory. If it’s a symbolic link, resolve symbolic links.

which exposes many local files and overrides runfiles, especially when the script is under the workspace root.

Solution

I plan to either require python to not prepend them and add the script (symbolic link) directory to PYTHONPATH, or just setup the PYTHONSAFEPATH in pywrapper.sh.

I was experimenting with building python modules with C/C++ extensions in Bazel. Although the Bazel runtime environment/runfiles looks all right, the script just can not find the built dynamic libraries because the very first search path in sys.path is the real bare root directory.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions