88from packaging .utils import NormalizedName , canonicalize_name
99from packaging .version import Version
1010
11- from . import (
12- constraints ,
13- dependency_graph ,
14- packagesettings ,
15- )
11+ from . import constraints , dependency_graph , packagesettings , request_session
1612
1713logger = logging .getLogger (__name__ )
1814
@@ -25,7 +21,7 @@ class WorkContext:
2521 def __init__ (
2622 self ,
2723 active_settings : packagesettings .Settings | None ,
28- constraints_file : pathlib . Path | None ,
24+ constraints_file : str | None ,
2925 patches_dir : pathlib .Path ,
3026 sdists_repo : pathlib .Path ,
3127 wheels_repo : pathlib .Path ,
@@ -45,12 +41,12 @@ def __init__(
4541 max_jobs = max_jobs ,
4642 )
4743 self .settings = active_settings
48- self .input_constraints_file : pathlib . Path | None
44+ self .input_constraints_uri : str | None
4945 if constraints_file is not None :
50- self .input_constraints_file = constraints_file . absolute ()
46+ self .input_constraints_uri = constraints_file
5147 self .constraints = constraints .load (constraints_file )
5248 else :
53- self .input_constraints_file = None
49+ self .input_constraints_uri = None
5450 self .constraints = constraints .Constraints ({})
5551 self .sdists_repo = pathlib .Path (sdists_repo ).absolute ()
5652 self .sdists_downloads = self .sdists_repo / "downloads"
@@ -88,9 +84,19 @@ def pip_wheel_server_args(self) -> list[str]:
8884
8985 @property
9086 def pip_constraint_args (self ) -> list [str ]:
91- if not self .input_constraints_file :
87+ if not self .input_constraints_uri :
9288 return []
93- return ["--constraint" , os .fspath (self .input_constraints_file )]
89+
90+ if self .input_constraints_uri .startswith (("https://" , "http://" , "file://" )):
91+ path_to_constraints_file = self .work_dir / "input-constraints.txt"
92+ if not path_to_constraints_file .exists ():
93+ response = request_session .session .get (self .input_constraints_uri )
94+ path_to_constraints_file .write_text (response .text )
95+ else :
96+ path_to_constraints_file = pathlib .Path (self .input_constraints_uri )
97+
98+ path_to_constraints_file = path_to_constraints_file .absolute ()
99+ return ["--constraint" , os .fspath (path_to_constraints_file )]
94100
95101 def write_to_graph_to_file (self ):
96102 with open (self .work_dir / "graph.json" , "w" ) as f :
0 commit comments