Skip to content

Commit

Permalink
Refactor dependency management to pyproject.toml
Browse files Browse the repository at this point in the history
Previously, our dependency management was a bit of
a mess. We had both a `requirements.txt` and a
`pyproject.toml` and some dependencies were only
defined in one but not the other.

This aims to fix this mess and refactor towards
only using `pyproject.toml` to define the
dependencies.

At the same time, we also clean up the install
process, which now works by simply calling
`pip install .` or `pip install -e .[dev]` for the
developer envrionment.

Furthermore, we configure the already introduced
`setuptools_scm` to automatically infer a version
based on the most recent git tag.
  • Loading branch information
s-heppner committed Oct 11, 2024
1 parent 47f5e61 commit 5087670
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 32 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ env:

jobs:
test:
# This job runs the unittests on the python versions specified down at the matrix
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.10", "3.12"]
env:
COUCHDB_ADMIN_PASSWORD: "yo0Quai3"
AAS_SPECS_RELEASE_TAG: "V3.0.7"
# (2024-10-11, s-heppner)
# Specify the tag of the released schema files from https://github.com/admin-shell-io/aas-specs/releases
# that you want to use to test the serialization adapter against.
# Currently, we need to update this manually, however I'm afraid this is not possible to automatically infer,
# since it's heavily dependant of the version of the AAS specification we support.
AAS_SPECS_RELEASE_TAG: "IDTA-01001-3-0-1_schemasV3.0.8"
services:
couchdb:
image: couchdb:3
Expand All @@ -22,7 +28,6 @@ jobs:
env:
COUCHDB_USER: "admin"
COUCHDB_PASSWORD: ${{ env.COUCHDB_ADMIN_PASSWORD }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -37,8 +42,7 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install coverage
pip install -r requirements.txt
pip install .[dev]
- name: Setup test config and CouchDB database server
run: |
python test/_helper/setup_testdb.py -u "admin" -p "$COUCHDB_ADMIN_PASSWORD"
Expand All @@ -51,8 +55,8 @@ jobs:
coverage report -m
static-analysis:
# This job runs static code analysis, namely pycodestyle and mypy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
Expand All @@ -62,8 +66,7 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pycodestyle mypy
pip install -r requirements.txt
pip install .[dev]
- name: Check typing with MyPy
run: |
mypy basyx test
Expand All @@ -72,8 +75,8 @@ jobs:
pycodestyle --count --max-line-length 120 basyx test
readme-codeblocks:
# This job runs the same static code analysis (mypy and pycodestyle) on the codeblocks in our docstrings.
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
Expand All @@ -83,8 +86,7 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pycodestyle mypy codeblocks
pip install -r requirements.txt
pip install .[dev]
- name: Check typing with MyPy
run: |
mypy <(codeblocks python README.md)
Expand All @@ -96,8 +98,8 @@ jobs:
codeblocks python README.md | python
docs:
# This job checks, if the automatically generated documentation using sphinx can be compiled
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
Expand All @@ -107,15 +109,15 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install .
pip install -r docs/add-requirements.txt
- name: Check documentation for errors
run: |
SPHINXOPTS="-a -E -n -W --keep-going" make -C docs html
package:
# This job checks if we can build our SDK package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.X_PYTHON_VERSION }}
Expand All @@ -125,7 +127,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel build
pip install .
- name: Create source and wheel dist
run: |
python -m build
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:

jobs:
publish:
# This job publishes the package to PyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
Expand All @@ -17,10 +17,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install build
- name: Create source and wheel dist
run: |
python setup.py sdist bdist_wheel
python -m build
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@
/test/test_config.ini
# Schema files needed for testing
/test/adapter/schemas

# Ignore dynamically generated version file
basyx/version.py
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Additionally, we use [PEP 484 -- Type Hints](https://www.python.org/dev/peps/pep
Before submitting any changes, make sure to let `mypy` and `pycodestyle` check your code and run the unit tests with
Python's builtin `unittest`. To install the required tools, use:
```bash
pip install mypy pycodestyle
pip install .[dev]
```

Running all checks:
Expand Down
30 changes: 26 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"]
requires = [
"setuptools>=45",
"wheel",
"setuptools_scm[toml]>=6.2"
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
# Configure setuptools_scm for version management:
# - Automatically infers the version number from the most recent git tag
# - Generates a version.py file in the package directory
# - Allows for automatic versioning between releases (e.g., 1.0.1.dev4+g12345)
# If you want to use the version anywhere in the code, use
# ```
# from basyx.version import version
# print(f"Project version: {version}")
# ```
write_to = "basyx/version.py"

[project]
name = "basyx-python-sdk"
version = "1.0.0"
dynamic = ["version"]
description = "The Eclipse BaSyx Python SDK, an implementation of the Asset Administration Shell for Industry 4.0 systems"
authors = [
{ name = "The Eclipse BaSyx Authors", email = "[email protected]" }
Expand All @@ -19,10 +35,16 @@ classifiers = [
]
requires-python = ">=3.8"
dependencies = [
"python-dateutil>=2.8,<3",
"jsonschema~=4.7",
"lxml>=4.2,<5",
"python-dateutil>=2.8,<3",
"types-python-dateutil",
"pyecma376-2>=0.2.4",
"urllib3>=1.26,<3",
"pyecma376-2>=0.2.4"
"Werkzeug>=3.0.3,<4",
"schemathesis~=3.7",
"hypothesis~=6.13",
"lxml-stubs~=0.5.1",
]

[project.optional-dependencies]
Expand Down
10 changes: 0 additions & 10 deletions requirements.txt

This file was deleted.

0 comments on commit 5087670

Please sign in to comment.