Skip to content

Commit c190994

Browse files
committed
With setuptools changes, it is increasingly hard to build using bdist_rpm or test using setuptools.
The setuptools 69.3.0 started to change dashes to underscores, leading to + /usr/lib/rpm/rpmuncompress -x -v /src/build/bdist.linux-x86_64/rpm/SOURCES/python-libssh-0.0.1.tar.gz error: File /src/build/bdist.linux-x86_64/rpm/SOURCES/python-libssh-0.0.1.tar.gz: No such file or directory error: Bad exit status from /var/tmp/rpm-tmp.deAYuh (%prep) pypa/setuptools#3593 The setuptools 72.0.2 removed setup.py test command, leading to /usr/lib/python3.13/site-packages/setuptools/_distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_suite' warnings.warn(msg) usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: invalid command 'test' pypa/setuptools#4519
1 parent a43e344 commit c190994

File tree

7 files changed

+109
-14
lines changed

7 files changed

+109
-14
lines changed

Diff for: .github/workflows/build-test.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ jobs:
1717
os:
1818
- registry.fedoraproject.org/fedora:latest
1919
- registry.fedoraproject.org/fedora:rawhide
20-
- docker.io/almalinux:8
21-
- quay.io/centos/centos:stream9
2220
steps:
2321
- uses: actions/checkout@v4
2422
- name: Set the right OS in the Dockerfile
@@ -27,7 +25,7 @@ jobs:
2725
run: docker build -t python-libssh -f tests/Dockerfile .
2826
- name: Run container
2927
run: docker run --name python-libssh --rm -d python-libssh
30-
- name: Run tests in the container
31-
run: docker exec python-libssh python3 setup.py test
32-
- name: Run tests with installed rpm
28+
- name: Run tests with unittest discover
29+
run: docker exec python-libssh python3 -m unittest discover -v -s tests -p 't*_*.py'
30+
- name: Run tests manually
3331
run: docker exec python-libssh bash -c 'cp -rp tests /tmp/tests && cd /tmp/tests && for i in *.py ; do python3 -Werror $i ; done'

Diff for: Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
11

2+
NAME = python-$(shell eval echo $$( awk '/^name/ { print $$NF }' pyproject.toml))
3+
VERSION = $(shell eval echo $$( awk '/^version/ { print $$NF }' pyproject.toml))
4+
DIST = dist
5+
SPECFILE = $(NAME).spec
6+
7+
tar-gz:
8+
rm -rf $(DIST)/$(NAME)-$(VERSION)
9+
mkdir -p $(DIST)/$(NAME)-$(VERSION)
10+
cp -rp -t dist/$(NAME)-$(VERSION) $(shell ls | grep -v dist)
11+
for i in $(shell cat .gitignore) ; do rm -rf $(DIST)/$$i ; done
12+
tar -C $(DIST) -cvzf $(DIST)/$(NAME)-$(VERSION).tar.gz $(NAME)-$(VERSION)
13+
rm -rf $(DIST)/$(NAME)-$(VERSION)
14+
ls -l $(DIST)/*.tar.gz
15+
16+
srpm: tar-gz
17+
rpmbuild -D '_srcrpmdir $(DIST)' -D '_sourcedir $(DIST)' -bs $(SPECFILE)
18+
ls -l $(DIST)/*.src.rpm
19+
20+
dynamic-build-requires: tar-gz
21+
rpmbuild -D '_srcrpmdir $(DIST)' -D '_sourcedir $(PWD)/$(DIST)' -br $(SPECFILE)
22+
23+
rpm: tar-gz
24+
rpmbuild -D '_rpmdir $(DIST)' -D '_sourcedir $(PWD)/$(DIST)' -bb $(SPECFILE)
25+
mv $(DIST)/$$(uname -m)/*.$$(uname -m).rpm $(DIST)
26+
ls -l $(DIST)/*.$$(uname -m).rpm
27+
# rpm -qlp $(DIST)/*.$$(uname -m).rpm
28+
# rpm -q --requires -p $(DIST)/*.$$(uname -m).rpm
29+
30+
test:
31+
./test.sh
32+
33+
test-pylint:
34+
pylint-3 --disable=R --disable=C --indent-string="\t" --extension-pkg-whitelist=rpm,lxml libssh.pyx
35+
236
clean:
337
rm -rf $(shell cat .gitignore)
438

39+
.PHONY: tar-gz srpm rpm test test-pylint clean
40+

Diff for: README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
Build the extension with
77
```
8+
make rpm
9+
rpm -Uvh dist/python-libssh*.rpm
10+
```
11+
or
12+
```
813
python3 setup.py build_ext --inplace
914
```
1015

@@ -16,12 +21,16 @@ In other words, `ssh localhost true` needs to work.
1621

1722
Test it with
1823
```
24+
python3 -m unittest discover -v -s tests -p 't*_*.py'
25+
```
26+
or
27+
```
1928
python3 setup.py test
2029
```
2130

2231
## Author
2332

24-
Written by Jan Pazdziora, 2019
33+
Written by Jan Pazdziora, 2019--2024
2534

2635
## License
2736

Diff for: pyproject.toml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
[project]
3+
name = "libssh"
4+
version = "0.0.1"
5+
authors = [{name = "Jan Pazdziora"}]
6+
license = {text = "GNU Lesser General Public License v2 (LGPLv2)"}
7+
description = "Python bindings to client functionality of libssh"
8+
classifiers = [
9+
"Development Status :: 2 - Pre-Alpha",
10+
"License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
11+
"Topic :: Security",
12+
]
13+
14+
[build-system]
15+
requires = ["setuptools", "Cython"]
16+
build-backend = "setuptools.build_meta"
17+
18+
[tool.setuptools]
19+
packages = ["libssh"]
20+
package-dir = {"libssh" = "."}
21+

Diff for: python-libssh.spec

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
Name: python-libssh
3+
Version: 0.0.1
4+
Release: 1%{?dist}
5+
6+
Summary: Python bindings to client functionality of libssh
7+
License: LGPLv2
8+
URL: https://github.com/adelton/python-libssh
9+
Source0: %{name}-%{version}.tar.gz
10+
11+
BuildRequires: libssh-devel
12+
BuildRequires: python3-devel
13+
BuildRequires: python3-wheel
14+
15+
%description
16+
Python bindings to client functionality of libssh.
17+
18+
%prep
19+
%autosetup
20+
21+
%generate_buildrequires
22+
%pyproject_buildrequires -p
23+
24+
%build
25+
%pyproject_wheel
26+
27+
%install
28+
%pyproject_install
29+
30+
%pyproject_save_files -l libssh
31+
32+
%files -f %{pyproject_files}
33+

Diff for: setup.py

-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
from setuptools.extension import Extension
99
from Cython.Build import cythonize
1010

11-
import unittest
12-
def get_tests():
13-
return unittest.TestLoader().discover("tests", pattern="*.py")
14-
1511
setup(
1612
name = "python-libssh",
1713
version = "0.0.1",
@@ -24,6 +20,5 @@ def get_tests():
2420
"License :: OSI Approved :: GNU Lesser General Public License v2 (LGPLv2)",
2521
"Topic :: Security",
2622
],
27-
test_suite = "setup.get_tests",
2823
)
2924

Diff for: tests/Dockerfile

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN if test -f /etc/almalinux-release && grep 'AlmaLinux release 8' /etc/almalin
44
dnf config-manager --set-enabled powertools ; fi
55
RUN if test -f /etc/centos-release && grep 'CentOS Stream release 9' /etc/centos-release ; then \
66
dnf config-manager --set-enabled crb ; fi
7-
RUN dnf install -y --setopt=install_weak_deps=False python3-devel python3-setuptools python3-Cython make gcc libssh-devel openssh-server openssh-clients rpm-build
7+
RUN dnf install -y --setopt=install_weak_deps=False openssh-server openssh-clients make rpm-build gcc
88
RUN if test -f /etc/nsswitch.conf ; then grep hosts: /etc/nsswitch.conf && sed -i 's/^hosts:.*/hosts: files dns myhostname/' /etc/nsswitch.conf ; fi
99
RUN echo 'set enable-bracketed-paste off' >> ~root/.inputrc
1010
RUN for i in rsa ecdsa ed25519 ; do /usr/libexec/openssh/sshd-keygen $i ; done
@@ -16,7 +16,10 @@ RUN yes | ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
1616
RUN cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys && chmod 400 ~/.ssh/authorized_keys
1717
COPY . /src/
1818
WORKDIR /src
19-
RUN python3 setup.py build_ext --inplace
20-
RUN python3 setup.py bdist_rpm
19+
RUN if ! dnf --version | grep '^dnf5' ; then dnf install -y 'dnf-command(builddep)' ; fi
20+
RUN dnf builddep -y python-libssh.spec
21+
RUN make dynamic-build-requires || dnf builddep -y dist/*.buildreqs.nosrc.rpm
22+
RUN make rpm
23+
# RUN dnf install -y dist/python-libssh*.rpm
2124
RUN rpm -Uvh dist/python-libssh*.rpm
2225
ENTRYPOINT [ "/usr/sbin/sshd", "-D" ]

0 commit comments

Comments
 (0)