Skip to content

Make all popular_repo external repositories safe #1105

Merged
ianthehat merged 1 commit intobazel-contrib:masterfrom
ianthehat:maybe_repo_test
Dec 6, 2017
Merged

Make all popular_repo external repositories safe #1105
ianthehat merged 1 commit intobazel-contrib:masterfrom
ianthehat:maybe_repo_test

Conversation

@ianthehat
Copy link
Copy Markdown
Contributor

against pre-existing rules

@ianthehat ianthehat merged commit 4394550 into bazel-contrib:master Dec 6, 2017
@ianthehat ianthehat deleted the maybe_repo_test branch December 6, 2017 00:29
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…around (bazel-contrib#2069)

This is extra preparation needed for bazel-contrib#2059.

Summary:
- Create `pypi_repo_utils` for more ergonomic handling of Python in repo
context.
- Split the resolution of requirements files to platforms into a
separate function
to make the testing easier. This also allows more validation that was
realized
  that there is a need for in the WIP feature PR.
- Make the code more robust about the assumption of the target platform
label.

Work towards bazel-contrib#260, bazel-contrib#1105, bazel-contrib#1868.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…azel-contrib#2068)

This is just a small PR to reduce the scope of bazel-contrib#2059.

This just moves some code from one python file to a separate one.

Work towards bazel-contrib#260, bazel-contrib#1105, bazel-contrib#1868.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…ontrib#2075)

This also changes the local_runtime_repo to explicitly check for
supported platforms instead of relying on a `None` value returned by the
helper method. This makes the behaviour exactly the same to the
behaviour before this PR and we can potentially drop the need for the
validation in the future if our local_runtime detection is more robust.

This also makes the platform detectino in `pypi_repo_utils` not depend
on `uname` and only use the `repository_ctx`. Apparently the
`module_ctx.watch` throws an error if one attempts to watch files on the
system (this is left for `repository_rule` it seems and one can only do
`module_ctx.watch` on files within the current workspace. This was
surprising, but could have been worked around by just unifying code.

This splits out things from bazel-contrib#2059 and makes the code more succinct.

Work towards bazel-contrib#260, bazel-contrib#1105, bazel-contrib#1868.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…2059)

Before this change the `all_requirements` and related constants will
have
packages that need to be installed only on specific platforms and will
mean
that users relying on those constants (e.g. `gazelle`) will need to do
extra
work to exclude platform-specific packages. The package managers that
that
support outputting such files now include `uv` and `pdm`. This might be
also
useful in cases where we attempt to handle non-requirements lock files.

Note, that the best way to handle this would be to move all of the
requirements
parsing code to Python, but that may cause regressions as it is a much
bigger
change. This is only changing the code so that we are doing extra
processing
for the requirement lines that have env markers. The lines that have no
markers
will not see any change in the code execution paths and the python
interpreter
will not be downloaded.

We also use the `*_ctx.watch` API where available to correctly
re-evaluate the
markers if the `packaging` Python sources for this change.

Extra changes that are included in this PR:
- Extend the `repo_utils` to have a method for `arch` getting from the
`ctx`.
- Change the `local_runtime_repo` to perform the validation not relying
on the
  implementation detail of the `get_platforms_os_name`.
- Add `$(UV)` make variable for the `uv:current_toolchain` so that we
can
  generate the requirements for `sphinx` using `uv`.
- Swap the requirement generation using `genrule` and `uv` for `sphinx`
and co
so that we can test the `requirement` marker code. Note, the
`requirement`
  markers are not working well with the `requirement_cycles`.

Fixes bazel-contrib#1105.
Fixes bazel-contrib#1868.
Work towards bazel-contrib#260, bazel-contrib#1975.
Related bazel-contrib#1663.

---------

Co-authored-by: Richard Levasseur <rlevasseur@google.com>
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…thon (bazel-contrib#2135)

Before this PR the lockfile would become platform dependent when the
`requirements` file would have env markers. This was not caught because
we do not have MODULE.bazel.lock checked into the `rules_python`
repository because the CI is running against many versions and the lock
file is different, therefore we would not be able to run with
`bazel build --lockfile_mode=error`.

With this change we use the label to `BUILD.bazel` which is living next
to the `python` symlink and since the `BUILD.bazel` is the same on all
platforms, the lockfile will remain the same.

Summary
* refactor(uv): create a reusable macro for using uv for locking reqs.
* test(bzlmod): enable testing the MODULE.bazel.lock breakage across
platforms.
* test(bzlmod): use a universal requirements file for 3.9.
This breaks the CI, because the python interpreter file hash is added to
the lock file.
* fix(bzlmod): keep the lockfile platform independent when resolving
python


Fixes bazel-contrib#1105 and bazel-contrib#1868 for real this time.
Implements an additional helper for bazel-contrib#1975.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants