diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5771b73..1e38776 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,31 +17,15 @@ jobs: build: needs: style - name: Build package - runs-on: ubuntu-22.04 + name: Build and publish package + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - name: Install uv + uses: astral-sh/setup-uv@v4 with: - python-version: '3.12' - - name: Build sdist and wheel - run: | - pip install build - python -m build - - uses: actions/upload-artifact@v4 - with: - name: dist - path: dist - - upload-pypi: - name: Upload to PyPI - needs: build - runs-on: ubuntu-22.04 - permissions: - id-token: write - steps: - - uses: actions/download-artifact@v4 - with: - name: dist - path: dist - - uses: pypa/gh-action-pypi-publish@v1.9.0 + python-version: "3.12" + - name: Build Package + run: uv build + - name: Publish package distributions to PyPI + run: uv publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df2610a..5435f39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,12 @@ name: Test -on: [push, pull_request] +on: + push: + branches: [main] + pull_request: + branches: + - main + workflow_dispatch: jobs: style: @@ -17,22 +23,16 @@ jobs: needs: style strategy: matrix: - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ["3.9", "3.10", "3.11", "3.12"] name: Run tests (Python ${{ matrix.python-version }}) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Build sdist and wheel - run: | - pip install build - python -m build - - name: Install wheel - run: pip install "$(pwd)/$(echo dist/pyxdf*.whl)[dev]" + - name: Install uv + uses: astral-sh/setup-uv@v4 + - name: Build + run: uv sync --all-extras - name: Run tests run: | git clone https://github.com/xdf-modules/example-files.git - pip install pytest - pytest + uv run pytest diff --git a/.gitignore b/.gitignore index e168bc2..4d97ece 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ venv/ ENV/ env.bak/ venv.bak/ +uv.lock # Spyder project settings .spyderproject @@ -107,5 +108,11 @@ venv.bak/ .idea # cython temporaries -/pyxdf/pyxdf.c -/pyxdf/pyxdf.html +/src/pyxdf/pyxdf.c +/src/pyxdf/pyxdf.html + +# Dynamic version file +/src/pyxdf/__version__.py + +# Test files +example-files/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..86f94d5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,63 @@ +[project] +name = "pyxdf" +description = "Python library for importing XDF (Extensible Data Format)" +authors = [ + { name = "Christian Kothe", email = "christian.kothe@intheon.io" }, + { name = "Chadwick Boulay", email = "chadwick.boulay@gmail.com" }, + { name = "Clemens Brunner", email = "clemens.brunner@gmail.com" } +] +license = {file = "LICENSE"} +readme = "README.md" +requires-python = ">=3.9" +dynamic = ["version"] +keywords = [ + "XDF", + "pyxdf", + "LSL", + "Lab Streaming Layer", + "file format", + "biosignals", + "stream", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Topic :: Scientific/Engineering", + "License :: OSI Approved :: BSD License", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Operating System :: MacOS", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "numpy>=2.0.2", +] + +[project.urls] +Repository = "https://github.com/xdf-modules/pyxdf" +Issues = "https://github.com/xdf-modules/pyxdf/issues" +Changelog = "https://github.com/xdf-modules/pyxdf/blob/main/CHANGELOG.md" + +[dependency-groups] +dev = [ + "pytest>=8.3.4", + "ruff>=0.8.2", +] + +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/pyxdf/__version__.py" + +[tool.hatch.build.targets.wheel] +packages = ["src/pyxdf"] diff --git a/pyxdf/__init__.py b/pyxdf/__init__.py deleted file mode 100644 index c046393..0000000 --- a/pyxdf/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -# Authors: Christian Kothe & the Intheon pyxdf team -# Clemens Brunner -# -# License: BSD (2-clause) - -from importlib.metadata import PackageNotFoundError, version - -try: - __version__ = version(__name__) -except PackageNotFoundError: - __version__ = None - -from .pyxdf import load_xdf, match_streaminfos, resolve_streams - -__all__ = [load_xdf, resolve_streams, match_streaminfos] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0046ed3..0000000 --- a/setup.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[metadata] -# includes the license file in the wheel -license_files = LICENSE - -[bdist_wheel] -# our code is written to work on both Python 2 and 3 -universal=1 diff --git a/setup.py b/setup.py deleted file mode 100644 index bd04819..0000000 --- a/setup.py +++ /dev/null @@ -1,61 +0,0 @@ -# Authors: Christian Kothe & the Intheon pyxdf team -# Chadwick Boulay -# Clemens Brunner -# -# License: BSD (2-clause) - -"""Python setup script for the pyxdf distribution package.""" - -from setuptools import setup, find_packages -from codecs import open -from os import path - - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the relevant file -with open(path.join(here, "README.md"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="pyxdf", - use_scm_version=True, - setup_requires=["setuptools_scm"], - description="Python library for importing XDF (Extensible Data Format)", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/xdf-modules/xdf-Python", - author="Christian Kothe", - author_email="christian.kothe@intheon.io", - license="BSD", - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering", - "License :: OSI Approved :: BSD License", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX :: Linux", - "Operating System :: MacOS", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], - keywords=[ - "XDF", - "pyxdf", - "LSL", - "Lab Streaming Layer", - "file format", - "biosignals", - "stream", - ], - packages=find_packages(exclude=["pyxdf.test*"]), - install_requires=["numpy"], - extras_require={}, - package_data={}, - data_files=[], - entry_points={}, -) diff --git a/src/pyxdf/__init__.py b/src/pyxdf/__init__.py new file mode 100644 index 0000000..cbb9ff5 --- /dev/null +++ b/src/pyxdf/__init__.py @@ -0,0 +1,4 @@ +from .__version__ import __version__ as __version__ +from .pyxdf import load_xdf, match_streaminfos, resolve_streams + +__all__ = ["load_xdf", "resolve_streams", "match_streaminfos"] diff --git a/src/pyxdf/cli/__init__.py b/src/pyxdf/cli/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyxdf/cli/playback_lsl.py b/src/pyxdf/cli/playback_lsl.py similarity index 100% rename from pyxdf/cli/playback_lsl.py rename to src/pyxdf/cli/playback_lsl.py diff --git a/pyxdf/cli/print_metadata.py b/src/pyxdf/cli/print_metadata.py similarity index 100% rename from pyxdf/cli/print_metadata.py rename to src/pyxdf/cli/print_metadata.py diff --git a/pyxdf/pyxdf.pxd b/src/pyxdf/pyxdf.pxd similarity index 100% rename from pyxdf/pyxdf.pxd rename to src/pyxdf/pyxdf.pxd diff --git a/pyxdf/pyxdf.py b/src/pyxdf/pyxdf.py similarity index 100% rename from pyxdf/pyxdf.py rename to src/pyxdf/pyxdf.py diff --git a/pyxdf/test/test_data.py b/test/test_data.py similarity index 99% rename from pyxdf/test/test_data.py rename to test/test_data.py index 74c87f5..aabf2a2 100644 --- a/pyxdf/test/test_data.py +++ b/test/test_data.py @@ -6,7 +6,7 @@ from pyxdf import load_xdf # requires git clone https://github.com/xdf-modules/example-files.git -# into the root xdf-python folder +# into the root pyxdf folder path = Path("example-files") extensions = ["*.xdf", "*.xdfz", "*.xdf.gz"] files = [] diff --git a/pyxdf/test/test_library_basic.py b/test/test_library_basic.py similarity index 100% rename from pyxdf/test/test_library_basic.py rename to test/test_library_basic.py