Skip to content

Commit

Permalink
Add semantic versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedNasser8 committed Aug 29, 2024
1 parent 601724f commit d83bb70
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 86 deletions.
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: 41 additions & 85 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,119 +1,66 @@
# 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',
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]"

'License :: OSI Approved :: Apache Software License',
"Programming Language :: Python",
"Programming Language :: Python :: 3"
]
keywords = ['python', "medical imaging", "perfusion", "MRI"]
[[project.authors]]
name = "Steven Sourbron"
email = "[email protected]"

requires-python = ">=3.6"
[project.license]
file = "LICENSE"

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

[tool.setuptools.packages.find]
where = ["src"]
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 = false

docstring-code-line-length = "dynamic"

[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 +72,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"

0 comments on commit d83bb70

Please sign in to comment.