Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be0f661

Browse filesBrowse files
author
Alex Eagle
committed
Allow for requirements files to differ per platform
As a common example, we need a compiled requirements file for linux that differs from mac os
1 parent b842276 commit be0f661
Copy full SHA for be0f661

File tree

Expand file treeCollapse file tree

2 files changed

+22
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-5
lines changed

‎python/pip.bzl

Copy file name to clipboardExpand all lines: python/pip.bzl
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ load("//python/pip_install:requirements.bzl", _compile_pip_requirements = "compi
1919

2020
compile_pip_requirements = _compile_pip_requirements
2121

22-
def pip_install(requirements, name = "pip", **kwargs):
22+
def pip_install(requirements = None, name = "pip", **kwargs):
2323
"""Accepts a `requirements.txt` file and installs the dependencies listed within.
2424
2525
Those dependencies become available in a generated `requirements.bzl` file.

‎python/pip_install/pip_repository.bzl

Copy file name to clipboardExpand all lines: python/pip_install/pip_repository.bzl
+21-4Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,32 @@ exports_files(["requirements.bzl"])
121121
def _pip_repository_impl(rctx):
122122
python_interpreter = _resolve_python_interpreter(rctx)
123123

124-
if rctx.attr.incremental and not rctx.attr.requirements_lock:
125-
fail("Incremental mode requires a requirements_lock attribute be specified.")
124+
# if rctx.attr.incremental and not rctx.attr.requirements_lock:
125+
# fail("Incremental mode requires a requirements_lock attribute be specified.")
126126

127127
# We need a BUILD file to load the generated requirements.bzl
128128
rctx.file("BUILD.bazel", _BUILD_FILE_CONTENTS)
129129

130130
pypath = _construct_pypath(rctx)
131131

132+
os = rctx.os.name.lower()
133+
requirements_txt = rctx.attr.requirements
134+
135+
if os.startswith("mac os") and rctx.attr.requirements_darwin != None:
136+
requirements_txt = rctx.attr.requirements_darwin
137+
elif os.startswith("linux") and rctx.attr.requirements_linux != None:
138+
requirements_txt = rctx.attr.requirements_linux
139+
140+
if requirements_txt == None:
141+
fail("Expected platform specific requirements attribute, or requirements to be set")
142+
132143
if rctx.attr.incremental:
133144
args = [
134145
python_interpreter,
135146
"-m",
136147
"python.pip_install.parse_requirements_to_bzl",
137148
"--requirements_lock",
138-
rctx.path(rctx.attr.requirements_lock),
149+
rctx.path(requirements_txt),
139150
# pass quiet and timeout args through to child repos.
140151
"--quiet",
141152
str(rctx.attr.quiet),
@@ -153,7 +164,7 @@ def _pip_repository_impl(rctx):
153164
"-m",
154165
"python.pip_install.extract_wheels",
155166
"--requirements",
156-
rctx.path(rctx.attr.requirements),
167+
rctx.path(requirements_txt),
157168
]
158169

159170
args += ["--repo", rctx.attr.name, "--repo-prefix", rctx.attr.repo_prefix]
@@ -261,6 +272,12 @@ pip_repository_attrs = {
261272
allow_single_file = True,
262273
doc = "A 'requirements.txt' pip requirements file.",
263274
),
275+
"requirements_darwin": attr.label(
276+
allow_single_file = True,
277+
),
278+
"requirements_linux": attr.label(
279+
allow_single_file = True,
280+
),
264281
"requirements_lock": attr.label(
265282
allow_single_file = True,
266283
doc = """

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.