Skip to content

Commit f3de622

Browse files
committed
pycommon: add pyproject.toml for modern Python packaging
1 parent 56ff6d7 commit f3de622

File tree

6 files changed

+89
-51
lines changed

6 files changed

+89
-51
lines changed

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
@@ -60,13 +60,16 @@ rm -rf %{pypi_name}.egg-info
6060

6161
%install
6262
# Must do the subpackages' install first because the scripts in /usr/bin are
63-
# overwritten with every setup.py install.
64-
%{__python3} setup.py install --skip-build --single-version-externally-managed --root %{buildroot}
63+
# overwritten with every install. TODO check
64+
%{__python3} -m pip install . --root %{buildroot} --no-deps --disable-pip-version-check --no-cache-dir --verbose
65+
6566
mkdir -p %{buildroot}/%{_sysconfdir}/nemea/email-templates/; cp reporter_config/default.html %{buildroot}/%{_sysconfdir}/nemea/email-templates/default.html
6667

6768

6869
%check
69-
%{__python3} setup.py test
70+
%{__python3} -m pip install .[test]
71+
%{__python3} -m pytest
72+
7073

7174
%files -n python%{python3_pkgversion}-%{pypi_name}
7275
%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.

0 commit comments

Comments
 (0)