Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated setuptools with adslib in wheel distribution and pyproject.toml #426

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
max-line-length = 88
ignore = F401, W503
# flake8 cannot be configured through pyproject.toml
15 changes: 4 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,17 @@ jobs:

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install package (with dependencies)
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest==7.4.4 coverage coveralls pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build adslib
run: |
python setup.py build
- name: Install package
run: |
python setup.py develop
pip install .[tests,dev]
- name: Test with pytest
run: |
pytest -v --cov pyads
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# Test job to see how packaging looks like.
#

name: Build distributions

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v4
with:
submodules: "true"

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- run: |
python -m pip install -U pip
pip install build

- run: python -m build --wheel -vv
- if: matrix.os == 'ubuntu-latest'
run: python -m build --sdist -vv
# We only need a single source distribution

- uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.os }}
retention-days: 1
path: dist

make_artifact:
name: Combine artifacts
needs: build_wheels
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
# Download all artifacts so far
- uses: actions/upload-artifact@v4
with:
name: package-all
path: dist

test_artifacts:
name: Test distributions
needs: make_artifact
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
# Can't really test with Windows because 'TcAdsDll.dll' will be missing

steps:
- uses: actions/download-artifact@v4
with:
name: package-all
path: dist

- uses: actions/setup-python@v5
with:
python-version: "3.12"

# Now install the package from the local wheels and try to use it:
- run: |
pip install pyads --no-index --find-links ./dist
python -c "import pyads; pyads.Connection(ams_net_id='127.0.0.1.1.1', ams_net_port=851)"

test_editable:
name: Test editable install
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: "true"

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- run: |
pip install -e . -vv
python -c "import pyads; pyads.Connection(ams_net_id='127.0.0.1.1.1', ams_net_port=851)"
8 changes: 4 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
python -m build
twine upload dist/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ build/
*.egg-info/
.eggs/
venv/
.venv/
venv_*/

*.tox
deploy.py
Expand Down
12 changes: 9 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
include adslib/*
include LICENSE
include README.rst
#
# Recipe for extra files to pack for setuptools.
# MANIFEST.in is a little outdated but the best solution to differentiate files between sdist and wheel builds.
#

graft adslib
global-exclude *.a *.o *.obj *.bin *.so
prune obj
prune tests
12 changes: 0 additions & 12 deletions PKG-INFO

This file was deleted.

107 changes: 97 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,96 @@
[project]
name = "pyads"
description = "Python wrapper for TwinCAT ADS library"
authors = [
{ name = "Stefan Lehmann", email = "[email protected]" },
]
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Software Development :: Libraries",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
]
license = { text = "MIT" }
dynamic = ["version"]
dependencies = []

[project.optional-dependencies]
docs = [
"sphinx",
"sphinx_rtd_theme",
"recommonmark",
]
tests = [
"pytest",
"pytest-cov",
"tox",
]
dev = [
"build",
"flake8",
"pytest==7.4.4",
"coverage",
"coveralls",
]

[project.urls]
Repository = "https://github.com/stlehmann/pyads"
Documentation = "https://pyads.readthedocs.io"

[build-system]
requires = ["setuptools >= 61.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["pyads", "pyads.testserver"]
package-dir = { "" = "src" }
include-package-data = true
# ^ needed for MANIFEST.in

#[tool.setuptools.package-data]
# Package data (adslib/) is handled by MANIFEST.in instead

[tool.setuptools.exclude-package-data]
pyads = ["adslib/**"]
# ^ Odd trick, put this excludes the adslib source again from a wheel build and from a pip install

[tool.setuptools.dynamic]
version = {attr = "pyads.__version__"}

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37, py38, py39, py310

[testenv]
commands = discover
deps = discover
changedir = tests
whitelist_externals=*
passenv = TWINCAT3DIR

[pytest]
testpaths = tests
"""

[tool.black]
line-length = 88
target-version = ['py37', 'py38', 'py39', 'py310']
include = '\.pyi?$'
exclude = '''

target-version = ["py37", "py38", "py39", "py310"]
include = ".pyi?$"
exclude = """
(
/(
\.eggs
| \.git
| \.mypy_cache
| \.tox
| \.venv
.eggs
| .git
| .mypy_cache
| .tox
| .venv
| _build
| buck-out
| build
Expand All @@ -20,4 +100,11 @@ exclude = '''
)/
| pyads/__init__.py
)
'''
"""

[tool.pydocstyle]
ignore = ["D105", "D213", "D203", "D107"]

[tool.coverage.run]
include = ["pyads/*"]
omit = ["pyads/testserver/__main__.py"]
4 changes: 0 additions & 4 deletions requirements.in

This file was deleted.

Loading