Skip to content

Commit

Permalink
Merge pull request #9 from brian-team/infra_updates
Browse files Browse the repository at this point in the history
Infrastructure updates
  • Loading branch information
mstimberg authored Feb 7, 2025
2 parents 2883ffc + da987f7 commit b36fa9e
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 85 deletions.
27 changes: 5 additions & 22 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,19 @@ on:
push:
tags:
- 'v*'
pull_request:
tags:
- 'v*'

jobs:
pypi-publish:
name: upload release to PyPI
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
run: pdm publish
16 changes: 8 additions & 8 deletions .github/workflows/pytest-ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,8 @@ cython_debug/

# version
_version.py

# pdm
pdm.lock
.pdm-*/
.pdm-*
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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…
85 changes: 34 additions & 51 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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"
1 change: 1 addition & 0 deletions QuantSI/__init__.py → src/QuantSI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

# isort:skip_file
from ._version import __version__

from .allunits import (
# basic units
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions src/version_helper.py
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit b36fa9e

Please sign in to comment.