Skip to content

Commit 36917b1

Browse files
authored
Merge pull request #239 from Dakevid/master
pytrap add pycommon: Migrate configuration to pyproject.toml
2 parents d267631 + dc8a4ca commit 36917b1

File tree

16 files changed

+249
-145
lines changed

16 files changed

+249
-145
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,4 @@ unirec/tests/test_speed_ur
7676
unirec/tests/test_speed_uro
7777
unirec/tests/test_template_cmp
7878
unirec/tests/test_time
79+
__pycache__

Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ ACLOCAL_AMFLAGS=-I m4
3030

3131
install-exec-hook:
3232
@echo -e "\n\n"
33-
@echo "For installation of Python components run the following commands as root:"
33+
@echo "For installation of Python components run the following commands:"
3434
@for i in ${PYTHON_SUBDIRS}; do \
35-
echo -e "(cd $${i}; ${PYTHON} setup.py install --record=installed-files.txt;)\n"; \
35+
echo -e "(pip install ./$${i})\n"; \
3636
done
3737
@echo -e "\n\n"
3838

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ Python parts must be installed separately when needed.
4444
It can be done using:
4545

4646
```
47-
cd pytrap; sudo python3 setup.py install
47+
pip install ./pytrap
4848
```
4949
and
5050
```
51-
cd pycommon; sudo python3 setup.py install
51+
pip install ./pycommon
5252
```
5353

5454
Project status:

pycommon/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
EXTRA_DIST=report2idea.py ip_prefix_search.py nemea-pycommon.spec setup.py README-RPM-release.md README reporter_config
1+
EXTRA_DIST=report2idea.py ip_prefix_search.py nemea-pycommon.spec pyproject.toml README-RPM-release.md README reporter_config
22

33
if MAKE_RPMS
44
RPMFILENAME=nemea-pycommon
55
.PHONY: rpm
66
rpm:
77
mkdir -p RPMBUILD/SOURCES
8-
python3 setup.py sdist
8+
python3 -m build --sdist
99
cp dist/*.tar.gz RPMBUILD/SOURCES
1010
rpmbuild -ba nemea-pycommon.spec --define "_topdir `pwd`/RPMBUILD"
1111
mv RPMBUILD/RPMS/*/*.rpm RPMBUILD/SRPMS/*.rpm dist/

pycommon/README

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
# About pycommon
1+
# pycommon
22

3-
The pycommon module contains functionality for NEMEA modules written in python.
4-
Currently, it is used by reporter modules.
3+
**pycommon** provides shared functionality for [NEMEA](https://github.com/CESNET/Nemea) modules written in Python.
4+
It is primarily used by reporter modules, but can be reused in other NEMEA-related Python projects.
55

6-
# Installation
6+
---
77

8-
Run as root:
8+
## Installation
99

10+
It is recommended to install using `pip`:
11+
12+
```bash
13+
pip install .
1014
```
11-
python3 setup.py install
15+
If you need to install for a specific Python interpreter (e.g., Python 3.9 vs. 3.11), run the above command with the corresponding interpreter:
16+
```bash
17+
python3.11 -m pip install .
1218
```
1319

14-
Note: for different versions of python, it is needed to perform this command
15-
separately for each of them.
1620

21+
---

pycommon/README-RPM-release.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
# How to release new version of RPM?
1+
# How to release a new version of the RPM?
2+
1. Bump the version in `pyproject.toml` and `*.spec`.
23

3-
1. bump version in `setup.py` and `*.spec`
4-
2. don't forget to commit and push with commit message
4+
2. Don't forget to commit and push with a commit message:
55

66
```
77
pycommon: increased version, released package
88
```
99

10-
3. create python src package using `python setup.py sdist`
10+
3. Create a Python source distribution:
11+
```bash
12+
python3 -m pip install build
13+
python3 -m build --sdist
14+
```
1115

12-
4. upload files in `dist/` using `twine`:
16+
4. Upload files in `dist/` using `twine`:
1317

1418
```
1519
twine upload ./*
1620
```
1721

18-
5. run `make rpm`
19-
6. your packages are in `RPMBUILD/`, build for other RPM-based systems can be done using:
22+
5. Run `make rpm`
23+
6. Your packages are in `RPMBUILD/`, build for other RPM-based systems can be done using:
2024

2125
```
2226
copr build @CESNET/NEMEA RPMBUILD/SRPMS/<package.src.rpm>

pycommon/nemea-pycommon.spec

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,16 @@ rm -rf %{pypi_name}.egg-info
6868

6969
%install
7070
# Must do the subpackages' install first because the scripts in /usr/bin are
71-
# overwritten with every setup.py install.
72-
%{__python3} setup.py install --skip-build --single-version-externally-managed --root %{buildroot}
71+
# overwritten with every install.
72+
%{__python3} -m pip install . --root %{buildroot} --no-deps --disable-pip-version-check --no-cache-dir --verbose
73+
7374
mkdir -p %{buildroot}/%{_sysconfdir}/nemea/email-templates/; cp reporter_config/default.html %{buildroot}/%{_sysconfdir}/nemea/email-templates/default.html
7475

7576

7677
%check
77-
%{__python3} setup.py test
78+
%{__python3} -m pip install .[test]
79+
%{__python3} -m pytest
80+
7881

7982
%files -n python%{python3_pkgversion}-%{pypi_name}
8083
%doc README

pycommon/pyproject.toml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "nemea-pycommon"
7+
version = "1.7.0"
8+
description = "Common Python modules and methods of the NEMEA system."
9+
readme = {text = "The module contains methods for creation and submission of incident reports in IDEA format.", content-type = "text/plain"}
10+
license = {text = "BSD"}
11+
authors = [
12+
{name = "Vaclav Bartos, CESNET", email = "[email protected]"},
13+
]
14+
maintainers = [
15+
{name = "Tomas Cejka", email = "[email protected]"},
16+
]
17+
requires-python = ">=3.6"
18+
dependencies = [
19+
"pynspect",
20+
"idea-format",
21+
"PyYAML",
22+
"ply",
23+
"jinja2",
24+
"redis",
25+
]
26+
classifiers = [
27+
"Development Status :: 4 - Beta",
28+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
29+
"Operating System :: POSIX",
30+
"Programming Language :: C",
31+
"Programming Language :: Python",
32+
"Programming Language :: Python :: 3",
33+
"Topic :: Software Development :: Libraries",
34+
"Topic :: System :: Networking :: Monitoring",
35+
]
36+
37+
38+
[project.optional-dependencies]
39+
test = [
40+
"pytest",
41+
"pytest-cov",
42+
]
43+
44+
45+
46+
[project.urls]
47+
Homepage = "https://github.com/CESNET/Nemea-Framework"
48+
49+
[tool.setuptools]
50+
py-modules = ["report2idea", "ip_prefix_search"]
51+
packages = ["reporter_config", "reporter_config.actions"]
52+
53+
54+
[tool.pytest.ini_options]
55+
testpaths = ["test"]
56+
python_files = ["*_unittest.py","rc_*.py"]
57+
addopts = ""

pycommon/setup.py

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

pytrap/Makefile.am

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: rpm
22

3-
EXTRA_DIST=MANIFEST.in README README.md test.sh nemea-pytrap.spec setup.py \
3+
EXTRA_DIST=MANIFEST.in README README.md test.sh nemea-pytrap.spec pyproject.toml \
44
src/pytrapmodule.c \
55
src/unirecmodule.c \
66
src/unirecipaddr.c \
@@ -15,7 +15,7 @@ EXTRA_DIST=MANIFEST.in README README.md test.sh nemea-pytrap.spec setup.py \
1515

1616
rpm:
1717
mkdir -p RPMBUILD/SOURCES
18-
python3 setup.py sdist
18+
python3 -m build --sdist
1919
cp dist/*.tar.gz RPMBUILD/SOURCES
2020
rpmbuild -ba nemea-pytrap.spec --define "_topdir `pwd`/RPMBUILD"
2121
mv RPMBUILD/RPMS/*/*.rpm RPMBUILD/SRPMS/*.rpm dist/
@@ -27,13 +27,13 @@ TESTS = test.sh
2727

2828
.PHONY: coverage
2929
coverage:
30-
CFLAGS=-coverage python setup.py build_ext --inplace
31-
CFLAGS=-coverage python3 setup.py build_ext --inplace
32-
python3 setup.py test || echo "Skipped python3 tests"
30+
CFLAGS=-coverage python3 -m pip install .[test] --no-deps --disable-pip-version-check --no-cache-dir
31+
CFLAGS=-coverage python3 -m pytest --cov=pycommon || echo "Skipped python3 tests"
3332
@lcov --capture --directory . --output-file coverage.info 2>/dev/null && \
3433
genhtml coverage.info --output-directory out 2>/dev/null || echo "Skipped coverage analysis"
3534

3635
.PHONY: doc
3736
doc:
38-
python3 setup.py build_sphinx
39-
37+
python3 -m pip install .[docs] --no-cache-dir
38+
cd docs
39+
make html

0 commit comments

Comments
 (0)