Skip to content

Commit fe82b9a

Browse files
committed
Add disting to pypi to release steps
1 parent e6c63ab commit fe82b9a

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

litex_setup.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
import sys
55
import time
66
import subprocess
7-
import shutil
87
import hashlib
98
import argparse
109

11-
import urllib.request
1210

1311
start_time = time.time()
1412
current_path = os.path.abspath(os.curdir)
@@ -207,6 +205,31 @@ def git_tag(tag=None):
207205
os.system(f"git tag {tag}")
208206
os.system(f"git push --tags")
209207

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+
210233
# Git repositories initialization ------------------------------------------------------------------
211234

212235
def litex_setup_init_repos(config="standard", tag=None, dev_mode=False):
@@ -330,11 +353,28 @@ def litex_setup_release_repos(tag):
330353
for name in install_configs["full"]:
331354
if name in ["migen"]:
332355
continue
333-
repo = git_repos[name]
356+
334357
os.chdir(os.path.join(current_path, name))
358+
335359
# Tag Repo.
336360
print_status(f"Tagging {name} Git repository as {tag}...")
337361
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()
338378
else:
339379
print_status(f"Not confirmed, exiting.")
340380

setup.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name = "litex",
13-
version = "2024.08",
13+
version = "2024.12",
1414
description = "Python SoC/Core builder for building FPGA based systems.",
1515
long_description = long_description,
1616
long_description_content_type = "text/markdown",
@@ -32,7 +32,11 @@
3232
"meson"
3333
"pexpect"
3434
"setuptools"
35-
"requests"
35+
"requests",
36+
# Tools for distribution
37+
"build",
38+
"twine",
39+
"wheel",
3640
]
3741
},
3842
packages = find_packages(exclude=("test*", "sim*", "doc*")),

0 commit comments

Comments
 (0)