Skip to content

WIP: Update vendored Skylib to 0.8.0 with some edits#2081

Closed
laszlocsomor wants to merge 1 commit intobazel-contrib:masterfrom
laszlocsomor:update-skylib-0.8.0
Closed

WIP: Update vendored Skylib to 0.8.0 with some edits#2081
laszlocsomor wants to merge 1 commit intobazel-contrib:masterfrom
laszlocsomor:update-skylib-0.8.0

Conversation

@laszlocsomor
Copy link
Copy Markdown
Contributor

@laszlocsomor laszlocsomor commented May 29, 2019

Motivation: lib/unittest.bzl now works with Bazel's
native test wrapper on Windows, which will replace
the current Bash-script-based test wrapper.

The "some edits" are described in
"go/private/skylib/README.rst".

See bazelbuild/bazel#6622

Motivation: lib/unittest.bzl works with Bazel's
native test wrapper on Windows, which will replace
the current Bash-script-based test wrapper.

The "some edits" in the header refer to:
- rewriting labels in `load()` statements
- omitting 'tests' and 'docs' directories from
  Skylib 0.8.0

See bazelbuild/bazel#6622
@laszlocsomor
Copy link
Copy Markdown
Contributor Author

I believe the tests failed because the Bazel version is too old for Skylib 0.8.0
I try a different approach: #2082

yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…ntrib#2201)

This value has been hardcoded for a long time, so let's add the
`patch_strip`
attribute to the `WORKSPACE` setups now so that we add less tech debt in
the
`bzlmod` world later and need to migrate `bzlmod` users from the hard
coded
value to something that can be configured.

This should be backwards compatible because of the default `int` value
of `1`
for the `patch_strip` attribute.

Summary:
- feat: add `patch_strip` to `python_repository`.
- feat: add the default value of patch_strip to get_release_info.
- refactor: handle patch_strip key in `TOOL_VERSIONS`.

Work towards bazel-contrib#2081.

---------

Co-authored-by: Richard Levasseur <richardlev@gmail.com>
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
With this PR we get rudimentary unit tests for the `python` bzlmod
extension
which allows us to unit test the override behaviour that will become
more
complex soon.

Summary:
- refactor: inline the python_register_toolchains
- refactor: use toolchain_info to call python_register_toolchains
- refactor: move the registration out of the main loop
- refactor: split the parsing of the modules to a separate function
- test(bzlmod): add python.toolchain module parsing tests

Work towards bazel-contrib#2081

---------

Co-authored-by: Richard Levasseur <richardlev@gmail.com>
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
… in full_version (bazel-contrib#2219)

This PR just makes the `MINOR_MAPPING` overridable and explicit in
many macros/rules that we own. Even though technically new API is
exposed, I am not sure if it is possible to use it and I am not sure
if we should advertise it.

Explicit minor_mapping results in easier wiring of `python.override`
`bzlmod` extension tag class planned for bazel-contrib#2081.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…rib#2218)

This `semver` function may turn out to be useful in validating
the input for the `python.*override` tag classes to be added in
a followup PR. Because this is a refactor of an existing code and
adding tests, I decided to split it out.

For a POC see bazel-contrib#2151, work towards bazel-contrib#2081.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…-contrib#2217)

This is a different take on bazel-contrib#2205.

Summary:
- Remove version constraints from the
`//python/config_settings:python_version`.
- Remove `is_python_config_setting` macro and use a different
implementation to
  retain the same functionality.

This in general will improve the situation on how the toolchains are
registered
and hopefully is a step towards resolving issues for bazel-contrib#2081.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…separate files (bazel-contrib#2232)

This makes the dependency management in WORKSPACE much easier to do.

Summary:
- refactor: split out the py_repositories call to a separate file
- refactor: split out the python_repository rule to a separate file
- refactor: split out the standalone interpreter utility function
- refactor: split out the python_register_toolchains function
- refactor: rename the remaining file

Work towards bazel-contrib#2081.
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
Before this PR the users could not override how the hermetic toolchain
is downloaded when in `bzlmod`. However, the same APIs would be
available to users using `WORKSPACE`. With this we also allow root
modules to restrict which toolchain versions the non-root modules, which
may be helpful when optimizing the CI runtimes so that we don't waste
time downloading multiple `micro` versions of the same `3.X` python
version, which most of the times have identical behavior.

Whilst at it, tweak the `semver` implementation to allow for testing of
absence of values in the original input.

Work towards bazel-contrib#2081 and this should be one of the last items that are
blocking bazel-contrib#1361 from the API point of view.

Replaces bazel-contrib#2151.

---------

Co-authored-by: Richard Levasseur <richardlev@gmail.com>
yushan26 pushed a commit to yushan26/rules_go that referenced this pull request Jun 16, 2025
…l-contrib#2253)

With this change we set the default value of `--python_version` when
the `python.toolchain` is used in `bzlmod` and we generate the
appropriate config settings based on the registered toolchains and
given overrides by the root module.

This means that we expect the `--python_version` to be always set to
a non-empty value under `bzlmod` and we can cleanup code which was
handling `//conditions:default` case. This also means that we can
in theory drop the requirement for `python_version` in `pip.parse`
and just setup dependencies for all packages that we find in the
`requirements.txt` file and move on. This is left as future work
by myself or anyone willing to contribute. We can also start reusing
the same `whl_library` instance for multi-platform packages because
the python version flag is always set - this will simplify the layout
and makes the feature non-experimental anymore under bzlmod.

Summary:
* Add `@pythons_hub` to the `WORKSPACE` with dummy data to make
  pythons_hub work.
* Add `MINOR_MAPPING` and `PYTHON_VERSIONS` to pythons_hub to
  generate the config settings.
* Remove handling of the default version in `pypi` code under bzlmod.

Work towards bazel-contrib#2081, bazel-contrib#260, bazel-contrib#1708

---------

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.

2 participants