Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 7 additions & 36 deletions python/private/pypi/whl_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

""

load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
load("//python/private:auth.bzl", "AUTH_ATTRS", "get_auth")
load("//python/private:envsubst.bzl", "envsubst")
load("//python/private:is_standalone_interpreter.bzl", "is_standalone_interpreter")
Expand Down Expand Up @@ -261,22 +260,6 @@ def _create_repository_execution_environment(rctx, python_interpreter, logger =
env[_CPPFLAGS] = " ".join(cppflags)
return env

def _extract_whl_py(rctx, *, python_interpreter, args, whl_path, environment, logger):
pypi_repo_utils.execute_checked(
rctx,
op = "whl_library.ExtractWheel({}, {})".format(rctx.attr.name, whl_path),
python = python_interpreter,
arguments = args + [
"--whl-file",
whl_path,
],
srcs = rctx.attr._python_srcs,
environment = environment,
quiet = rctx.attr.quiet,
timeout = rctx.attr.timeout,
logger = logger,
)

def _get_entry_points(rctx, install_dir_path, metadata):
dist_info_dir = "{}-{}.dist-info".format(
metadata.name.replace("-", "_"),
Expand Down Expand Up @@ -376,11 +359,10 @@ def _whl_library_impl(rctx):
# build deps from PyPI (e.g. `flit_core`) if they are missing.
extra_pip_args.extend(["--find-links", "."])

enable_pipstar_extract = rp_config.bazel_8_or_later

# When pipstar is enabled, Python isn't used, so there's no need
# to setup env vars to run Python, unless we need to build an sdist
if enable_pipstar_extract and whl_path and not rctx.attr.whl_patches:
# When we already have a wheel and there are no patches, Python isn't used,
# so there's no need to setup env vars to run Python, unless we need to
# build an sdist or resolve a requirement.
if whl_path and not rctx.attr.whl_patches:
environment = {}
args = []
python_interpreter = None
Expand Down Expand Up @@ -446,17 +428,7 @@ def _whl_library_impl(rctx):
timeout = rctx.attr.timeout,
)

if enable_pipstar_extract:
whl_extract(rctx, whl_path = whl_path, logger = logger)
else:
_extract_whl_py(
rctx,
python_interpreter = python_interpreter,
args = args,
whl_path = whl_path,
environment = environment,
logger = logger,
)
whl_extract(rctx, whl_path = whl_path, logger = logger)

install_dir_path = whl_path.dirname.get_child("site-packages")
metadata = whl_metadata(
Expand Down Expand Up @@ -513,9 +485,8 @@ repo(
_remove_files(rctx, "BUILD", "BUILD.bazel")
rctx.file("BUILD.bazel", build_file_contents)

if enable_pipstar_extract:
if hasattr(rctx, "repo_metadata"):
return rctx.repo_metadata(reproducible = True)
if hasattr(rctx, "repo_metadata"):
return rctx.repo_metadata(reproducible = True)
Comment thread
rickeylev marked this conversation as resolved.

return None

Expand Down
4 changes: 0 additions & 4 deletions tests/venv_site_packages_libs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//python:py_library.bzl", "py_library")
load("//tests/support:py_reconfig.bzl", "py_reconfig_test")
Expand Down Expand Up @@ -79,9 +78,6 @@ py_reconfig_test(
"@platforms//os:windows": "system_python",
"//conditions:default": "script",
}),
env = {
"BAZEL_8_OR_LATER": "1" if rp_config.bazel_8_or_later else "0",
},
main = "whl_scripts_runnable_test.py",
venvs_site_packages = "yes",
deps = [
Expand Down
6 changes: 0 additions & 6 deletions tests/venv_site_packages_libs/whl_scripts_runnable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ def test_entry_point_is_runnable(self):
script_executable = output[-1].strip()
self.assertEqual(script_executable, sys.executable)

# This should really check for 8.5 instead of 8+, but we test with 8.6
# so it's close enough for our purposes.
@unittest.skipUnless(
BAZEL_8_OR_LATER,
"bazel 8.5 and lower uses wheel.py, which rewrites #!pythonw to #!python",
)
def test_pythonw_script(self):
script_path = self._get_script_path("whl_with_data1_pythonw")
self.assertTrue(script_path.exists(), f"Script not found at {script_path}")
Expand Down