Skip to content

Commit

Permalink
switching to hatchling build process
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 6, 2024
1 parent 9e81f5b commit ecac2d0
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 17 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: CI/CD

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
release:
types: [published]

defaults:
run:
shell: bash

jobs:
test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.12"]
fail-fast: false
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors
# because the Github action bot is not a collaborator on the repo
run: git config --local --unset http.https://github.com/.extraheader
- name: Fetch tags
run: git fetch --prune --unshallow
- name: Disable etelemetry
run: echo "NO_ET=TRUE" >> $GITHUB_ENV
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Update build tools
run: python3 -m pip install --break-system-packages --upgrade pip
- name: Install Package
run: python3 -m pip install --break-system-packages -e .[test]
# - name: Change out of root directory
# run: cd docs
# - name: Pytest
# run: pytest -vvs --cov xnatutils --cov-config .coveragerc --cov-report xml .
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v2
# with:
# fail_ci_if_error: true
# token: ${{ secrets.CODECOV_TOKEN }}

build:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Unset header
# checkout@v2 adds a header that makes branch protection report errors
# because the Github action bot is not a collaborator on the repo
run: git config --local --unset http.https://github.com/.extraheader
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install build tools
run: python3 -m pip install --break-system-packages build twine
- name: Build source and wheel distributions
run: python3 -m build .
- name: Check distributions
run: twine check dist/*
- uses: actions/upload-artifact@v3
with:
name: build
path: dist

# build-docs:
# runs-on: ubuntu-latest
# needs: [build]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v2
# - name: Unset header
# # checkout@v2 adds a header that makes branch protection report errors
# # because the Github action bot is not a collaborator on the repo
# run: git config --local --unset http.https://github.com/.extraheader
# - name: Setup Python
# uses: actions/setup-python@v2
# with:
# python-version: 3.x
# - name: Install dependencies
# run: |
# python3 -m pip install --break-system-packages --upgrade pip
# pip install .[docs]
# - name: Build documentation
# run: |
# cd docs
# make html
# cd ..
# - uses: actions/upload-artifact@v3
# with:
# name: built-docs
# path: docs/build/html

deploy:
needs: [build] # , build-docs]
runs-on: ubuntu-latest
steps:
- name: Download build
uses: actions/download-artifact@v3
with:
name: built-main
path: dist
- name: Check for PyPI token on tag
id: deployable
if: github.event_name == 'release'
env:
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
run: if [ -n "$PYPI_API_TOKEN" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
- name: Upload to PyPI
if: steps.deployable.outputs.DEPLOY
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

# deploy-docs:
# needs: [build-docs, deploy]
# runs-on: ubuntu-latest
# steps:
# - name: Download built docs
# uses: actions/download-artifact@v3
# with:
# name: built-docs
# path: docs-build
# - name: Check for GHPAGES_DEPLOY_KEY token
# id: deployable
# if: github.event_name == 'release'
# env:
# GHPAGES_DEPLOY_KEY: "${{ secrets.GHPAGES_DEPLOY_KEY }}"
# run: if [ -n "$GHPAGES_DEPLOY_KEY" ]; then echo "DEPLOY=true" >> $GITHUB_OUTPUT; fi
# - name: Deploy Docs to GitHub Pages
# if: steps.deployable.outputs.DEPLOY
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GHPAGES_DEPLOY_KEY }}
# publish_dir: docs-build

# Deploy on tags if PYPI_API_TOKEN is defined in the repository secrets.
# Secrets are not accessible in the if: condition [0], so set an output variable [1]
# [0] https://github.community/t/16928
# [1] https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-output-parameter
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
test/*.xml
.vscode
*.venv
_version.py
96 changes: 96 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "xnatutils"
description = "A collection of scripts for downloading/uploading and listing data from XNAT repositories."
readme = "README.rst"
requires-python = ">=3.8"
dependencies = ["xnat>=0.6", "progressbar2>=3.16.0", "future>=0.16"]
license = { file = "LICENSE" }
authors = [{ name = "Thomas G. Close", email = "[email protected]" }]
maintainers = [{ name = "Thomas G. Close", email = "[email protected]" }]
keywords = ["XNAT", "REST API", "DICOM", "uploader"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Healthcare Industry",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
]
dynamic = ["version"]

# [project.optional-dependencies]
# dev = [
# "black",
# "pre-commit",
# "codespell",
# "flake8",
# "flake8-pyproject",
# "xnatutils[test]",
# "pydata-sphinx-theme >=0.13",
# ]
# test = [
# "pytest >=6.2.5",
# "pytest-env>=0.6.2",
# "pytest-cov>=2.12.1",
# "pydra >=0.23.0a0",
# ]
# docs = [
# ]

[project.urls]
repository = "https://github.com/Australian-Imaging-Service/xnatutils"


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

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

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build]
packages = ["xnatutils"]
exclude = ["tests"]
include = ["./xnatutils"]

[project.scripts]
xnat-get = "xnatutils.get_:cmd"
xnat-put = "xnatutils.put_:cmd"
xnat-ls = "xnatutils.ls_:cmd"
xnat-varget = "xnatutils.varget_:cmd"
xnat-varput = "xnatutils.varput_:cmd"
xnat-rename = "xnatutils.rename_:cmd"

[tool.black]
target-version = ['py38']
exclude = "xnatutils/core/_version.py"
# [tool.mypy]
# python_version = "3.8"
# ignore_missing_imports = true
# strict = true
# namespace_packages = true
# explicit_package_bases = true
# exclude = ["tests", "scripts", "docs", "build", "dist", "xnatutils/_version.py"]


[tool.codespell]
ignore-words = ".codespell-ignorewords"

[tool.flake8]
doctests = true
per-file-ignores = ["__init__.py:F401"]
max-line-length = 88
select = "C,E,F,W,B,B950"
extend-ignore = ['E203', 'E501', 'E129', 'W503', 'E704']
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

12 changes: 0 additions & 12 deletions setup.cfg

This file was deleted.

0 comments on commit ecac2d0

Please sign in to comment.