Skip to content

Commit 3333eaf

Browse files
stlehmannRobertoRoosRobert Roos
authored
Roberto roos feature/new setuptools (#469)
* Started migration to pyproject.toml, working on Windows * Adopted src/ layout * Moved requirements * Struggling to get pyproject.toml to work the same * Got sdist build to work as expected * Got windows/linux wheels to work * Got adslib source to be skipped in sdist build * Got package to work as wanted using MANIFEST.in * Changed adslib DLL finder logic * Added package CI * Replaced build by build_py + Cleanup, should work now for editable installs * Added test of produced artifacts * fixup! Got package to work as wanted using MANIFEST.in * Dropped Python 3.7 and lower, included up to Python 3.12 (#399) * Dropped Python 3.7 and lower, included up to Python 3.12 + Added Python requirement to setup.py * Updated checkout and setup-python Github workflows * CI: Unpin pytest version * Add setuptools to CI dependencies installation * Update email * Update programming language classifiers * Sync python versions for tox * Fix black exclude * Fix setup.py * Changelog update * Reformat Changelog --------- Co-authored-by: RobertoRoos <robert.soor@gmail.com> Co-authored-by: Robert Roos <robert.roos@demcon.com>
1 parent 1762027 commit 3333eaf

28 files changed

+323
-297
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[flake8]
22
max-line-length = 88
3+
ignore = F401, W503
4+
# flake8 cannot be configured through pyproject.toml

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ jobs:
2121

2222
steps:
2323
- name: Checkout repository and submodules
24+
uses: actions/checkout@v4
2425
uses: actions/checkout@v4
2526
with:
2627
submodules: recursive
2728
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
2830
uses: actions/setup-python@v5
2931
with:
3032
python-version: ${{ matrix.python-version }}
31-
- name: Install dependencies
33+
- name: Install package (with dependencies)
3234
run: |
3335
python -m pip install --upgrade pip
3436
python -m pip install flake8 pytest coverage coveralls pytest-cov setuptools

.github/workflows/packaging.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#
2+
# Test job to see how packaging looks like.
3+
#
4+
5+
name: Build distributions
6+
7+
on: [push, pull_request]
8+
9+
jobs:
10+
build_wheels:
11+
name: Build wheels on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
submodules: "true"
21+
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.12"
25+
26+
- run: |
27+
python -m pip install -U pip
28+
pip install build
29+
30+
- run: python -m build --wheel -vv
31+
- if: matrix.os == 'ubuntu-latest'
32+
run: python -m build --sdist -vv
33+
# We only need a single source distribution
34+
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
name: dist-${{ matrix.os }}
38+
retention-days: 1
39+
path: dist
40+
41+
make_artifact:
42+
name: Combine artifacts
43+
needs: build_wheels
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/download-artifact@v4
47+
with:
48+
path: dist
49+
merge-multiple: true
50+
# Download all artifacts so far
51+
- uses: actions/upload-artifact@v4
52+
with:
53+
name: package-all
54+
path: dist
55+
56+
test_artifacts:
57+
name: Test distributions
58+
needs: make_artifact
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
matrix:
62+
os: [ ubuntu-latest, macos-latest ]
63+
# Can't really test with Windows because 'TcAdsDll.dll' will be missing
64+
65+
steps:
66+
- uses: actions/download-artifact@v4
67+
with:
68+
name: package-all
69+
path: dist
70+
71+
- uses: actions/setup-python@v5
72+
with:
73+
python-version: "3.12"
74+
75+
# Now install the package from the local wheels and try to use it:
76+
- run: |
77+
pip install pyads --no-index --find-links ./dist
78+
python -c "import pyads; pyads.Connection(ams_net_id='127.0.0.1.1.1', ams_net_port=851)"
79+
80+
test_editable:
81+
name: Test editable install
82+
runs-on: ubuntu-latest
83+
84+
steps:
85+
- uses: actions/checkout@v4
86+
with:
87+
submodules: "true"
88+
89+
- uses: actions/setup-python@v5
90+
with:
91+
python-version: "3.12"
92+
93+
- run: |
94+
pip install -e . -vv
95+
python -c "import pyads; pyads.Connection(ams_net_id='127.0.0.1.1.1', ams_net_port=851)"

.github/workflows/python-publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ jobs:
1515
runs-on: ubuntu-latest
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1919
with:
2020
submodules: recursive
2121
- name: Set up Python
22-
uses: actions/setup-python@v2
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.x'
2525
- name: Install dependencies
2626
run: |
2727
python -m pip install --upgrade pip
28-
pip install setuptools wheel twine
28+
pip install build twine
2929
- name: Build and publish
3030
env:
3131
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
3232
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3333
run: |
34-
python setup.py sdist
34+
python -m build
3535
twine upload dist/*

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ build/
1212
*.egg-info/
1313
.eggs/
1414
venv/
15+
.venv/
16+
venv_*/
1517

1618
*.tox
1719
deploy.py

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77
## 3.5.1 (Unreleased)
88

99
### Added
10-
- [#462](https://github.com/stlehmann/pyads/issues/462) Short description on Linux build dependencies in docs
10+
* [#462](https://github.com/stlehmann/pyads/issues/462) Short description on Linux build dependencies in docs
11+
12+
### Changed
13+
* [#400](https://github.com/stlehmann/pyads/issues/400) Full support for pyproject.toml
1114

1215
## 3.5.0
1316

MANIFEST.in

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
include adslib/*
2-
include LICENSE
3-
include README.rst
1+
#
2+
# Recipe for extra files to pack for setuptools.
3+
# MANIFEST.in is a little outdated but the best solution to differentiate files between sdist and wheel builds.
4+
#
5+
6+
graft adslib
7+
global-exclude *.a *.o *.obj *.bin *.so
8+
prune obj
9+
prune tests

pyproject.toml

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,98 @@
1+
[project]
2+
name = "pyads"
3+
description = "Python wrapper for TwinCAT ADS library"
4+
authors = [
5+
{ name = "Stefan Lehmann", email = "stlm@posteo.de" },
6+
]
7+
readme = "README.md"
8+
classifiers = [
9+
"Development Status :: 4 - Beta",
10+
"Intended Audience :: Developers",
11+
"License :: OSI Approved :: MIT License",
12+
"Programming Language :: Python :: 3.8",
13+
"Programming Language :: Python :: 3.9",
14+
"Programming Language :: Python :: 3.10",
15+
"Programming Language :: Python :: 3.11",
16+
"Programming Language :: Python :: 3.12",
17+
"Topic :: Software Development :: Libraries",
18+
"Operating System :: Microsoft :: Windows",
19+
"Operating System :: POSIX :: Linux",
20+
]
21+
license = { text = "MIT" }
22+
dynamic = ["version"]
23+
dependencies = []
24+
25+
[project.optional-dependencies]
26+
docs = [
27+
"sphinx",
28+
"sphinx_rtd_theme",
29+
"recommonmark",
30+
]
31+
tests = [
32+
"pytest",
33+
"pytest-cov",
34+
"tox",
35+
]
36+
dev = [
37+
"build",
38+
"flake8",
39+
"pytest==7.4.4",
40+
"coverage",
41+
"coveralls",
42+
]
43+
44+
[project.urls]
45+
Repository = "https://github.com/stlehmann/pyads"
46+
Documentation = "https://pyads.readthedocs.io"
47+
48+
[build-system]
49+
requires = ["setuptools >= 61.0", "wheel"]
50+
build-backend = "setuptools.build_meta"
51+
52+
[tool.setuptools]
53+
packages = ["pyads", "pyads.testserver"]
54+
package-dir = { "" = "src" }
55+
include-package-data = true
56+
# ^ needed for MANIFEST.in
57+
58+
#[tool.setuptools.package-data]
59+
# Package data (adslib/) is handled by MANIFEST.in instead
60+
61+
[tool.setuptools.exclude-package-data]
62+
pyads = ["adslib/**"]
63+
# ^ Odd trick, put this excludes the adslib source again from a wheel build and from a pip install
64+
65+
[tool.setuptools.dynamic]
66+
version = {attr = "pyads.__version__"}
67+
68+
[tool.tox]
69+
legacy_tox_ini = """
70+
[tox]
71+
envlist = py38, py39, py310, py311, py312
72+
73+
[testenv]
74+
commands = discover
75+
deps = discover
76+
changedir = tests
77+
whitelist_externals=*
78+
passenv = TWINCAT3DIR
79+
80+
[pytest]
81+
testpaths = tests
82+
"""
83+
184
[tool.black]
285
line-length = 88
386
target-version = ['py38', 'py39', 'py310', 'py311', 'py312']
487
include = '\.pyi?$'
588
exclude = '''
6-
789
(
890
/(
9-
\.eggs
10-
| \.git
11-
| \.mypy_cache
12-
| \.tox
13-
| \.venv
91+
.eggs
92+
| .git
93+
| .mypy_cache
94+
| .tox
95+
| .venv
1496
| _build
1597
| buck-out
1698
| build
@@ -20,4 +102,11 @@ exclude = '''
20102
)/
21103
| pyads/__init__.py
22104
)
23-
'''
105+
'''
106+
107+
[tool.pydocstyle]
108+
ignore = ["D105", "D213", "D203", "D107"]
109+
110+
[tool.coverage.run]
111+
include = ["pyads/*"]
112+
omit = ["pyads/testserver/__main__.py"]

requirements.in

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

requirements.txt

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

0 commit comments

Comments
 (0)