Skip to content

Conversation

@rickeylev
Copy link
Contributor

The test was failing because the b.py file couldn't be imported because, starting with Python 3.11, the PYTHONSAFEPATH environment variable (set by the bootstrap startup) is respected. This setting inhibits the default Python behavior of adding the main script's directory to sys.path.

To fix, use py_library.imports to explicitly add the necessary directory to sys.path.

Fixes #20660

The test was failing because the `b.py` file couldn't be imported
because, starting with Python 3.11, the `PYTHONSAFEPATH` environment
variable (set by the bootstrap startup) is respected. This setting
inhibits the default Python behavior of adding the main script's
directory to sys.path.

To fix, use `py_library.imports` to explicitly add the necessary
directory to `sys.path`.

Fixes bazelbuild#20660
@copybara-service copybara-service bot closed this in 9b027c8 Jan 3, 2024
@rickeylev rickeylev deleted the fix.py.smoke.311 branch January 3, 2024 22:11
iancha1992 pushed a commit to iancha1992/bazel that referenced this pull request Dec 13, 2024
The test was failing because the `b.py` file couldn't be imported because, starting with Python 3.11, the `PYTHONSAFEPATH` environment variable (set by the bootstrap startup) is respected. This setting inhibits the default Python behavior of adding the main script's directory to sys.path.

To fix, use `py_library.imports` to explicitly add the necessary directory to `sys.path`.

Fixes bazelbuild#20660

Closes bazelbuild#20738.

PiperOrigin-RevId: 595498775
Change-Id: I0c9521b210fe9e2c40692727fc87d41995e0968a
iancha1992 pushed a commit to iancha1992/bazel that referenced this pull request Dec 13, 2024
The test was failing because the `b.py` file couldn't be imported because, starting with Python 3.11, the `PYTHONSAFEPATH` environment variable (set by the bootstrap startup) is respected. This setting inhibits the default Python behavior of adding the main script's directory to sys.path.

To fix, use `py_library.imports` to explicitly add the necessary directory to `sys.path`.

Fixes bazelbuild#20660

Closes bazelbuild#20738.

PiperOrigin-RevId: 595498775
Change-Id: I0c9521b210fe9e2c40692727fc87d41995e0968a
iancha1992 added a commit that referenced this pull request Dec 16, 2024
python: fix bazel py_test testSmoke for Python 3.11+
The test was failing because the `b.py` file couldn't be imported
because, starting with Python 3.11, the `PYTHONSAFEPATH` environment
variable (set by the bootstrap startup) is respected. This setting
inhibits the default Python behavior of adding the main script's
directory to sys.path.

To fix, use `py_library.imports` to explicitly add the necessary
directory to `sys.path`.

Fixes #20660

Closes #20738.

PiperOrigin-RevId: 595498775
Change-Id: I0c9521b210fe9e2c40692727fc87d41995e0968a

Commit
9b027c8

No public description
PiperOrigin-RevId: 694487395
Change-Id: I3f3e154ebfa932721d917661d61a878477a8e574

Commit
be2186f

---------

Co-authored-by: Richard Levasseur <[email protected]>
Co-authored-by: Googler <[email protected]>
mbland pushed a commit to mbland/bazel that referenced this pull request Nov 14, 2025
…dows CI failures (bazelbuild#24691)

python: fix bazel py_test testSmoke for Python 3.11+
The test was failing because the `b.py` file couldn't be imported
because, starting with Python 3.11, the `PYTHONSAFEPATH` environment
variable (set by the bootstrap startup) is respected. This setting
inhibits the default Python behavior of adding the main script's
directory to sys.path.

To fix, use `py_library.imports` to explicitly add the necessary
directory to `sys.path`.

Fixes bazelbuild#20660

Closes bazelbuild#20738.

PiperOrigin-RevId: 595498775
Change-Id: I0c9521b210fe9e2c40692727fc87d41995e0968a

Commit
bazelbuild@9b027c8

No public description
PiperOrigin-RevId: 694487395
Change-Id: I3f3e154ebfa932721d917661d61a878477a8e574

Commit
bazelbuild@be2186f

---------

Co-authored-by: Richard Levasseur <[email protected]>
Co-authored-by: Googler <[email protected]>
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.

//src/test/py/bazel:py_test is broken with Python 3.11

1 participant