-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bazel should put external repos after stdlib on PYTHONPATH #5899
Comments
See #7959 for related |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 3 years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team ( |
Description of the problem / feature request:
Bazel prepends external dependencies to
PYTHONPATH
before the stdlib.This makes external dep modules hide stdlib modules, which is generally a bad thing.
As an example, consider trying to use the
enum
module with code that is Python 2 and Python 3 compatible. The enum34 package provides theenum
module in py2. However, its only a subset of later Python 3 enum features; i.e., its not a drop-in replacement forenum
in Python 3.4+So you create a
new_http_archive rule
and get the "enum" directory ontosys.path
, which now looks something like:['/some-bazel-path/enum34_archive', 'python3.6/stdlib.zip", "python3.6/site-packages']
Now if you
import enum
, it'll take the enum module from the enum34_archive entry, which breaks all sorts of things.Instead, it should really be putting the repos after the stdlib, probably where site-packages would normally go.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
The simplest way is to run a Python 3 binary that depends on the enum34 package.
Then import various stdlib modules in foo.py.
Then run bazel with python3 (I was using 3.6)
bazel build --python_path=/usr/bin/python3.6 :foo
bazel-bin/foo
And it should fail out in some stdlib modules that rely on enum
What operating system are you running Bazel on?
What's the output of
bazel info release
?Have you found anything relevant by searching the web?
The text was updated successfully, but these errors were encountered: