Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,41 +329,41 @@ tasks:
<<: *minimum_supported_version
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod_build_file_generation
name: "examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel"
working_directory: examples/bzlmod_build_file_generation
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, minimum Bazel"
working_directory: gazelle/examples/bzlmod_build_file_generation
platform: ubuntu2204
bazel: 7.x
integration_test_bzlmod_generation_build_files_ubuntu:
<<: *reusable_build_test_all
<<: *coverage_targets_example_bzlmod_build_file_generation
name: "examples/bzlmod_build_file_generation: Ubuntu"
working_directory: examples/bzlmod_build_file_generation
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu"
working_directory: gazelle/examples/bzlmod_build_file_generation
platform: ubuntu2204
integration_test_bzlmod_generation_build_files_ubuntu_run:
<<: *reusable_build_test_all
name: "examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip"
working_directory: examples/bzlmod_build_file_generation
name: "gazelle/examples/bzlmod_build_file_generation: Ubuntu, Gazelle and pip"
working_directory: gazelle/examples/bzlmod_build_file_generation
platform: ubuntu2204
shell_commands:
- "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: "examples/bzlmod_build_file_generation: Debian"
working_directory: examples/bzlmod_build_file_generation
name: "gazelle/examples/bzlmod_build_file_generation: Debian"
working_directory: gazelle/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: "examples/bzlmod_build_file_generation: MacOS"
working_directory: examples/bzlmod_build_file_generation
name: "gazelle/examples/bzlmod_build_file_generation: MacOS"
working_directory: gazelle/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: "examples/bzlmod_build_file_generation: Windows"
working_directory: examples/bzlmod_build_file_generation
name: "gazelle/examples/bzlmod_build_file_generation: Windows"
working_directory: gazelle/examples/bzlmod_build_file_generation
platform: windows

integration_test_multi_python_versions_ubuntu_workspace:
Expand Down
4 changes: 4 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ examples/pip_parse_vendored/bazel-pip_parse_vendored
examples/pip_repository_annotations/bazel-pip_repository_annotations
examples/py_proto_library/bazel-py_proto_library
gazelle/bazel-gazelle
gazelle/examples/bzlmod_build_file_generation/bazel-bin
gazelle/examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
gazelle/examples/bzlmod_build_file_generation/bazel-out
gazelle/examples/bzlmod_build_file_generation/bazel-testlog
Comment on lines +29 to +32
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The newly added gazelle/.bazelignore file already handles ignoring these Bazel-generated directories within the gazelle/examples/bzlmod_build_file_generation path. These entries in the root .bazelignore are therefore redundant and can be removed to avoid duplication and simplify maintenance.

tests/integration/compile_pip_requirements/bazel-compile_pip_requirements
tests/integration/ignore_root_user_error/bazel-ignore_root_user_error
tests/integration/local_toolchains/bazel-local_toolchains
Expand Down
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ query --deleted_packages=examples/build_file_generation,examples/build_file_gene

test --test_output=errors

common --deleted_packages=gazelle/examples/bzlmod_build_file_generation
common --deleted_packages=gazelle/examples/bzlmod_build_file_generation/runfiles
Comment on lines +12 to +13
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and consistency with other parts of this file (like the query --deleted_packages on line 9), you can combine these two deleted_packages flags into a single line with comma-separated paths.

common --deleted_packages=gazelle/examples/bzlmod_build_file_generation,gazelle/examples/bzlmod_build_file_generation/runfiles


# Do NOT implicitly create empty __init__.py files in the runfiles tree.
# By default, these are created in every directory containing Python source code
# or shared libraries, and every parent directory of those directories,
Expand Down
4 changes: 3 additions & 1 deletion .bcr/gazelle/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

bcr_test_module:
module_path: "../examples/bzlmod_build_file_generation"
module_path: "examples/bzlmod_build_file_generation"
matrix:
platform: ["debian11", "macos", "ubuntu2004", "windows"]
# last_rc is to get latest 8.x release. Replace with 8.x when available.
Expand All @@ -23,6 +23,8 @@ bcr_test_module:
name: "Run test module"
platform: ${{ platform }}
bazel: ${{ bazel }}
shell_commands:
- "echo 'common --override_module=rules_python=' >> .bazelrc"
build_targets:
- "//..."
- ":modules_map"
Expand Down
32 changes: 25 additions & 7 deletions .github/workflows/create_archive_and_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit -o nounset -o pipefail
set -o nounset
set -o pipefail
set -o errexit

set -x

TAG=$1
if [ -z "$TAG" ]; then
echo "ERROR: TAG env var must be set"
exit 1
fi
# If the workflow checks out one commit, but is releasing another
git fetch origin tag "$TAG"
# Update our local state so the grep command below searches what we expect
git checkout "$TAG"

# Exclude dot directories, specifically, this file so that we don't
# find the substring we're looking for in our own file.
# Exclude CONTRIBUTING.md, RELEASING.md because they document how to use these strings.
if grep --exclude=CONTRIBUTING.md --exclude=RELEASING.md --exclude-dir=.* VERSION_NEXT_ -r; then
grep --exclude=CONTRIBUTING.md \
--exclude=RELEASING.md \
--exclude=release.py \
--exclude=release_test.py \
--exclude-dir=.* \
VERSION_NEXT_ -r || grep_exit_code=$?

if [[ $grep_exit_code -eq 0 ]]; then
echo
echo "Found VERSION_NEXT markers indicating version needs to be specified"
exit 1
fi

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# A prefix is added to better match the GitHub generated archives.
PREFIX="rules_python-${TAG}"
ARCHIVE="rules_python-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
git archive --format=tar "--prefix=${PREFIX}/" "$TAG" | gzip > "$ARCHIVE"
SHA=$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')

cat > release_notes.txt << EOF

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Publish new releases to Bazel Central Registry.
name: Publish to BCR
on:
# Run the publish workflow after a successful release
# Will be triggered from the release.yaml workflow
workflow_call:
inputs:
tag_name:
required: true
type: string
secrets:
publish_token:
required: true
# In case of problems, let release engineers retry by manually dispatching
# the workflow from the GitHub UI
workflow_dispatch:
inputs:
tag_name:
description: git tag being released
required: true
type: string
jobs:
publish:
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
with:
tag_name: ${{ inputs.tag_name }}
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
registry_fork: bazel-contrib/bazel-central-registry
attest: false
permissions:
contents: write
secrets:
# Necessary to push to the BCR fork, and to open a pull request against a registry
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}
49 changes: 37 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,60 @@ on:
- "*.*.*"
workflow_dispatch:
inputs:
tag_name:
description: "release tag: tag that will be released"
required: true
type: string
publish_to_pypi:
description: 'Publish to PyPI'
required: true
type: boolean
default: true
secrets:
publish_token:
required: false

jobs:
build:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ github.ref_name }}
- name: Create release archive and notes
run: .github/workflows/create_archive_and_notes.sh
- name: Publish wheel dist
if: github.event_name == 'push' || github.event.inputs.publish_to_pypi
env:
# This special value tells pypi that the user identity is supplied within the token
TWINE_USERNAME: __token__
# Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on
# https://github.com/bazel-contrib/rules_python/settings/secrets/actions
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: bazel run --stamp --embed_label=${{ github.ref_name }} //python/runfiles:wheel.publish
run: .github/workflows/create_archive_and_notes.sh ${{ inputs.tag_name || github.ref_name }}
- name: Release
uses: softprops/action-gh-release@v2
with:
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
prerelease: ${{ contains(github.ref, '-rc') }}
prerelease: ${{ contains( (inputs.tag_name || github.ref), '-rc') }}
fail_on_unmatched_files: true
files: rules_python-*.tar.gz
tag_name: ${{ inputs.tag_name || github.ref_name }}

publish_bcr:
needs: release
uses: ./.github/workflows/publish.yml
with:
tag_name: ${{ inputs.tag_name || github.ref_name }}
secrets:
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}

publish_pypi:
# We just want publish_pypi last, since once uploaded, it can't be changed.
name: Publish runfiles to PyPI
needs: publish_bcr
runs-on: ubuntu-latest
steps:
- if: github.event_name == 'push' || github.event.inputs.publish_to_pypi
env:
# This special value tells pypi that the user identity is supplied within the token
TWINE_USERNAME: __token__
# Note, the PYPI_API_TOKEN is for the rules-python pypi user, added by @rickylev on
# https://github.com/bazel-contrib/rules_python/settings/secrets/actions
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: bazel run --stamp --embed_label=${{ inputs.tag_name || github.ref_name }} //python/runfiles:wheel.publish
10 changes: 5 additions & 5 deletions docs/api/rules_python/python/config_settings/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Values:

This flag replaces the Bazel builtin `--build_python_zip` flag.

:::{versionadded} VERSION_NEXT_FEATURE
:::{versionadded} 1.7.0
:::
::::

Expand All @@ -62,7 +62,7 @@ Values;
This flag replaces the Bazel builtin
`--experimental_python_import_all_repositories` flag.

:::{versionadded} VERSION_NEXT_FEATURE
:::{versionadded} 1.7.0
:::
::::

Expand All @@ -75,11 +75,11 @@ be removed.

This flag replaces the Bazel builtin `--python_path` flag.

:::{deprecated} VERSION_NEXT_FEATURE
:::{deprecated} 1.7.0
Use toolchains instead.
:::

:::{versionadded} VERSION_NEXT_FEATURE
:::{versionadded} 1.7.0
:::
::::

Expand Down Expand Up @@ -111,7 +111,7 @@ Values:
This flag replaces the Bazel builtin
`--incompatible_default_to_explicit_init_py` flag.

:::{versionadded} VERSION_NEXT_FEATURE
:::{versionadded} 1.7.0
:::
::::

Expand Down

This file was deleted.

8 changes: 8 additions & 0 deletions gazelle/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bazel-bin
bazel-gazelle
bazel-out
bazel-testlogs
examples/bzlmod_build_file_generation/bazel-bin
examples/bzlmod_build_file_generation/bazel-bzlmod_build_file_generation
examples/bzlmod_build_file_generation/bazel-out
examples/bzlmod_build_file_generation/bazel-testlog
3 changes: 3 additions & 0 deletions gazelle/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
common --deleted_packages=examples/bzlmod_build_file_generation
common --deleted_packages=examples/bzlmod_build_file_generation/runfiles

test --test_output=errors

# Do NOT implicitly create empty __init__.py files in the runfiles tree.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,28 @@ module(
# For typical setups you set the version.
# See the releases page for available versions.
# https://github.com/bazel-contrib/rules_python/releases
bazel_dep(name = "rules_python", version = "0.0.0")
bazel_dep(name = "rules_python", version = "1.0.0")

# NOTE: This override is removed for BCR presubmits and the version
# specified by bazel_dep() is used instead.
# The following loads rules_python from the file system.
# For usual setups you should remove this local_path_override block.
local_path_override(
module_name = "rules_python",
path = "../..",
path = "../../..",
)

# The following stanza defines the dependency rules_python_gazelle_plugin.
# For typical setups you set the version.
# See the releases page for available versions.
# https://github.com/bazel-contrib/rules_python/releases
bazel_dep(name = "rules_python_gazelle_plugin", version = "0.0.0")
bazel_dep(name = "rules_python_gazelle_plugin", version = "1.5.0")

# The following starlark loads the gazelle plugin from the file system.
# For usual setups you should remove this local_path_override block.
local_path_override(
module_name = "rules_python_gazelle_plugin",
path = "../../gazelle",
path = "../..",
)

# The following stanza defines the dependency for gazelle
Expand Down Expand Up @@ -84,7 +86,7 @@ use_repo(pip, "pip")

# This project includes a different module that is on the local file system.
# Add the module to this parent project.
bazel_dep(name = "other_module", version = "", repo_name = "our_other_module")
bazel_dep(name = "other_module", version = "0.0.0", repo_name = "our_other_module")
local_path_override(
module_name = "other_module",
path = "other_module",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module(
name = "other_module",
)

# Version doesn't matter because the root module overrides it,
# but Bazel requires it exist in the registry.
bazel_dep(name = "rules_python", version = "1.0.0")
Loading