Skip to content

next build chain that replaces DOS scripts per Python+TOML file #1710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2025
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
102 changes: 102 additions & 0 deletions build_winpython_meta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import os
import sys
# Use tomllib if available (Python 3.11+), otherwise fall back to tomli
try:
import tomllib # Python 3.11+
except ImportError:
try:
import tomli as tomllib # For older Python versions
except ImportError:
print("Please install tomli for Python < 3.11: pip install tomli")
sys.exit(1)

#import yaml
import subprocess
from pathlib import Path

def load_builds(config_file):
with open(config_file, "rb") as f:
config = tomllib.load(f)
builds = config["builds"]
python_versions = config.get("pythons", {})
return builds, python_versions
#with open(config_file, "r", encoding="utf-8") as f:
# return yaml.safe_load(f)["builds"]

def run_build(build, python_versions):
print(f"\n=== Building WinPython: {build['name']} ===")
print(build)

root_dir_for_builds = build["root_dir_for_builds"]
my_python_target = build["python_target"]
my_flavor = build["flavor"]
my_arch = str(build["arch"])
my_create_installer = build.get("create_installer", "True")
my_requirements = build.get("requirements", "")
my_source_dirs = build.get("source_dirs", "")
my_find_links = build.get("find_links", "")
my_toolsdirs = build.get("toolsdirs", "")
#my_install_options = build.get("install_options", "")
wheelhousereq = build.get("wheelhousereq", "")

# Get Python release info from TOML [pythons]
py_target = my_python_target
vinfo = python_versions.get(py_target, {})
my_python_target_release = vinfo.get("python_target_release", "")
my_release = vinfo.get("release", "")
my_release_level = vinfo.get("my_release_level", "b0")
mandatory_requirements = vinfo.get("mandatory_requirements", os.path.join(os.getcwd(), "mandatory_requirements.txt"))

# Get Python release info from TOML [pythons]
my_constraints = build.get("my_constraints", r"C:\WinP\constraints.txt")
target_python_exe = build.get("target_python_exe", "python.exe")

# Build directory logic
my_basedir = f"{root_dir_for_builds}\\bd{my_python_target}"
my_WINPYDIRBASE = f"{my_basedir}\\bu{my_flavor}\\WPy{my_arch}-{my_python_target_release}{my_release}{my_release_level}"

# Build env paths (customize as needed) already defined per the launcher of that script...

my_python_exe = Path(sys.executable)
my_buildenvi = str(my_python_exe.parent)

my_archive_dir = os.path.join(os.getcwd(), "WinPython_build_logs")
os.makedirs(my_archive_dir, exist_ok=True)

my_requirements_pre = build.get("my_requirements_pre", mandatory_requirements)

# Build command
build_cmd = [
str(my_python_exe),
"-m", "winpython.build_winpython",
"--buildenv", my_buildenvi,
"--python-target", my_python_target,
"--release", my_release,
"--release-level", my_release_level,
"--winpydirbase", my_WINPYDIRBASE,
"--flavor", my_flavor,
"--source_dirs", my_source_dirs,
"--tools_dirs", my_toolsdirs,
"--log-dir", my_archive_dir,
"--mandatory-req", mandatory_requirements,
"--pre-req", my_requirements_pre,
"--requirements", my_requirements,
"--constraints", my_constraints,
"--find-links", my_find_links,
"--wheelhousereq", wheelhousereq,
"--create-installer", my_create_installer,
#"--install-options", env["my_install_options"],
]

print("Running build command:")
print(" ".join(build_cmd))
subprocess.run(build_cmd, cwd=os.getcwd(), check=False)

def main():
config_file = sys.argv[1] if len(sys.argv) > 1 else "winpython_buildsZZZ.toml"
builds, python_versions = load_builds(config_file)
for build in builds:
run_build(build, python_versions)

if __name__ == "__main__":
main()
11 changes: 5 additions & 6 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ numba>=0.53.1
numcodecs>=0.7.3
numdifftools>=0.9.39
numexpr>=2.7.3
numpy>=1.20.2+mkl
numpy>=1.20.2
numpydoc>=1.1.0
oct2py>=5.2.0
octave-kernel>=0.32.0
Expand Down Expand Up @@ -425,7 +425,7 @@ pytest>=6.2.3
python-baseconv>=1.2.2
python-dateutil>=2.8.1
python-dotenv>=0.15.0
python-hdf4>=0.10.0+dummy
python-hdf4>=0.10.0
python-jsonrpc-server>=0.4.0
python-language-server>=0.36.2
python-Levenshtein>=0.12.2
Expand Down Expand Up @@ -547,15 +547,14 @@ tinycss>=0.4
toml>=0.10.2
toolz>=0.11.1

torch>=1.8.1+cpu
torch>=1.8.1
torchaudio>=0.8.1
torchvision>=0.8.2+cpu

torchvision>=0.8.2
tornado>=6.1
tqdm>=4.59.0
traitlets>=5.0.5
traittypes>=0.2.1
tranquilizer>=0.5.0+1.gff8dd5f
tranquilizer>=0.5.0
trio>=0.18.0
trio-asyncio>=0.12.0
twine>=3.4.1
Expand Down
1 change: 1 addition & 0 deletions generate_a_winpython_distropy_meta.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"C:\WinPdev\WPy64-310111\python-3.10.11.amd64\python.exe" build_winpython_meta.py %1
54 changes: 54 additions & 0 deletions winpython_builds_bd13.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[pythons]
"311" = { python_target_release = "3119", release = "2", my_release_level = "b3" }
"312" = { python_target_release = "31210", release = "2", my_release_level = "b3" }
"313" = { python_target_release = "3135", release = "1", my_release_level = "b3" }
"314" = { python_target_release = "3140", release = "1", my_release_level = "rc1" }


[[builds]]
name = "dot"
root_dir_for_builds = "C:\\Winp"
python_target = "313"
pyver = "3.13"
flavor = "test"
arch = "64"
create_installer = "7zip.zip"
preclear_build_directory = "Yes"
requirements = "C:\\Winp\\bd313\\dot_requirements.txt"
source_dirs = "C:\\Winp\\bd313\\packages.win-amd64"
find_links = "C:\\Winp\\packages.srcreq"
toolsdirs = "C:\\Winp\\bdTools\\Tools.dot"
install_options = "--no-index --pre --trusted-host=None"


[[builds]]
name = "slim"
root_dir_for_builds = "C:\\Winp"
python_target = "313"
pyver = "3.13"
flavor = "slim"
arch = "64"
create_installer = "7zip.7z"
preclear_build_directory = "Yes"
requirements = "C:\\Winp\\bd313\\requirements64_slim.txt"
source_dirs = "C:\\Winp\\bd313\\packages.win-amd64"
find_links = "C:\\Winp\\packages.srcreq"
toolsdirs = "C:\\Winp\\bdTools\\tools64_pandoc_alone"
install_options = "--no-index --pre --trusted-host=None"


[[builds]]
name = "whl"
root_dir_for_builds = "C:\\Winp"
python_target = "313"
pyver = "3.13"
flavor = "whl"
arch = "64"
create_installer = ".7z-mx9"
preclear_build_directory = "Yes"
requirements = "C:\\Winp\\bd313\\dot_requirements.txt"
source_dirs = "C:\\Winp\\bd313\\packages.win-amd64"
find_links = "C:\\Winp\\packages.srcreq"
toolsdirs = "C:\\Winp\\bdTools\\Tools.dot"
install_options = "--no-index --pre --trusted-host=None"
wheelhousereq = "C:\\Winp\\bd313\\requirements64_whl.txt"