Skip to content

fix: support older bootstrap Python - #1518

Closed
rksharma-owg wants to merge 1 commit into
meta:mainfrom
rksharma-owg:fix/buck2-python-compatibility
Closed

rksharma-owg wants to merge 1 commit into
meta:mainfrom
rksharma-owg:fix/buck2-python-compatibility

Conversation

@rksharma-owg

Copy link
Copy Markdown
Contributor

Summary

Replace the Python 3.12-only Path.relative_to(walk_up=True) call in the Rust build-script shim with os.path.relpath.

Problem

The default system Python bootstrap toolchain can invoke from_any_dir.py with Python versions before 3.12, causing TypeError: relative_to() got an unexpected keyword argument 'walk_up' for Rust build scripts that compile C.

Root Cause

Path.relative_to(walk_up=True) is unavailable before Python 3.12, but the system bootstrap toolchain uses the host python3 without enforcing that minimum.

Fix

Use os.path.relpath, preserving the existing relative-path behavior without imposing a Python 3.12 requirement.

Tests

Scope is intentionally limited to the Rust build-script path shim.

Fixes #1490

@meta-cla

meta-cla Bot commented Sep 26, 2026

Copy link
Copy Markdown

Hi @rksharma-owg!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 26, 2026
@meta-codesync

meta-codesync Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@christycylee has imported this pull request. If you are a Meta employee, you can view this in D135755968. (Because this pull request was imported automatically, there will not be any future comments.)

meta-codesync Bot pushed a commit to meta/buck2-prelude that referenced this pull request Dec 3, 2026
Summary:
Replace the Python 3.12-only Path.relative_to(walk_up=True) call in the Rust build-script shim with os.path.relpath.

## Problem

The default system Python bootstrap toolchain can invoke from_any_dir.py with Python versions before 3.12, causing TypeError: relative_to() got an unexpected keyword argument 'walk_up' for Rust build scripts that compile C.

## Root Cause

Path.relative_to(walk_up=True) is unavailable before Python 3.12, but the system bootstrap toolchain uses the host python3 without enforcing that minimum.

## Fix

Use os.path.relpath, preserving the existing relative-path behavior without imposing a Python 3.12 requirement.

## Tests

- python3.11 prelude/rust/tools/from_any_dir_test.py
- python3 prelude/rust/tools/from_any_dir_test.py
- python3 -m py_compile prelude/rust/tools/from_any_dir.py prelude/rust/tools/from_any_dir_test.py
- Fork GitHub Actions matrix: Linux, macOS, and Windows passed (run 36185760647: https://github.com/rksharma-owg/buck2/actions/runs/36185760647).

Scope is intentionally limited to the Rust build-script path shim.

Fixes meta/buck2#1490

X-link: meta/buck2#1518

Reviewed By: dtolnay

Differential Revision: D135755968

Pulled By: christycylee

fbshipit-source-id: 4c62d18d1bc912fbb6d73eb40183ed8f4abb7b68
@meta-codesync meta-codesync Bot closed this in 17bf203 Dec 3, 2026
@meta-codesync meta-codesync Bot added the Merged label Dec 3, 2026
@meta-codesync

meta-codesync Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@christycylee merged this pull request in 17bf203.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prelude/rust: from_any_dir.py needs Python ≥ 3.12 (Path.relative_to(walk_up=True)) but the bootstrap toolchain runs whatever host python3 is

1 participant