Skip to content
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

feat(bzlmod): Allow bzlmod pip.parse to reference the default python toolchain and interpreter #1303

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

chrislovecnm
Copy link
Collaborator

@chrislovecnm chrislovecnm commented Jul 10, 2023

This commit defaults the pip.parse python_version attribute to the default version of
Python, as configured by the python.toolchain extension. This allows a user to use the
Python version set by rules_python or the root module. Also, this makes setting the
attribute optional (as it has a default) and we automatically select the interpreter.

Closes #1267

This commit defaults the python_version attribute to the default
version of Python.  This allows a user to use the version we
define in rules_python MODULE.bazel.  Also, a user can now
not set the python_version attribute on a pip tag_class
and we automatically set the interpreter.
@chrislovecnm chrislovecnm changed the title Allow bzlmod pip.parse to reference the default python feat(bzlmod): Allow bzlmod pip.parse to reference the default python Jul 10, 2023
@chrislovecnm chrislovecnm added the type: bzlmod bzlmod work label Jul 10, 2023
@chrislovecnm chrislovecnm changed the title feat(bzlmod): Allow bzlmod pip.parse to reference the default python feat(bzlmod): Allow bzlmod pip.parse to reference the default python toolchain and interpreter Jul 10, 2023
@rickeylev rickeylev added this pull request to the merge queue Jul 10, 2023
Merged via the queue into bazelbuild:main with commit e5d9f10 Jul 10, 2023
@chrislovecnm chrislovecnm deleted the default-interpreter branch July 10, 2023 23:25
chrislovecnm added a commit that referenced this pull request Jul 24, 2023
… python toolchain and interpreter (#1303)"

This reverts commit e5d9f10.
github-merge-queue bot pushed a commit that referenced this pull request Jul 26, 2023
…hon version (#1341)

Reverts #1303

The main issue is that `pip.parse()` accepts a locked requirements file
-- this means
the requirements are specific to a particular Python version[1]. Because
the default Python
version can arbitrarily change, the lock file may not be valid for the
Python version
that is used at runtime. The net result is a module will use
dependencies for e.g. Python
3.8, but will use 3.9 at runtime. Additionally, the dependencies
resolved for 3.8 will
be created under names such as `@foo_39` (because that's the
python_version pip.parse sees),
which is just more confusing.

BREAKING CHANGE:
* pip.parse() must have `python_version` explicitly set. Set it to the
Python version
    used to resolve the requirements file.

[1] Lock files aren't necessarily version specific, but we don't
currently support the
environment markers in lock files to make them cross-python-version
compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bzlmod bzlmod work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow bzlmod pip.parse to reference the default python
2 participants