Skip to content

Commit 602d526

Browse files
committed
refactor: Migrate to PEP621, add uv.lock and move to capstone 5
This makes packaging easier on newer systems and facilitates reproducibility of the builds. Note: I do not have the expertise around setup.py & python packaging in general. Part of this commit has been co-developed with an LLM. I checked it works on my system.
1 parent cc1ae68 commit 602d526

File tree

5 files changed

+2039
-159
lines changed

5 files changed

+2039
-159
lines changed

pyocd/_build.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from __future__ import annotations
2+
3+
import zipfile
4+
from pathlib import Path
5+
6+
from setuptools.command.build_py import build_py as _build_py
7+
from setuptools.command.sdist import sdist as _sdist
8+
9+
10+
def _ensure_svd_zip() -> None:
11+
script_dir = Path(__file__).resolve().parent
12+
svd_dir_path = script_dir / "debug" / "svd"
13+
svd_data_dir_path = svd_dir_path / "data"
14+
svd_zip_path = svd_dir_path / "svd_data.zip"
15+
16+
if svd_data_dir_path.exists():
17+
with zipfile.ZipFile(svd_zip_path, "w", zipfile.ZIP_DEFLATED) as svd_zip:
18+
for svd_file in sorted(svd_data_dir_path.iterdir()):
19+
if svd_file.is_file():
20+
svd_zip.write(svd_file, svd_file.name)
21+
elif not svd_zip_path.exists():
22+
raise RuntimeError(
23+
"neither the source SVD data directory nor built svd_data.zip exist",
24+
)
25+
26+
27+
class build_py(_build_py):
28+
def run(self) -> None:
29+
_ensure_svd_zip()
30+
super().run()
31+
32+
33+
class sdist(_sdist):
34+
def run(self) -> None:
35+
_ensure_svd_zip()
36+
super().run()

pyproject.toml

Lines changed: 117 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,130 @@
44
requires = [
55
"setuptools>=51",
66
"wheel",
7-
"setuptools_scm[toml]>=6.0,<7.0; python_version < \"3.7\"",
8-
"setuptools_scm[toml]>=7.0; python_version >= \"3.7\"",
7+
"setuptools_scm>=7.0",
98
]
109
build-backend = "setuptools.build_meta"
1110

11+
[project]
12+
name = "pyocd"
13+
description = "Cortex-M debugger for Python"
14+
readme = "README.md"
15+
requires-python = ">=3.8"
16+
license = { text = "Apache-2.0" }
17+
maintainers = [
18+
{ name = "Chris Reed", email = "[email protected]" },
19+
]
20+
keywords = ["embedded", "debug", "debugger", "arm", "gdb", "gdbserver", "flash", "test"]
21+
classifiers = [
22+
"Development Status :: 5 - Production/Stable",
23+
"Environment :: Console",
24+
"Intended Audience :: Developers",
25+
"Intended Audience :: Manufacturing",
26+
"Intended Audience :: Science/Research",
27+
"License :: OSI Approved :: Apache Software License",
28+
"Operating System :: MacOS :: MacOS X",
29+
"Operating System :: Microsoft :: Windows",
30+
"Operating System :: POSIX",
31+
"Operating System :: POSIX :: BSD",
32+
"Operating System :: POSIX :: Linux",
33+
"Programming Language :: Python",
34+
"Programming Language :: Python :: 3",
35+
"Programming Language :: Python :: 3.8",
36+
"Programming Language :: Python :: 3.9",
37+
"Programming Language :: Python :: 3.10",
38+
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
40+
"Programming Language :: Python :: 3.13",
41+
"Topic :: Software Development",
42+
"Topic :: Software Development :: Debuggers",
43+
"Topic :: Software Development :: Embedded Systems",
44+
"Topic :: Software Development :: Testing",
45+
"Topic :: Utilities",
46+
]
47+
dynamic = ["version"]
48+
dependencies = [
49+
"capstone>=5.0,<6.0",
50+
"cmsis-pack-manager>=0.5.2,<1.0",
51+
"colorama<1.0",
52+
"hidapi>=0.10.1,<1.0; platform_system != 'Linux'",
53+
"importlib_metadata>=3.6",
54+
"importlib_resources",
55+
"intelhex>=2.0,<3.0",
56+
"intervaltree>=3.0.2,<4.0",
57+
"lark>=1.1.5,<2.0",
58+
"libusb-package>=1.0,<2.0",
59+
"natsort>=8.0.0,<9.0",
60+
"prettytable>=2.0,<4.0",
61+
"pyelftools<1.0",
62+
"pylink-square>=1.0,<2.0",
63+
"pyusb>=1.2.1,<2.0",
64+
"pyyaml>=6.0,<7.0",
65+
"six>=1.15.0,<2.0",
66+
"typing-extensions>=4.0,<5.0",
67+
]
68+
69+
[project.optional-dependencies]
70+
pemicro = [
71+
"pyocd_pemicro>=1.0.6",
72+
]
73+
test = [
74+
"pytest>=6.2",
75+
"pytest-cov",
76+
"coverage",
77+
"flake8",
78+
"pylint",
79+
"tox",
80+
]
81+
82+
[project.scripts]
83+
pyocd = "pyocd.__main__:main"
84+
pyocd-gdbserver = "pyocd.tools.gdb_server:main"
85+
86+
[project.entry-points."pyocd.probe"]
87+
cmsisdap = "pyocd.probe.cmsis_dap_probe:CMSISDAPProbePlugin"
88+
jlink = "pyocd.probe.jlink_probe:JLinkProbePlugin"
89+
picoprobe = "pyocd.probe.picoprobe:PicoprobePlugin"
90+
remote = "pyocd.probe.tcp_client_probe:TCPClientProbePlugin"
91+
stlink = "pyocd.probe.stlink_probe:StlinkProbePlugin"
92+
93+
[project.entry-points."pyocd.rtos"]
94+
argon = "pyocd.rtos.argon:ArgonPlugin"
95+
freertos = "pyocd.rtos.freertos:FreeRTOSPlugin"
96+
rtx5 = "pyocd.rtos.rtx5:RTX5Plugin"
97+
threadx = "pyocd.rtos.threadx:ThreadXPlugin"
98+
zephyr = "pyocd.rtos.zephyr:ZephyrPlugin"
99+
100+
[project.urls]
101+
Website = "https://pyocd.io/"
102+
Documentation = "https://pyocd.io//docs"
103+
Source = "https://github.com/pyocd/pyOCD"
104+
Issues = "https://github.com/pyocd/pyOCD/issues"
105+
Discussions = "https://github.com/pyocd/pyOCD/discussions"
106+
Releases = "https://github.com/pyocd/pyOCD/releases"
107+
108+
[tool.setuptools]
109+
include-package-data = true
110+
111+
[tool.setuptools.packages.find]
112+
include = ["pyocd*"]
113+
114+
[tool.setuptools.package-data]
115+
pyocd = ["debug/svd/svd_data.zip"]
116+
117+
[tool.setuptools.cmdclass]
118+
build_py = "pyocd._build.build_py"
119+
sdist = "pyocd._build.sdist"
120+
12121
[tool.setuptools_scm]
13122
write_to = "pyocd/_version.py"
14123
local_scheme = "dirty-tag"
15124

125+
[tool.flake8]
126+
exclude = [
127+
"test_user_script.py",
128+
"gdb_test_script.py",
129+
]
130+
16131
[tool.pytest.ini_options]
17132
testpaths = ["test/unit"]
18133
junit_family = "xunit2"

setup.cfg

Lines changed: 0 additions & 114 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)