For more detailed setup instructions, see https://rules-python.readthedocs.io/en/latest/getting-started.html
Using Bzlmod
Add to your MODULE.bazel
file:
bazel_dep(name = "rules_python", version = "1.0.0")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pip",
python_version = "3.11",
requirements_lock = "//:requirements_lock.txt",
)
use_repo(pip, "pip")
Using WORKSPACE
Paste this snippet into your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
strip_prefix = "rules_python-1.0.0",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
Gazelle plugin
Paste this snippet into your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python_gazelle_plugin",
sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07",
strip_prefix = "rules_python-1.0.0/gazelle",
url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz",
)
# To compile the rules_python gazelle extension from source,
# we must fetch some third-party go dependencies that it uses.
load("@rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")
_py_gazelle_deps()
What's Changed
- docs: fix refs to precompile source retention flag/attr in precompiling docs by @rickeylev in #2419
- refactor: Add GAZELLE_VERBOSE env and log parser failures by @dougthor42 in #2420
- refactor(toolchain): use bazel to extract
zstd
archives by @aignas in #2412 - refactor!(toolchain): remove uname dep in the repository_rule stage by @aignas in #2406
- fix(pypi): handle multiple versions of the same package when parsing requirements files by @ewianda in #2377
- fix(uv): Fix sha256 for uv binary for aarch64-apple-darwin by @schultetwin in #2422
- feat(musl): add musl toolchain by @aignas in #2402
- chore: extra code removals before 1.0 by @aignas in #2421
- feat(pypi): Add extra_hub_aliases to pip_repository too by @gholms in #2426
- chore!(pip.parse): remove parse_all_requirements_files attribute by @aignas in #2407
- chore(gazelle): Rename GAZELLE_VERBOSE env var; use idiomatic go; add comments by @dougthor42 in #2428
- fix: make sys.executable work with script bootstrap by @rickeylev in #2409
- tests: make workspace CI jobs enable workspace mode by @comius in #2435
- fix: use com_google_protobuf in WORKSPACE by @comius in #2432
- chore: add dougthor42 as one of the gazelle owners by @aignas in #2427
- ci: rm the lock file testing by @aignas in #2430
- tests: make some tests compatible with Bazel 9 fix various tests relying on Bazel builtin providers existing by @rickeylev in #2433
- refactor(pypi): move config setting processing to the macro by @aignas in #2424
- chore: rename the dev-only setup files to more clearly self-describe what they are by @rickeylev in #2436
- fix: correctly obtain relative path required for the venv created by
--bootstrap_impl=script
by @chowder in #2439 - fix: Propagate common kwargs to sphinx_run by @tpudlik in #2442
- fix: upgrade to bazel_features 1.21.0 for Bazel 8 rc3 support by @rickeylev in #2440
- fix(render_pkg_aliases): correctly render when we have target_platforms set by @aignas in #2447
- deps: upgrade to stardoc 0.7.2 for Bazel 8 support by @rickeylev in #2451
- chore: auto compute prelease setting by @rickeylev in #2452
- feat(runfiles): add support for spaces and newlines in runfiles paths by @dizzy57 in #2456
- fix: upgrade to rules_bazel_integration_test 0.27.0 for bazel 9 compatibility by @rickeylev in #2454
- doc: improve alias error msg in pip hubs by @aignas in #2458
- fix: Add
libs/python3.lib
to libpython target for SABI builds on Windows by @nicholasjng in #1820 - fix: dependency resolver on windows only works when --enable_runfiles and --windows_enable_symlinks is used by @ChewyGumball in #2457
- chore: remove defunct code from py_cc_link_params_info.bzl by @rickeylev in #2465
- fix: add missing api distribution target by @rickeylev in #2464
- docs: mention calling register_toolchains in custom toolchain docs by @rickeylev in #2463
- test: Enable non-ABI3 libs linking test for Windows by @nicholasjng in #2461
- fix: only delete first sys.path entry in the stage-2 bootstrap if PYTHONSAFEPATH is unset or unsupported by @chowder in #2418
- fix(gazelle): empty list by @hunshcn in #2099
- chore: bump the changelog to 1.0 by @aignas in #2470
New Contributors
- @schultetwin made their first contribution in #2422
- @gholms made their first contribution in #2426
- @ChewyGumball made their first contribution in #2457
Full Changelog: 0.40.0...1.0.0