|
4 | 4 | import sys |
5 | 5 | import time |
6 | 6 | import subprocess |
7 | | -import shutil |
8 | 7 | import hashlib |
9 | 8 | import argparse |
10 | 9 |
|
11 | | -import urllib.request |
12 | 10 |
|
13 | 11 | start_time = time.time() |
14 | 12 | current_path = os.path.abspath(os.curdir) |
@@ -207,6 +205,31 @@ def git_tag(tag=None): |
207 | 205 | os.system(f"git tag {tag}") |
208 | 206 | os.system(f"git push --tags") |
209 | 207 |
|
| 208 | +# Python Build helpers ----------------------------------------------------------------------------- |
| 209 | +def bump_version(version): |
| 210 | + with open("setup.py", "r") as f: |
| 211 | + content = f.readlines() |
| 212 | + with open("setup.py", "w") as f: |
| 213 | + for line in content: |
| 214 | + # Find the version line |
| 215 | + if line.strip().startswith("version"): |
| 216 | + # Get the current version |
| 217 | + current_version = line.strip().split('=')[1].strip(" ,\"") |
| 218 | + # Print the current version for debugging |
| 219 | + print_status(f"Current version: {current_version}") |
| 220 | + # Print the new version for debugging |
| 221 | + print_status(f"New version: {version}") |
| 222 | + |
| 223 | + line = line.replace(current_version, version) |
| 224 | + f.write(line) |
| 225 | + |
| 226 | +def build_repo(): |
| 227 | + os.system(f"python -m build --sdist --wheel") |
| 228 | + os.system(f"python -m twine check dist/*") |
| 229 | + |
| 230 | +def push_to_pypi(): |
| 231 | + os.system(f"python -m twine upload dist/*") |
| 232 | + |
210 | 233 | # Git repositories initialization ------------------------------------------------------------------ |
211 | 234 |
|
212 | 235 | def litex_setup_init_repos(config="standard", tag=None, dev_mode=False): |
@@ -330,11 +353,28 @@ def litex_setup_release_repos(tag): |
330 | 353 | for name in install_configs["full"]: |
331 | 354 | if name in ["migen"]: |
332 | 355 | continue |
333 | | - repo = git_repos[name] |
| 356 | + |
334 | 357 | os.chdir(os.path.join(current_path, name)) |
| 358 | + |
335 | 359 | # Tag Repo. |
336 | 360 | print_status(f"Tagging {name} Git repository as {tag}...") |
337 | 361 | git_tag(tag=tag) |
| 362 | + |
| 363 | + # TODO: Not all repos have been uplifted for redistribution. |
| 364 | + # Eventually, this "if" check should be removed and the bump |
| 365 | + # versioning part moved above the git tag |
| 366 | + if name in ("litex",): |
| 367 | + # Bump the version |
| 368 | + print_status(f"Bumping the version of {name} python package...") |
| 369 | + bump_version(version=tag) |
| 370 | + |
| 371 | + # Make sure the repo builds for distribution |
| 372 | + print_status(f"Building {name} python package...") |
| 373 | + build_repo() |
| 374 | + |
| 375 | + # Push disted artifacts to pypi |
| 376 | + print_status(f"Publishing {name} to pypi...") |
| 377 | + push_to_pypi() |
338 | 378 | else: |
339 | 379 | print_status(f"Not confirmed, exiting.") |
340 | 380 |
|
|
0 commit comments