Skip to content

Commit f3e83e7

Browse files
authored
fix(venv): include pth files at the root of the site-packages folder (#3340)
Before this PR we would not include `pth` files at the root of the `site-packages` folder, but we would include if they are further down the tree. Fixes #3339 Fixes #2071
1 parent f84640b commit f3e83e7

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ END_UNRELEASED_TEMPLATE
105105
* (venvs) {obj}`--venvs_site_packages=yes` works for packages that dynamically
106106
link to shared libraries
107107
([#3228](https://github.com/bazel-contrib/rules_python/issues/3228)).
108+
* (venvs) {obj}`--venvs_site_packages=yes` includes `pth` files at the root of the
109+
site-packages folder
110+
([#3339](https://github.com/bazel-contrib/rules_python/issues/3339)).
108111
* (uv) {obj}`//python/uv:lock.bzl%lock` now works with a local platform
109112
runtime.
110113
* (toolchains) WORKSPACE builds now correctly register musl and freethreaded

python/private/common.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ PYTHON_FILE_EXTENSIONS = [
3636
"dylib", # Python C modules, Mac specific
3737
"py",
3838
"pyc",
39+
"pth", # import 'pth' files
3940
"pyi",
4041
"so", # Python C modules, usually Linux
4142
]

python/private/venv_runfiles.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ def get_venv_symlinks(ctx, files, package, version_str, site_packages_root):
290290
entry = VenvSymlinkEntry(
291291
kind = VenvSymlinkKind.LIB,
292292
link_to_path = paths.join(runfiles_dir_name, site_packages_root, filename),
293+
link_to_file = src,
293294
package = package,
294295
version = version_str,
295-
venv_path = filename,
296+
venv_path = path,
296297
files = depset([src]),
297298
)
298299
venv_symlinks.append(entry)

tests/venv_site_packages_libs/app_files_building/app_files_building_tests.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def _test_shared_library_symlinking(name):
271271
"site-packages/foo.libs/libx.so",
272272
"site-packages/foo/a.py",
273273
"site-packages/foo/b.so",
274+
"site-packages/root.pth",
275+
"site-packages/root.py",
276+
"site-packages/root.so",
274277
],
275278
)
276279
analysis_test(
@@ -314,6 +317,9 @@ def _test_shared_library_symlinking_impl(env, target):
314317
"bar/y.so": srcs[2],
315318
"foo": "_main/tests/venv_site_packages_libs/app_files_building/site-packages/foo",
316319
"foo.libs/libx.so": srcs[3],
320+
"root.pth": srcs[-3],
321+
"root.py": srcs[-2],
322+
"root.so": srcs[-1],
317323
}
318324
env.expect.that_dict(actual[VenvSymlinkKind.LIB]).contains_exactly(expected_libs)
319325

0 commit comments

Comments
 (0)