diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index de54237..27f9007 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -4,9 +4,6 @@ on: push: tags: - 'v*' - pull_request: - tags: - - 'v*' jobs: pypi-publish: @@ -14,26 +11,12 @@ jobs: runs-on: ubuntu-latest environment: release permissions: + # IMPORTANT: this permission is mandatory for trusted publishing id-token: write steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 with: - python-version: '3.x' - - - name: Install build dependencies - run: | - python -m pip install --upgrade pip - pip install build - - - name: Build package - run: python -m build - - - name: List dist directory contents - run: ls -la dist - + fetch-depth: 0 # We need all history to determine the version + - uses: pdm-project/setup-pdm@v4 - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + run: pdm publish diff --git a/.github/workflows/pytest-ubuntu.yaml b/.github/workflows/pytest-ubuntu.yaml index 78909b0..d421a82 100644 --- a/.github/workflows/pytest-ubuntu.yaml +++ b/.github/workflows/pytest-ubuntu.yaml @@ -1,25 +1,25 @@ -name: Python package +name: Tests on: [push, pull_request] jobs: test: - runs-on: ubuntu-latest + name: Run tests + runs-on: ubuntu-24.04 steps: - name: Check out the repository uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 + - name: Set up PDM + uses: pdm-project/setup-pdm@v4 with: - python-version: '3.x' + python-version: 3.13 - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install .[test] + pdm install -G test - name: Run tests run: | - pytest --doctest-modules + pdm run -v pytest --doctest-modules diff --git a/.gitignore b/.gitignore index f777e0b..46b8b54 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,8 @@ cython_debug/ # version _version.py + +# pdm +pdm.lock +.pdm-*/ +.pdm-* \ No newline at end of file diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 106fde7..4d6d482 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -7,9 +7,9 @@ version: 2 # Set the OS, Python version and other tools you might need build: - os: 'ubuntu-20.04' + os: 'ubuntu-22.04' tools: - python: "3.11" + python: "3.12" # Build documentation in the "docs/" directory with Sphinx sphinx: diff --git a/README.md b/README.md index 91cdb84..8ccab22 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,2 @@ # QuantSI Work in progress: unit system as used by the Brian2 simulator - -We will think of a better name before releasing… diff --git a/pyproject.toml b/pyproject.toml index 5c63d6a..01f512a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,17 @@ [project] name = "QuantSI" +description = "unit system as used by the Brian2 simulator" authors = [ - {name = 'Sorin Birchi'}, + {name = "Sorin Birchi"}, + {name = "Marcel Stimberg"}, + {name = "Dan Goodman"}, + {name = "Romain Brette"}, ] -requires-python = '>=3.10' -dependencies = [ - 'numpy>=1.23.5', - 'sympy>=1.2', - 'setuptools>=61' -] -dynamic = ["version", "readme"] -description = 'unit system as used by the Brian2 simulator' -keywords = ['computational neuroscience', 'simulation', 'system units'] +dependencies = ["numpy>=1.25", "sympy>=1.2"] +requires-python = ">=3.10" +readme = "README.md" +license = {text = "GPLv3"} +keywords = ['SI', 'SI units', 'unit system', 'physical quantities'] classifiers = [ 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', @@ -20,51 +20,34 @@ classifiers = [ 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering :: Bio-Informatics' + 'Topic :: Scientific/Engineering' ] +dynamic = ["version"] [project.optional-dependencies] -test = ['pytest', 'pytest-xdist>=1.22.3'] -docs = ['sphinx>=7', 'ipython>=5', 'sphinx-tabs'] - -[project.urls] -Documentation ='https://QuantSI.readthedocs.io/en/latest/' -Source = 'https://github.com/brian-team/QuantSI' -Tracker = 'https://github.com/brian-team/QuantSI/issues' - -[build-system] -requires = [ - "setuptools>=61", - "numpy>=2.0.0rc1", - "wheel", - "setuptools_scm[toml]>=6.2" +test = [ + "pytest>=8.3.4", + "pytest-xdist>=1.22.3", + "pdm-backend>=2.4.3", ] -build-backend = "setuptools.build_meta" - -[tool.setuptools] -zip-safe = false -include-package-data = true - -[tool.setuptools.packages.find] -include = ["QuantSI*"] - -[tool.setuptools.dynamic] -readme = {file = 'README.md', content-type = "text/markdown"} +docs = [ + "sphinx>=7", + "ipython>=5", + "sphinx-tabs>=3.4.7", +] +[build-system] +requires = ["pdm-backend"] +build-backend = "pdm.backend" -[tool.setuptools_scm] -version_scheme = 'post-release' -local_scheme = 'no-local-version' -write_to = 'QuantSI/_version.py' -fallback_version = 'unknown' +[tool.pdm] +distribution = true -[tool.black] -target-version = ['py310'] -include = '^/QuantSI/.*\.pyi?$' +[tool.pdm.version] +source = "scm" +tag_filter = "v*" +version_format = "src.version_helper:format_version" +write_to = "QuantSI/_version.py" +write_template = "__version__ = '{}'" -[tool.isort] -atomic = true -profile = "black" -py_version = "311" -skip_gitignore = true -# NOTE: isort has no "include" option, only "skip". -skip_glob = ["docs_sphinx/*"] +[tool.pytest.ini_options] +addopts = "-ra" \ No newline at end of file diff --git a/QuantSI/__init__.py b/src/QuantSI/__init__.py similarity index 99% rename from QuantSI/__init__.py rename to src/QuantSI/__init__.py index 3ac85d7..26226f8 100644 --- a/QuantSI/__init__.py +++ b/src/QuantSI/__init__.py @@ -3,6 +3,7 @@ """ # isort:skip_file +from ._version import __version__ from .allunits import ( # basic units diff --git a/QuantSI/allunits.py b/src/QuantSI/allunits.py similarity index 100% rename from QuantSI/allunits.py rename to src/QuantSI/allunits.py diff --git a/QuantSI/conftest.py b/src/QuantSI/conftest.py similarity index 100% rename from QuantSI/conftest.py rename to src/QuantSI/conftest.py diff --git a/QuantSI/constants.py b/src/QuantSI/constants.py similarity index 100% rename from QuantSI/constants.py rename to src/QuantSI/constants.py diff --git a/QuantSI/fundamentalunits.py b/src/QuantSI/fundamentalunits.py similarity index 100% rename from QuantSI/fundamentalunits.py rename to src/QuantSI/fundamentalunits.py diff --git a/QuantSI/stdunits.py b/src/QuantSI/stdunits.py similarity index 100% rename from QuantSI/stdunits.py rename to src/QuantSI/stdunits.py diff --git a/QuantSI/tests/__init__.py b/src/QuantSI/tests/__init__.py similarity index 100% rename from QuantSI/tests/__init__.py rename to src/QuantSI/tests/__init__.py diff --git a/QuantSI/tests/test_units.py b/src/QuantSI/tests/test_units.py similarity index 100% rename from QuantSI/tests/test_units.py rename to src/QuantSI/tests/test_units.py diff --git a/src/version_helper.py b/src/version_helper.py new file mode 100644 index 0000000..2903d6f --- /dev/null +++ b/src/version_helper.py @@ -0,0 +1,11 @@ +from pdm.backend.hooks.version import SCMVersion + +def format_version(version) -> str: + """ + Format the version number of the package. This function is only supposed to be + called by the pdm-backend to get the version number of the package. + """ + if version.distance is None: + return str(version.version) + else: + return f"{version.version}.post{version.distance}" \ No newline at end of file