build: switch setup.py to pyproject.toml - #16
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates nvmetcli’s Python packaging metadata from a legacy setup.py-driven build to a PEP 517/518 + PEP 621 pyproject.toml configuration.
Changes:
- Removed
setup.pyto eliminate the legacy setuptools entrypoint. - Added
pyproject.tomlwith setuptools build backend and project metadata (incl. runtime/test dependencies).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| setup.py | Deleted legacy setuptools packaging script. |
| pyproject.toml | Introduces PEP 517/518 build config and PEP 621 project metadata, including dependencies and script packaging. |
Suppressed comments (2)
pyproject.toml:12
requires-python = ">=3.6"declares Python 3-only support, but the existing packaging scripts still usepython setup.py ...(Debian rules even uses--with python2) and the installed script shebang is/usr/bin/python. This mismatch can lead to building/installing against Python 2 or an arbitrary defaultpython, which will fail given the code uses Python 3-only syntax (e.g. f-strings).
license = { text = "Apache 2.0" }
requires-python = ">=3.6"
maintainers = [
pyproject.toml:23
- The
testextra only includesnose2, butmake testrunspython3 -m nose2 ... --coverage, which requires thecoveragemodule to be installed. Addcoverageto thetestoptional dependencies so a standardpip install .[test]is sufficient to run the test target.
[project.optional-dependencies]
test = [
"nose2"
]
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Suppressed comments (5)
rpm/nvmetcli.spec.tmpl:30
pip3 install ... .will, by default, resolve/install runtime deps and may also perform an isolated PEP 517 build (downloading build deps). That is undesirable/broken in offline RPM builds and duplicates dependency management already handled by RPM. Add--no-deps --no-build-isolationhere. Also note that pip/setuptools will install scripts under the prefix’s bin dir (typically/usr/bin), so the%filesentry should match that path (it currently lists/usr/sbin/nvmetcli).
pip3 install --root=%{buildroot} --prefix=usr .
debian/rules:17
pip3 installwill try to resolve/install dependencies and may trigger an isolated PEP 517 build, which can attempt network access (blocked viahttp_proxy). For Debian packaging, dependencies should come from Build-Depends/Depends instead. Add--no-deps --no-build-isolationto make the build reproducible/offline-friendly.
pip3 install --root=$(install_dir) --prefix=/usr .
pyproject.toml:19
- Installing the CLI via
script-filespreserves the script’s original shebang. Thenvmetcliscript currently starts with#!/usr/bin/python, which can resolve to Python 2 on some systems, conflicting withrequires-python = ">=3.6". Consider switching to a console-script entry point (preferred) or updating thenvmetcliscript shebang topython3to ensure the installed command always uses Python 3.
[tool.setuptools]
packages = ["nvmet"]
script-files = ["nvmetcli"]
rpm/nvmetcli.spec.tmpl:26
python3 -m builduses PEP 517 build isolation by default and will try topip installbuild requirements into a temp env. In distro package builds (often offline), this commonly fails. Use--no-isolation(and ensure build requirements are provided by BuildRequires/Build-Depends) to keep builds deterministic.
This issue also appears on line 30 of the same file.
%{__python3} -m build
debian/rules:14
python3 -m builduses build isolation by default and will try to install build requirements via pip in a temporary env. Withhttp_proxyset to block network access, this is likely to fail. Add--no-isolationand rely on Build-Depends to provide build requirements.
This issue also appears on line 17 of the same file.
python3 -m build
f981d08 to
7414862
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Suppressed comments (7)
debian/rules:17
pip3 installmay attempt dependency resolution / downloads and may use build isolation. Since the rules file explicitly blocks network access, add--no-deps --no-build-isolation --no-indexto make the install step deterministic/offline.
pip3 install --root=$(install_dir) --prefix=/usr .
rpm/nvmetcli.spec.tmpl:26
python3 -m builddefaults to build isolation, which may try to download build requirements during RPM builds (typically offline). Consider disabling isolation and relying onBuildRequiresinstead.
%{__python3} -m build
rpm/nvmetcli.spec.tmpl:30
- The
%installstep usespip3 install ... ., which can trigger dependency resolution and rebuilds. Installing the wheel produced in%buildwith--no-deps --no-index --no-build-isolationis more deterministic and avoids network access.
pip3 install --root=%{buildroot} --prefix=usr .
rpm/nvmetcli.spec.tmpl:11
pyproject.tomldeclares build-system requirements onsetuptoolsandwheel, but the RPMBuildRequireslist does not include distro packages for them. This can make offline builds fail if build isolation is disabled or if the build frontend cannot provision build requirements.
This issue also appears in the following locations of the same file:
- line 26
- line 30
BuildRequires: python3-devel python3-pip python3-build systemd-units
debian/control:10
debian/rulesswitches to--with python3, butdebian/controlstill uses${python:Depends}. With dh-python for Python 3, the substvar is${python3:Depends}; leaving${python:Depends}will typically result in missing runtime deps.
Depends: ${misc:Depends}, ${python:Depends}, python-configshell-fb
debian/rules:14
python3 -m builddefaults to build isolation, which can cause attempts to fetch build requirements. Since this packaging explicitly blocks network access, pass--no-isolationand rely on distro-provided build requirements instead.
This issue also appears on line 17 of the same file.
python3 -m build
nvmet/nvme.py:293
- Falling back to
modprobewhen/proc/sys/kernel/modprobeexists but is empty changes behavior: an empty value is commonly used to disable module autoloading via modprobe. It’s safer to treat an empty file as “do not attempt to load modules” rather than falling back tomodprobe.
modprobe_cmd = 'modprobe'
try:
with open('/proc/sys/kernel/modprobe', 'r', encoding="utf-8") as f:
modprobe_cmd = f.read().strip() or modprobe_cmd
except OSError:
960489e to
ea9383b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.
Suppressed comments (5)
debian/control:10
debian/rulesswitches todh ... --with python3, butdebian/controlstill uses${python:Depends}. Withdh-pythonin Python 3 mode this substitution variable is not provided, which can break dependency generation. Consider also aligning the configshell dependency name with the Python 3 package in your distro.
Depends: ${misc:Depends}, ${python:Depends}, python-configshell-fb
debian/rules:18
pip3 installduring Debian package builds should be prevented from resolving/downloading dependencies and from creating an isolated build env (which can trigger network access). Add--no-deps --no-build-isolationand preferpython3 -m pipfor consistency.
override_dh_auto_install:
pip3 install --root=$(install_dir) --prefix=/usr .
rpm/nvmetcli.spec.tmpl:31
- In the RPM spec,
pip3 install --prefix=usruses a relative prefix, which can install files under an unexpected path. Also, RPM builds should avoid dependency resolution / build isolation to prevent network access and ensure reproducible builds.
%install
rm -rf %{buildroot}
pip3 install --root=%{buildroot} --prefix=usr .
mkdir -p %{buildroot}%{_sysconfdir}/nvmet
README:54
- Minor grammar: "simple run" should be "simply run".
coverage installed and simple run 'make test'. To run all
nvmet/test_nvmet.py:31
_usable_devices()can raiseOSError/PermissionErrorfromos.stat()even afteros.path.exists()returns true (e.g., permission issues or races). Treat such paths as unusable instead of crashing the tests.
return [x for x in NVMET_TEST_DEVICES
if os.path.exists(x) and
(stat.S_ISBLK(os.stat(x).st_mode) or os.path.isfile(x))]
Update debian/rules, rpm/nvmetcli.spec.tmpl, README, and bump-ver.sh to use python3 -m build / pip3 install instead of setup.py, since setup.py has been replaced by pyproject.toml. Signed-off-by: Ales Novak <alnovak@suse.com> Signed-off-by: Daniel Wagner <wagi@monom.org>
Verify that building the project with the PEP 517/518 tooling works. Signed-off-by: Daniel Wagner <wagi@monom.org>
The python-kmod project has been abandoned for a while. Remove the dependency and just use the 'modprobe' approach. Signed-off-by: Daniel Wagner <wagi@monom.org>
Support for the nose2 coverage plugin is gradually being removed. Signed-off-by: Daniel Wagner <wagi@monom.org>
Previously test_namespace_attrs and test_save_restore were skipped outright when NVMET_TEST_DEVICES (default /dev/ram0,/dev/ram1) were not present. Add get_test_devices(), which prefers configured/present devices but falls back to creating 512M sparse temp files for any that are missing. Signed-off-by: Daniel Wagner <wagi@monom.org>
While at it also add a build workflow and remove the kmod python binding and more build fixes.
Fixes: #11 #15