fix(bzlmod): set the default_version to the python_version flag (#2253)

With this change we set the default value of `--python_version` when
the `python.toolchain` is used in `bzlmod` and we generate the
appropriate config settings based on the registered toolchains and
given overrides by the root module.

This means that we expect the `--python_version` to be always set to
a non-empty value under `bzlmod` and we can cleanup code which was
handling `//conditions:default` case. This also means that we can
in theory drop the requirement for `python_version` in `pip.parse`
and just setup dependencies for all packages that we find in the
`requirements.txt` file and move on. This is left as future work
by myself or anyone willing to contribute. We can also start reusing
the same `whl_library` instance for multi-platform packages because
the python version flag is always set - this will simplify the layout
and makes the feature non-experimental anymore under bzlmod.

Summary:
* Add `@pythons_hub` to the `WORKSPACE` with dummy data to make
  pythons_hub work.
* Add `MINOR_MAPPING` and `PYTHON_VERSIONS` to pythons_hub to
  generate the config settings.
* Remove handling of the default version in `pypi` code under bzlmod.

Work towards #2081, #260, #1708

---------

Co-authored-by: Richard Levasseur <rlevasseur@google.com>
22 files changed
tree: 6a41977775268ba559ac3f41e2bd722394f26c1a
  1. .bazelci/
  2. .bcr/
  3. .ci/
  4. .github/
  5. docs/
  6. examples/
  7. gazelle/
  8. python/
  9. sphinxdocs/
  10. tests/
  11. third_party/
  12. tools/
  13. .bazelignore
  14. .bazelrc
  15. .bazelversion
  16. .git-blame-ignore-revs
  17. .gitattributes
  18. .gitignore
  19. .pre-commit-config.yaml
  20. .readthedocs.yml
  21. addlicense.sh
  22. AUTHORS
  23. BUILD.bazel
  24. BZLMOD_SUPPORT.md
  25. CHANGELOG.md
  26. CONTRIBUTING.md
  27. CONTRIBUTORS
  28. DEVELOPING.md
  29. internal_deps.bzl
  30. internal_setup.bzl
  31. LICENSE
  32. MODULE.bazel
  33. README.md
  34. version.bzl
  35. WORKSPACE
  36. WORKSPACE.bzlmod
README.md

Python Rules for Bazel

Build status

Overview

This repository is the home of the core Python rules -- py_library, py_binary, py_test, py_proto_library, and related symbols that provide the basis for Python support in Bazel. It also contains package installation rules for integrating with PyPI and other indices.

Documentation for rules_python is at https://rules-python.readthedocs.io and in the Bazel Build Encyclopedia.

Examples live in the examples directory.

The core rules are stable. Their implementation is subject to Bazel's backward compatibility policy. This repository aims to follow semantic versioning.

The Bazel community maintains this repository. Neither Google nor the Bazel team provides support for the code. However, this repository is part of the test suite used to vet new Bazel releases. See How to contribute page for information on our development workflow.

Documentation

For detailed documentation, see https://rules-python.readthedocs.io

Bzlmod support

  • Status: Beta
  • Full Feature Parity: No

See Bzlmod support for more details.