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
10 changes: 10 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,16 @@ tasks:
name: "tests/integration bazel-in-bazel: Debian"
platform: debian11


integration_test_bazel_vendor_ubuntu:
<<: *reusable_build_test_all
name: "compile_pip_requirements: Ubuntu"
working_directory: tests/integration/pip_parse
platform: ubuntu2004
shell_commands:
- "bazel vendor --vendor_dir=./vendor //..."
- "bazel build --vendor_dir=./vendor //..."
- "rm -rf ./vendor"
integration_test_compile_pip_requirements_ubuntu:
<<: *reusable_build_test_all
name: "compile_pip_requirements: Ubuntu"
Expand Down
1 change: 1 addition & 0 deletions examples/pip_parse/.bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
1 change: 1 addition & 0 deletions examples/pip_parse/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# git ignore patterns

/bazel-*
/vendor
user.bazelrc
4 changes: 3 additions & 1 deletion examples/pip_parse/requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
requests~=2.25.1
s3cmd~=2.1.0
yamllint~=1.28.0
# Just to ensure environment markers are handled properly.
yamllint~=1.28.0; python_version == '3.9'
yamllint~=1.28.0; python_version != '3.9'
sphinx
sphinxcontrib-serializinghtml
2 changes: 1 addition & 1 deletion examples/pip_parse/requirements_lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ urllib3==1.26.20 \
# via
# -c ./constraints_urllib3.txt
# requests
yamllint==1.28.0 \
yamllint==1.28.0 ; python_version == "3.9" \
--hash=sha256:89bb5b5ac33b1ade059743cf227de73daa34d5e5a474b06a5e17fc16583b0cf2 \
--hash=sha256:9e3d8ddd16d0583214c5fdffe806c9344086721f107435f68bad990e5a88826b
# via -r requirements.in
Expand Down
13 changes: 8 additions & 5 deletions python/private/pypi/evaluate_markers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,16 @@ def evaluate_markers_py(mrctx, *, requirements, python_interpreter, python_inter
out_file = mrctx.path("requirements_with_markers.out.json")
mrctx.file(in_file, json.encode(requirements))

interpreter = pypi_repo_utils.resolve_python_interpreter(
mrctx,
python_interpreter = python_interpreter,
python_interpreter_target = python_interpreter_target,
)

pypi_repo_utils.execute_checked(
mrctx,
op = "ResolveRequirementEnvMarkers({})".format(in_file),
python = pypi_repo_utils.resolve_python_interpreter(
mrctx,
python_interpreter = python_interpreter,
python_interpreter_target = python_interpreter_target,
),
python = interpreter,
arguments = [
"-m",
"python.private.pypi.requirements_parser.resolve_target_platforms",
Expand All @@ -95,6 +97,7 @@ def evaluate_markers_py(mrctx, *, requirements, python_interpreter, python_inter
Label("@pypi__packaging//:BUILD.bazel"),
Label("//:BUILD.bazel"),
],
"PYTHONHOME": str(interpreter.dirname),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Solution LGTM in general.

},
logger = logger,
)
Expand Down