Skip to content

Replace deprecated distutils usage with sysconfig in CI scripts - #180241

Closed
zklaus wants to merge 10 commits into
gh/zklaus/47/basefrom
gh/zklaus/47/head
Closed

zklaus wants to merge 10 commits into
gh/zklaus/47/basefrom
gh/zklaus/47/head

Conversation

@zklaus

@zklaus zklaus commented Apr 13, 2026 •

Copy link
Copy Markdown
Collaborator

[ghstack-poisoned]
@pytorch-bot pytorch-bot Bot added the release notes: releng release notes category label Apr 13, 2026
@pytorch-bot

pytorch-bot Bot commented Apr 13, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/180241

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 21 Cancelled Jobs

As of commit 9b2e1fc with merge base 11261ac (image):

NEW FAILURE - The following job has failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

zklaus added a commit to zklaus/pytorch that referenced this pull request Apr 13, 2026
Replace distutils.sysconfig.get_python_lib() with
sysconfig.get_path("purelib") in CI test scripts, and add a local
strtobool() to replace distutils.util.strtobool (removed in
Python 3.12).

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: ec4e6b1
Pull-Request: pytorch#180241
@zklaus
zklaus marked this pull request as ready for review April 14, 2026 18:31
@zklaus
zklaus requested a review from a team as a code owner April 14, 2026 18:31
@zklaus zklaus added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Apr 14, 2026
zklaus added a commit to zklaus/pytorch that referenced this pull request Apr 15, 2026
Replace distutils.sysconfig.get_python_lib() with
sysconfig.get_path("purelib") in CI test scripts, and add a local
strtobool() to replace distutils.util.strtobool (removed in
Python 3.12).

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: ec4e6b1
Pull-Request: pytorch#180241
zklaus added a commit to zklaus/pytorch that referenced this pull request Apr 17, 2026
Replace distutils.sysconfig.get_python_lib() with
sysconfig.get_path("purelib") in CI test scripts, and add a local
strtobool() to replace distutils.util.strtobool (removed in
Python 3.12).

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: ec4e6b1
Pull-Request: pytorch#180241
zklaus added 2 commits April 20, 2026 13:41
[ghstack-poisoned]
[ghstack-poisoned]
zklaus added 2 commits April 23, 2026 17:11
[ghstack-poisoned]
[ghstack-poisoned]
zklaus added 2 commits April 25, 2026 08:05
[ghstack-poisoned]
[ghstack-poisoned]
zklaus added a commit to zklaus/pytorch that referenced this pull request Apr 29, 2026
Replace distutils.sysconfig.get_python_lib() with
sysconfig.get_path("purelib") in CI test scripts, and add a local
strtobool() to replace distutils.util.strtobool (removed in
Python 3.12).

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: dad9c9d
Pull-Request: pytorch#180241
zklaus added 2 commits April 29, 2026 13:02
[ghstack-poisoned]
[ghstack-poisoned]
zklaus added a commit to zklaus/pytorch that referenced this pull request Apr 29, 2026
Replace distutils.sysconfig.get_python_lib() with
sysconfig.get_path("purelib") in CI test scripts, and add a local
strtobool() to replace distutils.util.strtobool (removed in
Python 3.12).

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: ec5c94b
Pull-Request: pytorch#180241

@atalman atalman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

[ghstack-poisoned]
zklaus added a commit to zklaus/pytorch that referenced this pull request May 1, 2026
Replace distutils.sysconfig.get_python_lib() with
sysconfig.get_path("purelib") in CI test scripts, and add a local
strtobool() to replace distutils.util.strtobool (removed in
Python 3.12).

Co-Generated with [Claude Code](https://claude.com/claude-code)


ghstack-source-id: 447112b
Pull-Request: pytorch#180241
@zklaus zklaus closed this May 1, 2026
pytorchmergebot pushed a commit that referenced this pull request May 10, 2026
## Summary

Replace deprecated `distutils` usage in CI scripts and tooling, in preparation
for Python 3.12+ (where `distutils` is removed). Two patterns are handled:

- `distutils.sysconfig.get_python_lib()` → `sysconfig.get_path("purelib")` in
  `.ci/pytorch/macos-test.sh`, `.ci/pytorch/test.sh`, and
  `.ci/pytorch/smoke_test/check_binary_symbols.py`.
- `distutils.util.strtobool` → a small local replacement in
  `tools/strtobool.py`, imported by `.github/scripts/generate_pytorch_version.py`,
  `tools/generate_torch_version.py`, and `tools/alerts/create_alerts.py`.

## Suggested review order

1. `tools/strtobool.py` — the consolidated helper, semantically identical to
   the removed `distutils.util.strtobool`.
2. The three Python call sites that import it. `.github/scripts/...` uses the
   same `sys.path` shim already established in
   `.github/scripts/close_nonexistent_disable_issues.py` for cross-importing
   from `tools/`.
3. The `sysconfig` substitutions in the shell scripts and
   `check_binary_symbols.py` — mechanical.

<details>
<summary>Out of scope (intentional)</summary>

- `tools/build_pytorch_libs.py` (`distutils._msvccompiler._get_vc_env`):
  deferred to a follow-up — the API is private and the replacement is not a
  one-liner.
- `tools/setup_helpers/cmake.py` (`from distutils.version import LooseVersion`)
  and `setup.py` (`setuptools.distutils.log.warn`): both files are deleted
  outright by the scikit-build-core migration (#180248); fixing them here
  would just create merge conflicts.
- `test/run_test.py:135`'s `strtobool`: deliberately permissive
  (`s.lower() not in {"", "0", "false", "off"}`) and never raises. Switching
  to the strict distutils-style helper would change behavior for callers
  passing non-canonical truthy values such as `TEST_SHOWLOCALS=yeah`.
- Other `str2bool` variants in `benchmarks/operator_benchmark/`,
  `torch/utils/hipify/`, and `.ci/lumen_cli/` do not use `distutils` and are
  not in this PR's scope.

</details>

Replaces #180241.

Authored with Claude.

Pull Request resolved: #182120
Approved by: https://github.com/atalman
dsashidh pushed a commit to dsashidh/pytorch that referenced this pull request May 13, 2026
## Summary

Replace deprecated `distutils` usage in CI scripts and tooling, in preparation
for Python 3.12+ (where `distutils` is removed). Two patterns are handled:

- `distutils.sysconfig.get_python_lib()` → `sysconfig.get_path("purelib")` in
  `.ci/pytorch/macos-test.sh`, `.ci/pytorch/test.sh`, and
  `.ci/pytorch/smoke_test/check_binary_symbols.py`.
- `distutils.util.strtobool` → a small local replacement in
  `tools/strtobool.py`, imported by `.github/scripts/generate_pytorch_version.py`,
  `tools/generate_torch_version.py`, and `tools/alerts/create_alerts.py`.

## Suggested review order

1. `tools/strtobool.py` — the consolidated helper, semantically identical to
   the removed `distutils.util.strtobool`.
2. The three Python call sites that import it. `.github/scripts/...` uses the
   same `sys.path` shim already established in
   `.github/scripts/close_nonexistent_disable_issues.py` for cross-importing
   from `tools/`.
3. The `sysconfig` substitutions in the shell scripts and
   `check_binary_symbols.py` — mechanical.

<details>
<summary>Out of scope (intentional)</summary>

- `tools/build_pytorch_libs.py` (`distutils._msvccompiler._get_vc_env`):
  deferred to a follow-up — the API is private and the replacement is not a
  one-liner.
- `tools/setup_helpers/cmake.py` (`from distutils.version import LooseVersion`)
  and `setup.py` (`setuptools.distutils.log.warn`): both files are deleted
  outright by the scikit-build-core migration (pytorch#180248); fixing them here
  would just create merge conflicts.
- `test/run_test.py:135`'s `strtobool`: deliberately permissive
  (`s.lower() not in {"", "0", "false", "off"}`) and never raises. Switching
  to the strict distutils-style helper would change behavior for callers
  passing non-canonical truthy values such as `TEST_SHOWLOCALS=yeah`.
- Other `str2bool` variants in `benchmarks/operator_benchmark/`,
  `torch/utils/hipify/`, and `.ci/lumen_cli/` do not use `distutils` and are
  not in this PR's scope.

</details>

Replaces pytorch#180241.

Authored with Claude.

Pull Request resolved: pytorch#182120
Approved by: https://github.com/atalman
Alokksinha00 pushed a commit to Alokksinha00/pytorch that referenced this pull request May 15, 2026
## Summary

Replace deprecated `distutils` usage in CI scripts and tooling, in preparation
for Python 3.12+ (where `distutils` is removed). Two patterns are handled:

- `distutils.sysconfig.get_python_lib()` → `sysconfig.get_path("purelib")` in
  `.ci/pytorch/macos-test.sh`, `.ci/pytorch/test.sh`, and
  `.ci/pytorch/smoke_test/check_binary_symbols.py`.
- `distutils.util.strtobool` → a small local replacement in
  `tools/strtobool.py`, imported by `.github/scripts/generate_pytorch_version.py`,
  `tools/generate_torch_version.py`, and `tools/alerts/create_alerts.py`.

## Suggested review order

1. `tools/strtobool.py` — the consolidated helper, semantically identical to
   the removed `distutils.util.strtobool`.
2. The three Python call sites that import it. `.github/scripts/...` uses the
   same `sys.path` shim already established in
   `.github/scripts/close_nonexistent_disable_issues.py` for cross-importing
   from `tools/`.
3. The `sysconfig` substitutions in the shell scripts and
   `check_binary_symbols.py` — mechanical.

<details>
<summary>Out of scope (intentional)</summary>

- `tools/build_pytorch_libs.py` (`distutils._msvccompiler._get_vc_env`):
  deferred to a follow-up — the API is private and the replacement is not a
  one-liner.
- `tools/setup_helpers/cmake.py` (`from distutils.version import LooseVersion`)
  and `setup.py` (`setuptools.distutils.log.warn`): both files are deleted
  outright by the scikit-build-core migration (pytorch#180248); fixing them here
  would just create merge conflicts.
- `test/run_test.py:135`'s `strtobool`: deliberately permissive
  (`s.lower() not in {"", "0", "false", "off"}`) and never raises. Switching
  to the strict distutils-style helper would change behavior for callers
  passing non-canonical truthy values such as `TEST_SHOWLOCALS=yeah`.
- Other `str2bool` variants in `benchmarks/operator_benchmark/`,
  `torch/utils/hipify/`, and `.ci/lumen_cli/` do not use `distutils` and are
  not in this PR's scope.

</details>

Replaces pytorch#180241.

Authored with Claude.

Pull Request resolved: pytorch#182120
Approved by: https://github.com/atalman
@github-actions
github-actions Bot deleted the gh/zklaus/47/head branch June 1, 2026 02:31
aperson30 pushed a commit to aperson30/pytorch that referenced this pull request Jun 20, 2026
## Summary

Replace deprecated `distutils` usage in CI scripts and tooling, in preparation
for Python 3.12+ (where `distutils` is removed). Two patterns are handled:

- `distutils.sysconfig.get_python_lib()` → `sysconfig.get_path("purelib")` in
  `.ci/pytorch/macos-test.sh`, `.ci/pytorch/test.sh`, and
  `.ci/pytorch/smoke_test/check_binary_symbols.py`.
- `distutils.util.strtobool` → a small local replacement in
  `tools/strtobool.py`, imported by `.github/scripts/generate_pytorch_version.py`,
  `tools/generate_torch_version.py`, and `tools/alerts/create_alerts.py`.

## Suggested review order

1. `tools/strtobool.py` — the consolidated helper, semantically identical to
   the removed `distutils.util.strtobool`.
2. The three Python call sites that import it. `.github/scripts/...` uses the
   same `sys.path` shim already established in
   `.github/scripts/close_nonexistent_disable_issues.py` for cross-importing
   from `tools/`.
3. The `sysconfig` substitutions in the shell scripts and
   `check_binary_symbols.py` — mechanical.

<details>
<summary>Out of scope (intentional)</summary>

- `tools/build_pytorch_libs.py` (`distutils._msvccompiler._get_vc_env`):
  deferred to a follow-up — the API is private and the replacement is not a
  one-liner.
- `tools/setup_helpers/cmake.py` (`from distutils.version import LooseVersion`)
  and `setup.py` (`setuptools.distutils.log.warn`): both files are deleted
  outright by the scikit-build-core migration (pytorch#180248); fixing them here
  would just create merge conflicts.
- `test/run_test.py:135`'s `strtobool`: deliberately permissive
  (`s.lower() not in {"", "0", "false", "off"}`) and never raises. Switching
  to the strict distutils-style helper would change behavior for callers
  passing non-canonical truthy values such as `TEST_SHOWLOCALS=yeah`.
- Other `str2bool` variants in `benchmarks/operator_benchmark/`,
  `torch/utils/hipify/`, and `.ci/lumen_cli/` do not use `distutils` and are
  not in this PR's scope.

</details>

Replaces pytorch#180241.

Authored with Claude.

Pull Request resolved: pytorch#182120
Approved by: https://github.com/atalman
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
## Summary

Replace deprecated `distutils` usage in CI scripts and tooling, in preparation
for Python 3.12+ (where `distutils` is removed). Two patterns are handled:

- `distutils.sysconfig.get_python_lib()` → `sysconfig.get_path("purelib")` in
  `.ci/pytorch/macos-test.sh`, `.ci/pytorch/test.sh`, and
  `.ci/pytorch/smoke_test/check_binary_symbols.py`.
- `distutils.util.strtobool` → a small local replacement in
  `tools/strtobool.py`, imported by `.github/scripts/generate_pytorch_version.py`,
  `tools/generate_torch_version.py`, and `tools/alerts/create_alerts.py`.

## Suggested review order

1. `tools/strtobool.py` — the consolidated helper, semantically identical to
   the removed `distutils.util.strtobool`.
2. The three Python call sites that import it. `.github/scripts/...` uses the
   same `sys.path` shim already established in
   `.github/scripts/close_nonexistent_disable_issues.py` for cross-importing
   from `tools/`.
3. The `sysconfig` substitutions in the shell scripts and
   `check_binary_symbols.py` — mechanical.

<details>
<summary>Out of scope (intentional)</summary>

- `tools/build_pytorch_libs.py` (`distutils._msvccompiler._get_vc_env`):
  deferred to a follow-up — the API is private and the replacement is not a
  one-liner.
- `tools/setup_helpers/cmake.py` (`from distutils.version import LooseVersion`)
  and `setup.py` (`setuptools.distutils.log.warn`): both files are deleted
  outright by the scikit-build-core migration (pytorch#180248); fixing them here
  would just create merge conflicts.
- `test/run_test.py:135`'s `strtobool`: deliberately permissive
  (`s.lower() not in {"", "0", "false", "off"}`) and never raises. Switching
  to the strict distutils-style helper would change behavior for callers
  passing non-canonical truthy values such as `TEST_SHOWLOCALS=yeah`.
- Other `str2bool` variants in `benchmarks/operator_benchmark/`,
  `torch/utils/hipify/`, and `.ci/lumen_cli/` do not use `distutils` and are
  not in this PR's scope.

</details>

Replaces pytorch#180241.

Authored with Claude.

Pull Request resolved: pytorch#182120
Approved by: https://github.com/atalman
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
## Summary

Replace deprecated `distutils` usage in CI scripts and tooling, in preparation
for Python 3.12+ (where `distutils` is removed). Two patterns are handled:

- `distutils.sysconfig.get_python_lib()` → `sysconfig.get_path("purelib")` in
  `.ci/pytorch/macos-test.sh`, `.ci/pytorch/test.sh`, and
  `.ci/pytorch/smoke_test/check_binary_symbols.py`.
- `distutils.util.strtobool` → a small local replacement in
  `tools/strtobool.py`, imported by `.github/scripts/generate_pytorch_version.py`,
  `tools/generate_torch_version.py`, and `tools/alerts/create_alerts.py`.

## Suggested review order

1. `tools/strtobool.py` — the consolidated helper, semantically identical to
   the removed `distutils.util.strtobool`.
2. The three Python call sites that import it. `.github/scripts/...` uses the
   same `sys.path` shim already established in
   `.github/scripts/close_nonexistent_disable_issues.py` for cross-importing
   from `tools/`.
3. The `sysconfig` substitutions in the shell scripts and
   `check_binary_symbols.py` — mechanical.

<details>
<summary>Out of scope (intentional)</summary>

- `tools/build_pytorch_libs.py` (`distutils._msvccompiler._get_vc_env`):
  deferred to a follow-up — the API is private and the replacement is not a
  one-liner.
- `tools/setup_helpers/cmake.py` (`from distutils.version import LooseVersion`)
  and `setup.py` (`setuptools.distutils.log.warn`): both files are deleted
  outright by the scikit-build-core migration (pytorch#180248); fixing them here
  would just create merge conflicts.
- `test/run_test.py:135`'s `strtobool`: deliberately permissive
  (`s.lower() not in {"", "0", "false", "off"}`) and never raises. Switching
  to the strict distutils-style helper would change behavior for callers
  passing non-canonical truthy values such as `TEST_SHOWLOCALS=yeah`.
- Other `str2bool` variants in `benchmarks/operator_benchmark/`,
  `torch/utils/hipify/`, and `.ci/lumen_cli/` do not use `distutils` and are
  not in this PR's scope.

</details>

Replaces pytorch#180241.

Authored with Claude.

Pull Request resolved: pytorch#182120
Approved by: https://github.com/atalman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/binaries Trigger all binary build and upload jobs on the PR open source release notes: releng release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants