Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Fix incompatibility with Python Toolchains #99

Merged
merged 8 commits into from
May 9, 2019

Conversation

aaliddell
Copy link
Contributor

@aaliddell aaliddell commented May 5, 2019

Fixes #98 by detecting the default toolchain wrappers and replacing with env versions. I'm perhaps not totally happy with how it's done, as any change in the path to these wrappers would break things again, so open to suggestions. Also, for Python 2 should we use /usr/bin/python or /usr/bin/python2, I prefer the latter but don't know how this behaves on all systems?

Also, now that we have PyInfo provider, the import paths are passed directly from Starlark to the compiler, removing a bit of fragility in parsing the stub file for those. However, I can't see a way to pass the interpreter directly, as this doesn't appear to be available to Starlark. This removed a TODO with reference b/29227737, if that means anything internally?

Tested with both the default toolchain and a custom one to ensure the correct shebang ends up at the top of the par file. It might be worth adding a test that excercises this, but until the toolchains flag is flipped in CI the test will always fail.

@aaliddell
Copy link
Contributor Author

Regarding the python vs python2 for Python 2 question: the concern was that the latter may not exist everywhere, but PEP-394 specifies that it must exist and is a well supported convention to depend upon.

Copy link

@tmc tmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff could be pared down a bit to just the relevant parts.

@brandjon
Copy link
Contributor

brandjon commented May 6, 2019

I'm perhaps not totally happy with how it's done, as any change in the path to these wrappers would break things again, so open to suggestions.

I wouldn't worry about it. This is a bespoke hack to make subpar work with a particular toolchain, so I think it's ok to assume some implementation details about that toolchain.

Also, for Python 2 should we use /usr/bin/python or /usr/bin/python2, I prefer the latter but don't know how this behaves on all systems?

python2 please. I'd rather break users who fail to specify an appropriate toolchain for their platform, than choose a default that ends up invoking the wrong version interpreter.

Also, now that we have PyInfo provider, the import paths are passed directly from Starlark to the compiler, removing a bit of fragility in parsing the stub file for those.

Cool!

However, I can't see a way to pass the interpreter directly, as this doesn't appear to be available to Starlark.

bazelbuild/bazel#7805

This removed a TODO with reference b/29227737, if that means anything internally?

It was an obsolete bug asking for imports to be accessible from PyInfo, which it has been for some time now.

Tested with both the default toolchain and a custom one to ensure the correct shebang ends up at the top of the par file. It might be worth adding a test that excercises this, but until the toolchains flag is flipped in CI the test will always fail.

I won't block the PR on this, but for reference the buildkite pipeline is defined here, and it looks like it can take custom flags.

@aaliddell
Copy link
Contributor Author

python2 please. I'd rather break users who fail to specify an appropriate toolchain for their platform, than choose a default that ends up invoking the wrong version interpreter.

Alright, that's the way it is now.

bazelbuild/bazel#7805

We can have a separate issue to track the desire to change the way the interpreter is found, which can resolve if PyRuntimeInfo becomes available.

I won't block the PR on this, but for reference the buildkite pipeline is defined here, and it looks like it can take custom flags.

Ok, I'll take a look

@tmc
Copy link

tmc commented May 7, 2019

The postsubmit is probably a better place but I changed the travisci config to run with the toolchains flag here: f0c9ec7
some of the tests are going to fail as they explicitly check which files end up in the archives (

if [ "$PAR" -eq 1 ]; then
). Personally I'm a fan of getting this in and expanding test flags as a follow-on.

I had started a minimal diff here with the flag in each state but I'll close in favor of this diff: #100

@aaliddell
Copy link
Contributor Author

Thanks, changes made 👍

Copy link
Contributor

@brandjon brandjon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Will try to merge tomorrow and see what else breaks due to the toolchains flag. Thanks for the PR!

@brandjon brandjon merged commit a25a2f2 into google:master May 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build fails with bazel 0.25 --incompatible_use_python_toolchains
3 participants