Skip to content

Commit 81d853a

Browse files
committed
move wheelhouse requirements processing into a dedicated function
1 parent 375604a commit 81d853a

File tree

1 file changed

+49
-31
lines changed

1 file changed

+49
-31
lines changed

winpython/build_winpython.py

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,54 @@ def run_make_py(build_python, winpydirbase, args):
102102
verbose=True, flavor=args.flavor,
103103
source_dirs=args.source_dirs, toolsdirs=args.tools_dirs
104104
)
105+
106+
def process_wheelhouse_requirements(target_python: Path, winpydirbase: Path,args: argparse.Namespace,file_postfix: str):
107+
"""
108+
Handle installation and conversion of wheelhouse requirements.
109+
"""
110+
log_section(f"🙏 Step 5: install wheelhouse requirements {args.wheelhousereq}")
111+
wheelhousereq = Path(args.wheelhousereq)
112+
kind = "local"
113+
out = winpydirbase.parent / f"pylock.{file_postfix}_wheels{kind}.toml"
114+
outreq = winpydirbase.parent / f"requir.{file_postfix}_wheels{kind}.txt"
115+
if wheelhousereq.is_file():
116+
# Generate pylock from wheelhousereq
117+
cmd = [
118+
str(target_python), "-m", "pip", "lock", "--no-index", "--trusted-host=None",
119+
"--find-links", args.find_links, "-c", args.constraints, "-r", str(wheelhousereq),
120+
"-o", str(out)
121+
]
122+
run_command(cmd)
123+
# Convert pylock to requirements with hash
124+
pylock_to_req_cmd = [
125+
str(target_python), "-X", "utf8", "-c",
126+
f"from wppm import wheelhouse as wh; wh.pylock_to_req(r'{out}', r'{outreq}')"
127+
]
128+
run_command(pylock_to_req_cmd, check=False)
129+
130+
kind = ""
131+
outw = winpydirbase.parent / f"pylock.{file_postfix}_wheels{kind}.toml"
132+
outreqw = winpydirbase.parent / f"requir.{file_postfix}_wheels{kind}.txt"
133+
# Generate web pylock from local frozen hashes
134+
web_lock_cmd = [
135+
str(target_python), "-m", "pip", "lock", "--no-deps", "--require-hashes",
136+
"-r", str(outreq), "-o", str(outw)
137+
]
138+
run_command(web_lock_cmd)
139+
pylock_to_req_cmd2 = [
140+
str(target_python), "-X", "utf8", "-c",
141+
f"from wppm import wheelhouse as wh; wh.pylock_to_req(r'{outw}', r'{outreqw}')"
142+
]
143+
run_command(pylock_to_req_cmd2, check=False)
144+
145+
# Use wppm to download local from req made with web hashes
146+
wheelhouse = winpydirbase / "wheelhouse" / "included.wheels"
147+
wppm_cmd = [
148+
str(target_python), "-X", "utf8", "-m", "wppm", str(out), "-ws", args.find_links,
149+
"-wd", str(wheelhouse)
150+
]
151+
run_command(wppm_cmd, check=False)
152+
105153
def main():
106154
parser = argparse.ArgumentParser()
107155
parser.add_argument('--python-target', required=True, help='Target Python version, e.g. 311')
@@ -165,37 +213,7 @@ def main():
165213
patch_winpython(target_python)
166214

167215
if args.wheelhousereq:
168-
log_section(f"🙏 Step 5: install wheelhouse requirements {args.wheelhousereq}")
169-
wheelhousereq = Path(args.wheelhousereq)
170-
kind = "local"
171-
out = winpydirbase.parent / f"pylock.{file_postfix}_wheels{kind}.toml"
172-
outreq = winpydirbase.parent / f"requir.{file_postfix}_wheels{kind}.txt"
173-
if wheelhousereq.is_file():
174-
# Generate pylock from wheelhousereq
175-
cmd = [str(target_python), "-m" , "pip", "lock","--no-index", "--trusted-host=None",
176-
"--find-links", args.find_links, "-c", str(args.constraints), "-r", str(wheelhousereq),
177-
"-o", str(out) ]
178-
run_command(cmd)
179-
# Convert pylock to requirements with hash
180-
cmd = [str(target_python), "-X", "utf8", "-c", f"from wppm import wheelhouse as wh; wh.pylock_to_req(r'{out}', r'{outreq}')"]
181-
run_command(cmd, check=False)
182-
183-
kind = ""
184-
outw = winpydirbase.parent / f"pylock.{file_postfix}_wheels{kind}.toml"
185-
outreqw = winpydirbase.parent / f"requir.{file_postfix}_wheels{kind}.txt"
186-
# Generate web pylock from local frozen hashes
187-
cmd = [str(target_python), "-m" , "pip", "lock","--no-deps", "--require-hashes",
188-
"-r", str(outreq), "-o", str(outw) ]
189-
run_command(cmd)
190-
cmd = [str(target_python), "-X", "utf8", "-c", f"from wppm import wheelhouse as wh; wh.pylock_to_req(r'{outw}', r'{outreqw}')"]
191-
run_command(cmd, check=False)
192-
193-
# Use wppm to download local from req made with web hashes
194-
wheelhouse = winpydirbase / "wheelhouse" / "included.wheels"
195-
cmd = [str(target_python), "-X", "utf8", "-m", "wppm", str(out), "-ws", args.find_links,
196-
"-wd", str(wheelhouse)
197-
]
198-
run_command(cmd, check=False)
216+
process_wheelhouse_requirements(target_python, winpydirbase, args, file_postfix)
199217

200218
log_section("🙏 Step 6: install lockfiles")
201219
print(target_python, winpydirbase, args.constraints, args.find_links, file_postfix)

0 commit comments

Comments
 (0)