Skip to content

Commit

Permalink
feat: Bzlmod refactor and allow for dynamic python interpreter target
Browse files Browse the repository at this point in the history
This commit includes:

- adding a new bzlmod_build_file_geration demo
- adding the capabilty where python.toolchain create the symlink
to set the pip python interperter target
- improved documentation in the pip arguments
  • Loading branch information
chrislovecnm committed May 4, 2023
1 parent 532f07a commit 4f04915
Show file tree
Hide file tree
Showing 33 changed files with 2,294 additions and 17 deletions.
48 changes: 48 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ buildifier:
test_targets: ["..."]
.coverage_targets_example_bzlmod: &coverage_targets_example_bzlmod
coverage_targets: ["//:test"]
.coverage_targets_example_bzlmod_build_file_generation: &coverage_targets_example_bzlmod_build_file_generation
coverage_targets: ["//:bzlmod_build_file_generation_test"]
.coverage_targets_example_multi_python: &coverage_targets_example_multi_python
coverage_targets:
- //tests:my_lib_3_10_test
Expand Down Expand Up @@ -179,6 +181,52 @@ tasks:
working_directory: examples/bzlmod
platform: windows

integration_test_bzlmod_generate_build_file_generation_ubuntu_min:
<<: *minimum_supported_bzlmod_version
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod_build_file_generation
name: example bzlmod build file min bazel version integration test
working_directory: examples/bzlmod_build_file_generation
platform: ubuntu2004
integration_test_bzlmod_generation_build_files_ubuntu:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod_build_file_generation
name: example bzlmod build file integration test
working_directory: examples/bzlmod_build_file_generation
platform: ubuntu2004
integration_test_bzlmod_generation_build_files_ubuntu_run:
<<: *reusable_build_test_all
name: example bzlmod build file running gazelle and pip integration test
working_directory: examples/bzlmod_build_file_generation
platform: ubuntu2004
shell_commands:
# Make a change to the locked requirements and then assert that //:requirements.update does the
# right thing. Also testing that gazelle runs as expected
- "echo '' > requirements_lock.txt"
- "! git diff --exit-code"
- "bazel run //:requirements.update"
- "git diff --exit-code"
- "bazel run //:gazelle_python_manifest.update"
- "bazel run //:gazelle -- update"
integration_test_bzlmod_build_file_generation_debian:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod_build_file_generation
name: example bzlmod build file integration test
working_directory: examples/bzlmod_build_file_generation
platform: debian11
integration_test_bzlmod_build_file_generation_macos:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod_build_file_generation
name: example bzlmod build file integration test
working_directory: examples/bzlmod_build_file_generation
platform: macos
integration_test_bzlmod_build_file_generation_windows:
<<: *reusable_build_test_all
# coverage is not supported on Windows
name: example bzlmod build file integration test
working_directory: examples/bzlmod_build_file_generation
platform: windows

integration_test_multi_python_versions_ubuntu_min:
<<: *minimum_supported_version
<<: *reusable_build_test_all
Expand Down
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# This lets us glob() up all the files inside the examples to make them inputs to tests
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
# To update these lines, run tools/bazel_integration_test/update_deleted_packages.sh
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/get_url,examples/bzlmod,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/multi_python_versions,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/py_proto_library,examples/relative_requirements,tests/compile_pip_requirements,tests/pip_repository_entry_points,tests/pip_deps
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/get_url,examples/bzlmod,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/multi_python_versions,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/py_proto_library,examples/relative_requirements,tests/compile_pip_requirements,tests/pip_repository_entry_points,tests/pip_deps
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/get_url,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/multi_python_versions,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/py_proto_library,examples/relative_requirements,tests/compile_pip_requirements,tests/pip_repository_entry_points,tests/pip_deps
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/get_url,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/runfiles,examples/multi_python_versions,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_install,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_import,examples/py_proto_library,examples/relative_requirements,tests/compile_pip_requirements,tests/pip_repository_entry_points,tests/pip_deps

test --test_output=errors

Expand Down
4 changes: 2 additions & 2 deletions docs/pip_repository.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ bazel_integration_test(
timeout = "long",
)

bazel_integration_test(
name = "bzlmod_build_file_generation_example",
timeout = "long",
)

bazel_integration_test(
name = "pip_install_example",
timeout = "long",
Expand Down
2 changes: 1 addition & 1 deletion examples/build_file_generation/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test --test_output=errors
test --test_output=errors --enable_runfiles

# Windows requires these for multi-python support:
build --enable_runfiles
Expand Down
Loading

0 comments on commit 4f04915

Please sign in to comment.