Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ END_UNRELEASED_TEMPLATE
([#2762](https://github.com/bazel-contrib/rules_python/issues/2762))
* (gazelle) Ancestor `conftest.py` files are added in addition to sibling `conftest.py`.
([#3497](https://github.com/bazel-contrib/rules_python/issues/3497))
* (pypi) `pip_parse` no longer silently drops PEP 508 URL-based requirements
(`pkg @ https://...`) when `extract_url_srcs=False` (the default for
`pip_repository`).

{#v0-0-0-added}
### Added
Expand Down
2 changes: 1 addition & 1 deletion python/private/pypi/parse_requirements.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _package_srcs(

if extract_url_srcs and dist:
req_line = r.srcs.requirement
elif can_fallback:
elif can_fallback or (not extract_url_srcs and dist):
dist = struct(
url = "",
filename = "",
Expand Down
41 changes: 41 additions & 0 deletions tests/pypi/parse_requirements/parse_requirements_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,47 @@ def _test_direct_urls_integration(env):

_tests.append(_test_direct_urls_integration)

def _test_direct_urls_no_extract(env):
"""Check that URL requirements are not dropped when extract_url_srcs=False."""
got = parse_requirements(
requirements_by_platform = {
"requirements_direct": ["linux_x86_64"],
"requirements_direct_sdist": ["osx_x86_64"],
},
extract_url_srcs = False,
)
env.expect.that_collection(got).contains_exactly([
struct(
name = "foo",
is_exposed = True,
is_multiple_versions = True,
srcs = [
struct(
distribution = "foo",
extra_pip_args = [],
filename = "",
requirement_line = "foo @ https://github.com/org/foo/downloads/foo-1.1.tar.gz",
sha256 = "",
target_platforms = ["osx_x86_64"],
url = "",
yanked = False,
),
struct(
distribution = "foo",
extra_pip_args = [],
filename = "",
requirement_line = "foo[extra] @ https://some-url/package.whl",
sha256 = "",
target_platforms = ["linux_x86_64"],
url = "",
yanked = False,
),
],
),
])

_tests.append(_test_direct_urls_no_extract)

def _test_extra_pip_args(env):
got = parse_requirements(
requirements_by_platform = {
Expand Down