Skip to content

Commit aded0e4

Browse files
authored
Merge pull request #81 from aleivag/semifull.pyproject.toml
Adding semi-full support for pyproyect.toml
2 parents 38f8ec8 + 53405e3 commit aded0e4

File tree

12 files changed

+73
-79
lines changed

12 files changed

+73
-79
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,12 @@ jobs:
1717
uses: actions/setup-python@v2
1818
with:
1919
python-version: ${{ matrix.python }}
20-
- name: Setup Cython
21-
run: |
22-
pip install -r requirements.txt Cython
23-
pip install Cython
2420
- name: Install dependencies
2521
run: sudo apt-get install -y libsystemd-dev
26-
- name: Build pystemd
27-
run: python setup.py sdist
2822
- name: Install pystemd
29-
run: pip install dist/pystemd*.tar.gz
23+
run: pip install -e '.[t]'
3024
- name: Run unit tests
31-
run: python -m unittest discover
32-
working-directory: ./tests
25+
run: pytest --cov=pystemd tests
3326

3427
formatting:
3528
runs-on: ubuntu-latest
@@ -40,8 +33,7 @@ jobs:
4033
uses: psf/black@stable
4134
- name: Run isort
4235
uses: isort/isort-action@v1
43-
with:
44-
sort-paths: "pystemd"
36+
4537

4638
typing:
4739
runs-on: ubuntu-latest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ tmtagsHistory
4242

4343
# Distribution / packaging
4444
.Python
45+
.pytest_cache/
46+
.mypy_cache/
47+
.coverage
4548
env/
4649
build/
4750
develop-eggs/

README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@ and then parsing the output to know the result.
1414
Show don't tell
1515
---------------
1616

17-
In software as in screenwriting, its better to show how things work instead of
17+
In software as in screenwriting, it's better to show how things work instead of
1818
tell. So this is how you would use the library from a interactive shell.
1919

2020
In [1]: from pystemd.systemd1 import Unit
2121
In [2]: unit = Unit(b'postfix.service')
2222
In [3]: unit.load()
2323

2424
Note: you need to call `unit.load()` because by default `Unit` will not load the
25-
unit information as that would require do some IO. You can auto load the unit by
26-
`Unit(b'postfix.service', _autoload=True)`
25+
unit information as that would require do some IO (and we dont like doing io on a class constructor).
26+
You can autoload the unit by `Unit(b'postfix.service', _autoload=True)` or using the unit as a
27+
contextmanager like `with Unit(b'postfix.service'): ...`
2728

2829
Once the unit is loaded, you can interact with it, you can do by accessing its
2930
systemd's interfaces:
@@ -246,14 +247,10 @@ v237.
246247
* gcc: or any compiler that `setup.py` will accept.
247248
* [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) command. Depending on your distro, the package is called "pkg-config", "pkgconfig" or a compatible substitute like "pkgconf"
248249

249-
if you want to install from source then after you clone this repo you need to
250+
if you want to install from source then after you clone this repo all you need to do its `pip install . `
250251

251-
```bash
252-
$ pip install -r requirements.txt # get six
253-
$ python3 setup.py install # only python3 supported
254-
```
255252

256-
but in addition to previous requirements you'll need:
253+
In addition to previous requirements you'll need:
257254

258255
* setuptools: Just use your distro's package (e.g. python-setuptools).
259256
* Cython: at least version 0.21a1, just pip install it or use the official

examples/future_cpucap_pool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from threading import Thread
66

77
import psutil
8-
98
from psutil import NoSuchProcess
109

1110
from pystemd.futures import TransientUnitPoolExecutor

examples/future_cpucap_process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import psutil
66
from psutil import NoSuchProcess
7+
78
from pystemd.futures import TransientUnitProcess
89

910

examples/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from itertools import chain
1111
from pprint import pprint
1212

13-
from pystemd.dbuslib import apply_signature, DBus
13+
from pystemd.dbuslib import DBus, apply_signature
1414

1515

1616
def monitor(*args):

examples/shell.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
import sys
1919
from pathlib import Path
2020

21+
from IPython.terminal.embed import InteractiveShellEmbed
22+
2123
import pystemd
2224
import pystemd.daemon
2325
import pystemd.journal
2426
import pystemd.run
25-
from IPython.terminal.embed import InteractiveShellEmbed
26-
2727

2828
display_banner = """
2929
Welcome to pystemd {pystemd.__version__} interactive shell for python {sys.version}.

pyproject.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,53 @@
1+
[build-system]
2+
requires = ["setuptools>=46.4.0", "wheel", "cython"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pystemd"
7+
version = "0.13.0"
8+
readme = "README.md"
9+
description="A systemd binding for python"
10+
dependencies = [
11+
"lxml",
12+
"psutil"
13+
]
14+
authors = [{name = "Alvaro Leiva Geisse", email = "aleivag@gmail.com"}]
15+
maintainers = [
16+
{name = "Alvaro Leiva Geisse", email = "aleivag@gmail.com"},
17+
{name = "Davide Cavalca", email = "dcavalca@meta.com"},
18+
{name = "Anita Zhang", email = "the.anitazha@gmail.com"}
19+
]
20+
classifiers = [
21+
"Operating System :: POSIX :: Linux",
22+
"Intended Audience :: Developers",
23+
"Intended Audience :: System Administrators",
24+
"Programming Language :: Python :: 3.6",
25+
"Programming Language :: Python :: 3.7",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Development Status :: 5 - Production/Stable",
31+
"Topic :: Utilities",
32+
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
33+
]
34+
license = { text = "LGPL-2.1+" }
35+
keywords = ["systemd", "linux", "dbus"]
36+
37+
[project.optional-dependencies]
38+
# Used for runing tests
39+
t = ["pytest", "pytest-cov"]
40+
lint = [
41+
"black",
42+
"mypi",
43+
"isort",
44+
]
45+
46+
[project.urls]
47+
changelog = "https://github.com/systemd/pystemd/blob/main/CHANGES.md"
48+
homepage = "https://github.com/systemd/pystemd"
49+
repository = "https://github.com/systemd/pystemd.git"
50+
151
[tool.mypy]
252
strict = false
353
packages = ["pystemd"]

requirements.txt

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

setup.py

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#
99

1010

11-
import ast
1211
import glob
1312
import subprocess
1413
import sys
@@ -36,25 +35,6 @@
3635
except ValueError:
3736
sys.exit("libsystemd version returned by pkg-config is not a plain integer!")
3837

39-
THIS_DIR = Path(__file__).parent
40-
41-
with (THIS_DIR / "README.md").open() as f:
42-
long_description = f.read()
43-
44-
# get and compute the version string
45-
version_file = THIS_DIR / "pystemd" / "__version__.py"
46-
with version_file.open() as f:
47-
parsed_file = ast.parse(f.read())
48-
49-
__version__ = [
50-
expr.value.s
51-
for expr in parsed_file.body
52-
if isinstance(expr, ast.Assign)
53-
and isinstance(expr.targets[0], ast.Name)
54-
and isinstance(expr.value, ast.Str)
55-
and expr.targets[0].id == "__version__"
56-
][0]
57-
5838
# Use C extensions if respective files are present. Else let Cython modules be
5939
# compiled to C code. The latter is the case when using a clone of the git
6040
# repository, unlike the source distribution which includes both .pyx and .c
@@ -80,42 +60,17 @@
8060
else:
8161
raise RuntimeError("Cython not installed.")
8262

83-
package_data = []
84-
package_data.extend(glob.glob("pystemd/*.pyi"))
85-
package_data.extend(glob.glob("pystemd/*/*.pyi"))
8663

8764
setup(
8865
name="pystemd",
89-
version=__version__,
66+
version="0.13.0",
67+
author="Alvaro Leiva Geisse",
68+
author_email="aleivag@gmail.com",
9069
packages=["pystemd", "pystemd.systemd1", "pystemd.machine1", "pystemd.DBus"],
91-
author="Alvaro Leiva",
92-
author_email="aleivag@meta.com",
9370
ext_modules=external_modules,
94-
url="https://github.com/systemd/pystemd",
95-
classifiers=[
96-
"Operating System :: POSIX :: Linux",
97-
"Intended Audience :: Developers",
98-
"Intended Audience :: System Administrators",
99-
"Programming Language :: Python :: 3.6",
100-
"Programming Language :: Python :: 3.7",
101-
"Programming Language :: Python :: 3.8",
102-
"Programming Language :: Python :: 3.9",
103-
"Programming Language :: Python :: 3.10",
104-
"Programming Language :: Python :: 3.11",
105-
"Development Status :: 5 - Production/Stable",
106-
"Topic :: Utilities",
107-
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
108-
],
109-
keywords=["systemd"],
110-
description="A systemd binding for python",
11171
package_data={
112-
"pystemd": [str(Path(p).relative_to("pystemd")) for p in package_data]
72+
"pystemd": [
73+
str(Path(p).relative_to("pystemd")) for p in glob.glob("pystemd/**/*.pyi")
74+
]
11375
},
114-
install_requires=[
115-
"lxml",
116-
"psutil",
117-
],
118-
long_description=long_description,
119-
long_description_content_type="text/markdown",
120-
license="LGPL-2.1+",
12176
)

0 commit comments

Comments
 (0)