Skip to content

Commit

Permalink
Upgrade build system
Browse files Browse the repository at this point in the history
  • Loading branch information
edeno committed Oct 23, 2024
1 parent 7b591b4 commit 7a2b12a
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
linguist-language=python
notebooks/* linguist-vendored

# Auto detect text files and perform LF normalization
* text=auto

.git_archival.txt export-subst
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,5 @@ coverage.xml
.DS_Store
*.png
*.mp4

_version.py
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
},
"python.formatting.provider": "none"
"isort.args": [
"--profile",
"black"
],
}
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "track_linearization"
description = "A python package to map 2D trajectories to 1D."
readme = "README.md"
requires-python = ">=3.8"
license = { file = "LICENSE" }
authors = [{ name = "Eric Denovellis", email = "[email protected]" }]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = ["numpy", "scipy", "matplotlib", "pandas", "dask", "networkx"]
dynamic = ["version"]

[project.urls]
"Homepage" = "https://github.com/LorenFrankLab/track_linearization"
"Bug Tracker" = "https://github.com/LorenFrankLab/track_linearization/issues"

[project.optional-dependencies]
test = ["black", "pytest", "pytest-cov"]
opt = ["numba", "ipympl"]

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/track_linearization/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [".git_archival.txt"]

[tool.hatch.build.targets.wheel]
packages = ["src/track_linearization"]
31 changes: 0 additions & 31 deletions setup.py

This file was deleted.

94 changes: 94 additions & 0 deletions workflows/test_package_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Test building package and publish

on:
push:
branches:
- main
- maint/*
tags:
- "*"
pull_request:
branches:
- main
- maint/*
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- run: twine check dist/*
- name: Upload sdist and wheel artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
- name: Build git archive
run: mkdir archive && git archive -v -o archive/archive.tgz HEAD
- name: Upload git archive artifact
uses: actions/upload-artifact@v3
with:
name: archive
path: archive/
test-package:
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
package: ['wheel', 'sdist', 'archive']
steps:
- name: Download sdist and wheel artifacts
if: matrix.package != 'archive'
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Download git archive artifact
if: matrix.package == 'archive'
uses: actions/download-artifact@v3
with:
name: archive
path: archive/
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Update pip
run: pip install --upgrade pip
- name: Install wheel
if: matrix.package == 'wheel'
run: pip install dist/*.whl
- name: Install sdist
if: matrix.package == 'sdist'
run: pip install dist/*.tar.gz
- name: Install archive
if: matrix.package == 'archive'
run: pip install archive/archive.tgz
- name: Install test extras
run: pip install package_name[test]
- name: Run tests
run: pytest --doctest-modules -v --pyargs track_linearization
publish:
runs-on: ubuntu-latest
needs: [test-package]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

0 comments on commit 7a2b12a

Please sign in to comment.