@@ -122,8 +122,19 @@ exports_files(["requirements.bzl"])
122
122
def _pip_repository_impl (rctx ):
123
123
python_interpreter = _resolve_python_interpreter (rctx )
124
124
125
- if rctx .attr .incremental and not rctx .attr .requirements_lock :
126
- fail ("Incremental mode requires a requirements_lock attribute be specified." )
125
+ os = rctx .os .name .lower ()
126
+ requirements_txt = rctx .attr .requirements_lock
127
+ if os .startswith ("mac os" ) and rctx .attr .requirements_darwin != None :
128
+ requirements_txt = rctx .attr .requirements_darwin
129
+ elif os .startswith ("linux" ) and rctx .attr .requirements_linux != None :
130
+ requirements_txt = rctx .attr .requirements_linux
131
+ elif "win" in os :
132
+ requirements_txt = rctx .attr .requirements_windows
133
+ if rctx .attr .incremental and not requirements_txt :
134
+ fail ("""\
135
+ Incremental mode requires a requirements_lock attribute be specified,
136
+ or a platform-specific lockfile using one of the requirements_* attributes.
137
+ """ )
127
138
128
139
# Write the annotations file to pass to the wheel maker
129
140
annotations = {package : json .decode (data ) for (package , data ) in rctx .attr .annotations .items ()}
@@ -136,9 +147,9 @@ def _pip_repository_impl(rctx):
136
147
"-m" ,
137
148
"python.pip_install.parse_requirements_to_bzl" ,
138
149
"--requirements_lock" ,
139
- rctx .path (rctx . attr . requirements_lock ),
150
+ rctx .path (requirements_txt ),
140
151
"--requirements_lock_label" ,
141
- str (rctx . attr . requirements_lock ),
152
+ str (requirements_txt ),
142
153
# pass quiet and timeout args through to child repos.
143
154
"--quiet" ,
144
155
str (rctx .attr .quiet ),
@@ -158,7 +169,7 @@ def _pip_repository_impl(rctx):
158
169
"-m" ,
159
170
"python.pip_install.extract_wheels" ,
160
171
"--requirements" ,
161
- rctx .path (rctx . attr . requirements ),
172
+ rctx .path (requirements_txt ),
162
173
"--annotations" ,
163
174
annotations_file ,
164
175
]
@@ -282,6 +293,18 @@ pip_repository_attrs = {
282
293
allow_single_file = True ,
283
294
doc = "A 'requirements.txt' pip requirements file." ,
284
295
),
296
+ "requirements_darwin" : attr .label (
297
+ allow_single_file = True ,
298
+ doc = "Override the requirements_lock attribute when the host platform is Mac OS" ,
299
+ ),
300
+ "requirements_linux" : attr .label (
301
+ allow_single_file = True ,
302
+ doc = "Override the requirements_lock attribute when the host platform is Linux" ,
303
+ ),
304
+ "requirements_windows" : attr .label (
305
+ allow_single_file = True ,
306
+ doc = "Override the requirements_lock attribute when the host platform is Windows" ,
307
+ ),
285
308
"requirements_lock" : attr .label (
286
309
allow_single_file = True ,
287
310
doc = """
0 commit comments