Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump internal_deps #1322

Merged
merged 10 commits into from
Sep 28, 2023
Merged

Conversation

aignas
Copy link
Collaborator

@aignas aignas commented Jul 16, 2023

Before this PR the dependencies were out of date and the pyproject_hooks was
missing allowing pip-compile to use pyproject.toml instead of
requirements.in. With the update we are more likely to support the new
features but they are not tested in this PR as the main goal is to update all of
the files that need regenerating due to upgraded pip-tools.

Here we:

  • Upgrade all of the deps to the latest versions.
  • Update all of the requirements and gazelle manifest files.
  • Add a quirk to ensure fix pip_compile on Windows.

Summary of version changes:

  • build: 0.9.0 -> 0.10.0
  • click: 8.0.1 -> 8.1.6
  • importlib_metadata: 1.4.0 -> 6.8.0
  • more_itertools: 8.13.0 -> 10.1.0
  • packaging: 22.0 -> 23.1
  • pip: 22.3.1 -> 23.2.1
  • pip_tools: 6.12.1 -> 7.2.0
  • pyproject_hooks: 1.0.0
  • setuptools: 60.10.0 -> 68.0.0
  • wheel: 0.38.4 -> 0.41.0
  • zipp: 1.0.0 -> 3.16.2

Fixes #1351

@aignas aignas force-pushed the chore/upgrade-internal-deps-2 branch 2 times, most recently from 53560a7 to 4eeb8bb Compare August 4, 2023 03:14
@aignas aignas marked this pull request as ready for review August 4, 2023 04:55
@aignas
Copy link
Collaborator Author

aignas commented Aug 4, 2023

This is still failing on Windows, but I am not entirely sure why, maybe someone with Windows could look deeper in to this.

@rickeylev
Copy link
Contributor

The windows error is:

      File "C:\temp\Bazel.runfiles_nst1tke9\runfiles\python39_x86_64-pc-windows-msvc\lib\pathlib.py", line 276, in gethomedir
        raise RuntimeError("Can't determine home directory")
    RuntimeError: Can't determine home directory

It's originating via pip -> setuptools -> pathlib. As part of, what appears to be, looking for configuration files. Perhaps there's an issue filed upstream? Is this setuptools version compatible with Python 3.9?

Looking at the Python 3.9 pathlib code, it checks for USERPROFILE in the environment, which is set. Maybe that isn't filtering down to the the action? Adding --test_env=USERPROFILE in the CI config might fix that.

@chrislovecnm
Copy link
Collaborator

It's originating via pip -> setuptools -> pathlib. As part of, what appears to be, looking for configuration files. Perhaps there's an issue filed upstream? Is this setuptools version compatible with Python 3.9?

I'm not finding an issue upstream in setuptools. And I cannot find a compatibility matrix.

@chrislovecnm
Copy link
Collaborator

chrislovecnm commented Aug 7, 2023

So adding the parameter --no-user-cfg will bypass the code causing this problem. See the parameter here:

https://github.com/pypa/setuptools/blob/1d9420746741c6ad8bc0757b5dcf6cadf3c1444d/setuptools/_distutils/dist.py#L279

Set the parameter and setuptools does not hit the pathlib call here:

https://github.com/pypa/setuptools/blob/1d9420746741c6ad8bc0757b5dcf6cadf3c1444d/setuptools/_distutils/dist.py#L354C60-L354C60

I don't think we want to pick up user configuration anyways.

There are long discussions around '~,' and Windows python/cpython#80445 is one of them.

setuptools moved from using os.path.expanduser('~') a while ago, and there are inconsistencies between the two implementations in Python that I have read about. See the setuptools commit here:

pypa/setuptools@c7d65dd#diff-1da6455033333a4ccf962e1f9f770e138d83c5775c11f72e16ebef1688026284L353-L355

So I am guessing that the older os.path implementation worked while the never implementation of using pathlib does not.

As I mentioned, if we set the --no-user-cfg parameter for setup tools, the setuptools code will not use the pathlib call, and setup tools won't try to find user configuration outside the sandbox.

@aignas
Copy link
Collaborator Author

aignas commented Aug 24, 2023

I spent some time debugging this and trying to understand the root cause of what is going on and I am not sure that the previous analysis in the comment above is entirely correct.

Looking at this log, I think what is happening is the following:

  1. The pip-tools is trying to lock the requirements.
  2. Then it is calling pip internal to fully resolve everything.
  3. Then pip needs to do some processing of the package and it is calling the vendored pyproject-hooks which exists within the pip/_vendor folder.
  4. ...
  5. It calls a subprocess.run which due to some reason has it's sys.path include Python files from outside the runfiles directory:
    C:\temp\Bazel.runfiles_n6t3rqoq\runfiles\pypi__pip\pip\_vendor\pyproject_hooks\_in_process
    C:\temp\pip-build-env-gejvde8f\site
    C:\temp\Bazel.runfiles_n6t3rqoq\runfiles\python39_x86_64-pc-windows-msvc\python39.zip
    C:\temp\Bazel.runfiles_n6t3rqoq\runfiles\python39_x86_64-pc-windows-msvc\DLLs
    C:\temp\Bazel.runfiles_n6t3rqoq\runfiles\python39_x86_64-pc-windows-msvc\lib
    C:\temp\pip-build-env-gejvde8f\overlay\Lib\site-packages
    C:\temp\pip-build-env-gejvde8f\normal\Lib\site-packages
    
  6. We fail whilst we are trying to build a wheel? This is where I get confused,
    as locking down the requirements should not need to build them, but given
    Python packaging complexity and non-hermeticity I would not be surprised if
    this is the actual behaviour that we have here.

I still think it would be good to get to the root cause of this and have the
full picture why multi_versions, pip_install and pip_parse integration
tests. multi_versions example is also only failing with Python 3.11,
whereas other examples are using 3.9. What is more, multi_versions
requirements contain only websockets and I am curious why it would work with
one Python version but not others. The same goes for why it would work on Linux
but not on Windows.

@groodt
Copy link
Collaborator

groodt commented Sep 11, 2023

6. We fail whilst we are trying to build a wheel? This is where I get confused,
as locking down the requirements should not need to build them, but given
Python packaging complexity and non-hermeticity I would not be surprised if
this is the actual behaviour that we have here.

Oh, yes, this is precisely what happens when locking dependencies. This happens automatically when an sdist is encountered, because there is no static metadata for sdists. So a wheel is built from the sdist. If I had my way, the rules would only support wheels (--only-binary=:all:), but I think that ship sailed long ago.

The test is failing on yamllint which is only provided as an sdist (https://pypi.org/project/yamllint/#files). Why does the test require yamllint? Can't we do something else instead?

I personally think this might be too aggressive an upgrade? What's the motivation to upgrade everything at once? If we're upgrading the tooling dependencies, such as pip-tools and build, I can get behind that.

In general, upgrading setuptools needs to be done carefully, because we probably want the oldest version of setuptools thats compatible with pip and the rest of our tools? If we upgrade setuptools too aggressively, we risk breaking the ability to build older packages? From my quick skim of the upgrade, I don't see anything obvious, but setuptools is a load-bearing, so unless there's a strong reason to upgrade it, maybe upgrade it independently?

@aignas aignas force-pushed the chore/upgrade-internal-deps-2 branch from 0daae99 to 565f096 Compare September 12, 2023 00:59
@groodt
Copy link
Collaborator

groodt commented Sep 27, 2023

I think the failure on Windows now, is due to the newer setuptools vendored distutils that is attempting to expand a home directory when building an sdist for websocket on py311 for the old version of websocket.

I can bump the pinned version of websocket so that an sdist will not be but I think this will likely break rules_python for windows users who have any sdist that make use of distutils?

@f0rmiga f0rmiga added this pull request to the merge queue Sep 28, 2023
Merged via the queue into bazelbuild:main with commit 9a8c447 Sep 28, 2023
1 check passed
renovate bot referenced this pull request in bazel-contrib/rules_bazel_integration_test Oct 6, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rules_python](https://togithub.com/bazelbuild/rules_python) |
http_archive | minor | `0.25.0` -> `0.26.0` |

---

### Release Notes

<details>
<summary>bazelbuild/rules_python (rules_python)</summary>

###
[`v0.26.0`](https://togithub.com/bazelbuild/rules_python/releases/tag/0.26.0)

[Compare
Source](https://togithub.com/bazelbuild/rules_python/compare/0.25.0...0.26.0)

#### Using Bzlmod with Bazel 6

**NOTE: bzlmod support is still beta. APIs subject to change.**

Add to your `MODULE.bazel` file:

```starlark
bazel_dep(name = "rules_python", version = "0.26.0")

pip = use_extension("@&#8203;rules_python//python/extensions:pip.bzl", "pip")

pip.parse(
    name = "pip",
    requirements_lock = "//:requirements_lock.txt",
)

use_repo(pip, "pip")
```

#### Using WORKSPACE

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_python",
    sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
    strip_prefix = "rules_python-0.26.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)

load("@&#8203;rules_python//python:repositories.bzl", "py_repositories")

py_repositories()
```

##### Gazelle plugin

Paste this snippet into your `WORKSPACE` file:

```starlark
load("@&#8203;bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_python_gazelle_plugin",
    sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
    strip_prefix = "rules_python-0.26.0/gazelle",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)

### To compile the rules_python gazelle extension from source,
### we must fetch some third-party go dependencies that it uses.

load("@&#8203;rules_python_gazelle_plugin//:deps.bzl", _py_gazelle_deps = "gazelle_deps")

_py_gazelle_deps()
```

#### What's Changed

- doc: Note Python version changes in CHANGELOG by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1391](https://togithub.com/bazelbuild/rules_python/pull/1391)
- fix: bcr releaser email by
[@&#8203;f0rmiga](https://togithub.com/f0rmiga) in
[https://github.com/bazelbuild/rules_python/pull/1392](https://togithub.com/bazelbuild/rules_python/pull/1392)
- Adding kwargs to gazelle_python_manifest by
[@&#8203;linzhp](https://togithub.com/linzhp) in
[https://github.com/bazelbuild/rules_python/pull/1289](https://togithub.com/bazelbuild/rules_python/pull/1289)
- docs: Use correct link to build badge image and build status page. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1390](https://togithub.com/bazelbuild/rules_python/pull/1390)
- feat(py_console_script_binary)!: entry points with custom dependencies
by [@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1363](https://togithub.com/bazelbuild/rules_python/pull/1363)
- fix(whl_library): avoid unnecessary repository rule restarts by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1400](https://togithub.com/bazelbuild/rules_python/pull/1400)
- refactor: add missing `//python/config_settings/private:distribution`
target by [@&#8203;philsc](https://togithub.com/philsc) in
[https://github.com/bazelbuild/rules_python/pull/1402](https://togithub.com/bazelbuild/rules_python/pull/1402)
- Import pycross_wheel_library by
[@&#8203;philsc](https://togithub.com/philsc) in
[https://github.com/bazelbuild/rules_python/pull/1403](https://togithub.com/bazelbuild/rules_python/pull/1403)
- refactor: upgrade certifi by
[@&#8203;cflewis](https://togithub.com/cflewis) in
[https://github.com/bazelbuild/rules_python/pull/1397](https://togithub.com/bazelbuild/rules_python/pull/1397)
- fix: don't set distribs in version transitioning rule by
[@&#8203;comius](https://togithub.com/comius) in
[https://github.com/bazelbuild/rules_python/pull/1412](https://togithub.com/bazelbuild/rules_python/pull/1412)
- fix(gazelle): upgrade rules_go: 0.39.1 -> 0.41.0 to work with upcoming
Bazel versions by [@&#8203;sgowroji](https://togithub.com/sgowroji) in
[https://github.com/bazelbuild/rules_python/pull/1410](https://togithub.com/bazelbuild/rules_python/pull/1410)
- fix: gazelle: Fix non-hermetic runfiles lookup by
[@&#8203;fmeum](https://togithub.com/fmeum) in
[https://github.com/bazelbuild/rules_python/pull/1415](https://togithub.com/bazelbuild/rules_python/pull/1415)
- feat: create toolchain type for py_proto_library by
[@&#8203;comius](https://togithub.com/comius) in
[https://github.com/bazelbuild/rules_python/pull/1416](https://togithub.com/bazelbuild/rules_python/pull/1416)
- internal: copy Starlark rule implementation from Bazel by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1418](https://togithub.com/bazelbuild/rules_python/pull/1418)
- feat: add new Python toolchain versions by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1414](https://togithub.com/bazelbuild/rules_python/pull/1414)
- internal(pystar): make starlark impl (mostly) loadable by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1422](https://togithub.com/bazelbuild/rules_python/pull/1422)
- feat: generate py_library per file by
[@&#8203;raylu](https://togithub.com/raylu) in
[https://github.com/bazelbuild/rules_python/pull/1398](https://togithub.com/bazelbuild/rules_python/pull/1398)
- chore: bump default python versions by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1425](https://togithub.com/bazelbuild/rules_python/pull/1425)
- feat: Support netrc-based authentication for python_repository rule by
[@&#8203;LINKIWI](https://togithub.com/LINKIWI) in
[https://github.com/bazelbuild/rules_python/pull/1417](https://togithub.com/bazelbuild/rules_python/pull/1417)
- refactor(pystar): load (but don't use) Starlark implementation. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1428](https://togithub.com/bazelbuild/rules_python/pull/1428)
- fix(gazelle): runfiles discovery by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1429](https://togithub.com/bazelbuild/rules_python/pull/1429)
- feat, refactor(pystar): bzl_library for packaging.bzl; fix pystar doc
building and py_wheel by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1432](https://togithub.com/bazelbuild/rules_python/pull/1432)
- refactor(toolchain): use a helper method to convert an X.Y version to
X.Y.Z by [@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1423](https://togithub.com/bazelbuild/rules_python/pull/1423)
- pycross: Rename `pycross_wheel_library` and make it work by
[@&#8203;philsc](https://togithub.com/philsc) in
[https://github.com/bazelbuild/rules_python/pull/1413](https://togithub.com/bazelbuild/rules_python/pull/1413)
- fix: Skip printing unneccesary warning. by
[@&#8203;matts1](https://togithub.com/matts1) in
[https://github.com/bazelbuild/rules_python/pull/1407](https://togithub.com/bazelbuild/rules_python/pull/1407)
- refactor(bzlmod)!: simplify pip.parse repository layout by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1395](https://togithub.com/bazelbuild/rules_python/pull/1395)
- feat(bzlmod): mark pip extension as os/arch dependent by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1433](https://togithub.com/bazelbuild/rules_python/pull/1433)
- chore: bump internal_deps by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1322](https://togithub.com/bazelbuild/rules_python/pull/1322)
- tests(pystar): CI configs that uses Starlark implementation of rules
by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1435](https://togithub.com/bazelbuild/rules_python/pull/1435)
- internal(pystar): Copy @&#8203;bazel_tools//tools/python files to
rules_python by [@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1437](https://togithub.com/bazelbuild/rules_python/pull/1437)
- internal(pystar): Make py_runtime_pair and autodetecting toolchain
mostly loadable. by [@&#8203;rickeylev](https://togithub.com/rickeylev)
in
[https://github.com/bazelbuild/rules_python/pull/1439](https://togithub.com/bazelbuild/rules_python/pull/1439)
- tests: Move base rule tests under tests instead of
//tools/build_defs/python by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1440](https://togithub.com/bazelbuild/rules_python/pull/1440)
- tests(pystar): py_runtime_pair and py_runtime analysis tests by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1441](https://togithub.com/bazelbuild/rules_python/pull/1441)
- fix(pystar): Use py_internal for runfiles_enabled,
declare_shareable_artifact, share_native_deps by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1443](https://togithub.com/bazelbuild/rules_python/pull/1443)
- build(deps): bump urllib3 from 1.26.13 to 1.26.17 in
/examples/pip_repository_annotations by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/bazelbuild/rules_python/pull/1447](https://togithub.com/bazelbuild/rules_python/pull/1447)
- build(deps): bump urllib3 from 1.25.11 to 1.26.17 in
/examples/pip_install by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/bazelbuild/rules_python/pull/1444](https://togithub.com/bazelbuild/rules_python/pull/1444)
- fix: add missing `@bazel_tools` files to bzl_library dependencies. by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1457](https://togithub.com/bazelbuild/rules_python/pull/1457)
- tests(pystar): add analysis tests to cover basic windows building by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1452](https://togithub.com/bazelbuild/rules_python/pull/1452)
- docs: move dependency management into respective bzl packages by
[@&#8203;rickeylev](https://togithub.com/rickeylev) in
[https://github.com/bazelbuild/rules_python/pull/1459](https://togithub.com/bazelbuild/rules_python/pull/1459)
- feat(py_wheel): Normalize name and version by
[@&#8203;vonschultz](https://togithub.com/vonschultz) in
[https://github.com/bazelbuild/rules_python/pull/1331](https://togithub.com/bazelbuild/rules_python/pull/1331)
- chore: add new Python toolchains from indygreg by
[@&#8203;aignas](https://togithub.com/aignas) in
[https://github.com/bazelbuild/rules_python/pull/1461](https://togithub.com/bazelbuild/rules_python/pull/1461)

#### New Contributors

- [@&#8203;cflewis](https://togithub.com/cflewis) made their first
contribution in
[https://github.com/bazelbuild/rules_python/pull/1397](https://togithub.com/bazelbuild/rules_python/pull/1397)
- [@&#8203;sgowroji](https://togithub.com/sgowroji) made their first
contribution in
[https://github.com/bazelbuild/rules_python/pull/1410](https://togithub.com/bazelbuild/rules_python/pull/1410)
- [@&#8203;raylu](https://togithub.com/raylu) made their first
contribution in
[https://github.com/bazelbuild/rules_python/pull/1398](https://togithub.com/bazelbuild/rules_python/pull/1398)
- [@&#8203;LINKIWI](https://togithub.com/LINKIWI) made their first
contribution in
[https://github.com/bazelbuild/rules_python/pull/1417](https://togithub.com/bazelbuild/rules_python/pull/1417)

**Full Changelog**:
bazelbuild/rules_python@0.25.0...0.26.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/bazel-contrib/rules_bazel_integration_test).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjMiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjMiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@aignas aignas deleted the chore/upgrade-internal-deps-2 branch May 13, 2024 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shipped version of importlib_metadata incompatible with pip_tools
5 participants