Skip to content

Fix for Bazel upcoming change incompatible_string_join_requires_strings#2059

Merged
jayconrod merged 1 commit intobazel-contrib:masterfrom
laurentlb:master
May 14, 2019
Merged

Fix for Bazel upcoming change incompatible_string_join_requires_strings#2059
jayconrod merged 1 commit intobazel-contrib:masterfrom
laurentlb:master

Conversation

@laurentlb
Copy link
Copy Markdown
Contributor

The arguments of string.join should be strings. In the future,
Bazel won't perform this implicit conversion.

The arguments of string.join should be strings. In the future,
Bazel won't perform this implicit conversion.
@jayconrod jayconrod merged commit 94a536c into bazel-contrib:master May 14, 2019
jayconrod pushed a commit that referenced this pull request May 15, 2019
…gs (#2059)

The arguments of string.join should be strings. In the future,
Bazel won't perform this implicit conversion.
jayconrod pushed a commit that referenced this pull request May 15, 2019
…gs (#2059)

The arguments of string.join should be strings. In the future,
Bazel won't perform this implicit conversion.
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
Before this PR the `uv` toolchain could not be used in a `genrule` it
seems because the `//python/uv:toolchain` does not have the necessary
providers for using the make variables and the re-exporting of the make
variables from the `toolchain` in the `current_toolchain` rule did not
seem to work.

This PR removes the provider construction in the `toolchain` and does
that only in the `current_toolchain`. This better mirrors how the Python
toolchains are setup (grepping `PYTHON3` is sufficient to get examples).
This also splits out work done in bazel-contrib#2059 to decrease its scope, so that
this can be discussed separately.

Work towards bazel-contrib#1975
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>
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