Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sematic version #46

Merged
merged 8 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish to PyPI


on:
workflow_dispatch:
branches:
- main
inputs:
version:
description: 'Version to release'
required: true
default: 'patch'
type: choice
options:
- 'major'
- 'minor'
- 'patch'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: '1.8.3'

- name: Install dependencies
run: poetry install

- name: Bump version
run: |
python handle_versioning.py ${{ github.event.inputs.version }}
git add pyproject.toml
git commit -m "Bump version to ${{ github.event.inputs.version }}"
git push

- name: Create tag
run: |
current_version=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
git tag $current_version
git push origin $current_version

- name: Publish to PyPI
env:
POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }}
run: poetry publish --build
45 changes: 45 additions & 0 deletions handle_versioning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import semantic_version
import toml


def read_version():
with open("pyproject.toml", "r") as file:
pyproject = toml.load(file)
return semantic_version.Version(pyproject["tool"]["poetry"]["version"])


def write_version(version):
with open("pyproject.toml", "r") as file:
pyproject = toml.load(file)
pyproject["tool"]["poetry"]["version"] = str(version)
with open("pyproject.toml", "w") as file:
toml.dump(pyproject, file)


def bump_version(part):
version = read_version()
if part == "major":
new_version = version.next_major()
elif part == "minor":
new_version = version.next_minor()
elif part == "patch":
new_version = version.next_patch()
else:
raise ValueError("Invalid part: choose 'major', 'minor', or 'patch'")
write_version(new_version)
print(f"Updated version to {new_version}")


if __name__ == "__main__":
import sys

if len(sys.argv) < 2 or sys.argv[1] not in ["read", "major", "minor", "patch"]:
raise ValueError("Missing command: choose 'read', 'major', 'minor', or 'patch")

command = sys.argv[1]
if command == "read":
current_version = read_version()
print(f"Current version is {current_version}")

else:
bump_version(command)
28 changes: 27 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

126 changes: 42 additions & 84 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,119 +1,68 @@
# https://python-poetry.org/docs/pyproject
# minimal required information

[project]
name = "osipi"
version = "0.1.2"
dependencies = [
"numpy",
"scipy"
]

# optional information

dependencies = [ "numpy", "scipy",]
description = "The authorative python package for perfusion MRI"
readme = "README.md"
authors = [
{ name = "Luis Torres", email = "[email protected]" },
{ name = "Steven Sourbron", email = "[email protected]" },
]
license = { file = "LICENSE" }
classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',

# Indicate who your project is intended for
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
'Operating System :: OS Independent',

'License :: OSI Approved :: Apache Software License',
"Programming Language :: Python",
"Programming Language :: Python :: 3"
]
keywords = ['python', "medical imaging", "perfusion", "MRI"]

classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Topic :: Scientific/Engineering", "Operating System :: OS Independent", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3",]
keywords = [ "python", "medical imaging", "perfusion", "MRI",]
requires-python = ">=3.6"
[[project.authors]]
name = "Luis Torres"
email = "[email protected]"

[project.urls]
"Homepage" = "https://osipi.github.io/pypi"
[[project.authors]]
name = "Steven Sourbron"
email = "[email protected]"

[tool.setuptools.packages.find]
where = ["src"]
[project.license]
file = "LICENSE"

[project.urls]
Homepage = "https://osipi.github.io/pypi"

[project.optional-dependencies]
tests = [
"pytest",
"matplotlib",
]
docs = [
"sphinx",
"pydata-sphinx-theme",
"myst-parser",
"sphinx-copybutton",
"sphinx-design",
"sphinx-remove-toctrees",
"autodocsumm",
"docutils",
"sphinxcontrib-applehelp",
"sphinxcontrib-devhelp",
"sphinxcontrib-htmlhelp",
"sphinxcontrib-jsmath",
"sphinxcontrib-qthelp",
"sphinxcontrib-serializinghtml",
"sphinx-gallery",
]
tests = [ "pytest", "matplotlib",]
docs = [ "sphinx", "pydata-sphinx-theme", "myst-parser", "sphinx-copybutton", "sphinx-design", "sphinx-remove-toctrees", "autodocsumm", "docutils", "sphinxcontrib-applehelp", "sphinxcontrib-devhelp", "sphinxcontrib-htmlhelp", "sphinxcontrib-jsmath", "sphinxcontrib-qthelp", "sphinxcontrib-serializinghtml", "sphinx-gallery",]

[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".direnv", ".eggs", ".git", ".git-rewrite","__init__.py",
".mypy_cache", ".nox", ".pants.d", ".pyenv", ".pytest_cache", ".pytype",
".ruff_cache", ".svn", ".venv", ".vscode", "__pypackages__", "_build",
"buck-out", "build", "dist", "site-packages", "venv",
]

exclude = [ ".direnv", ".eggs", ".git", ".git-rewrite", "__init__.py", ".mypy_cache", ".nox", ".pants.d", ".pyenv", ".pytest_cache", ".pytype", ".ruff_cache", ".svn", ".venv", ".vscode", "__pypackages__", "_build", "buck-out", "build", "dist", "site-packages", "venv",]
line-length = 100

[tool.poetry]
name = "osipi"
version = "0.1.2"
description = "The authorative python package for perfusion MRI"
authors = [ "Luis Torres <[email protected]>", "Steven Sourbron <[email protected]>",]
readme = "README.md"

[tool.ruff.lint]
# Enable Pyflakes (`F`), a subset of the pycodestyle (`E`) codes, and isort (`I`).
select = ["E4", "E7", "E9", "F", "I"]
select = [ "E4", "E7", "E9", "F", "I",]
ignore = []
fixable = ["ALL"]
fixable = [ "ALL",]
unfixable = []

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

indent-style = "space"

skip-magic-trailing-comma = false

line-ending = "auto"

docstring-code-format = true

docstring-code-line-length = 100

[tool.poetry]
name = "osipi"
version = "0.1.2"
description = "The authorative python package for perfusion MRI"
authors = ["Luis Torres <[email protected]>", "Steven Sourbron <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
numpy = "^1.21.2"
scipy = "^1.7.3"
matplotlib = "3.9.0"
requests = "^2.32.3"
semantic-version = "^2.10.0"
toml = "^0.10.2"

[tool.setuptools.packages.find]
where = [ "src",]

[tool.poetry.group.dev.dependencies]
flake8 = "^7.0.0"
Expand All @@ -125,8 +74,17 @@ pytest-cov = "^5.0.0"
autodocsumm = "^0.2.12"
docutils = "^0.21.2"
myst-parser = "^3.0.1"
rstcheck = {extras = ["sphinx"], version = "^6.2.1"}
mkdocs = "^1.6.0"
mkdocs-material = {extras = ["imaging"], version = "^9.5.27"}
mkdocs-gallery = "^0.10.1"
mkdocstrings = {extras = ["crystal", "python"], version = "^0.25.1"}

[tool.poetry.group.docs.dependencies.rstcheck]
extras = [ "sphinx",]
version = "^6.2.1"

[tool.poetry.group.docs.dependencies.mkdocs-material]
extras = [ "imaging",]
version = "^9.5.27"

[tool.poetry.group.docs.dependencies.mkdocstrings]
extras = [ "crystal", "python",]
version = "^0.25.1"
Loading