Skip to content
Snippets Groups Projects
Commit 464ed5b0 authored by Daniel CARRON's avatar Daniel CARRON :b: Committed by André Anjos
Browse files

Use hatchling and versioningit for versioning

parent 2cbd042c
No related branches found
No related tags found
1 merge request!21Use hatchling and versioningit for versioning
...@@ -27,3 +27,4 @@ _work/ ...@@ -27,3 +27,4 @@ _work/
.pytest_cache/ .pytest_cache/
results*/ results*/
trainlog.pdf trainlog.pdf
*_version.py
...@@ -12,6 +12,12 @@ variables: ...@@ -12,6 +12,12 @@ variables:
GIT_SUBMODULE_DEPTH: 1 GIT_SUBMODULE_DEPTH: 1
XDG_CONFIG_HOME: $CI_PROJECT_DIR/tests/data XDG_CONFIG_HOME: $CI_PROJECT_DIR/tests/data
.snippets:
setup-metadata:
- pip install hatch
- PACKAGE_NAME=$(hatch project metadata name)
- PACKAGE_VERSION=$(hatch project metadata version)
documentation: documentation:
before_script: before_script:
# for opencv-python dependence # for opencv-python dependence
......
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
recursive-include doc *.rst *.png
recursive-include tests *.py *.png *.csv *.json
recursive-include src/mednet/config/data *.json *.json.bz2
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
package: package:
name: {{ data['project']['name'] }} name: {{ data['project']['name'] }}
version: {{ data['project']['version'] }} version: {{ environ.get('PACKAGE_VERSION') }}
source: source:
path: .. path: ..
build: build:
noarch: python noarch: python
number: {{ environ.get('USE_BUILD_NUMBER', 0) }} number: {{ environ.get('NEXT_BUILD_NUMBER', 0) }}
run_exports: run_exports:
- {{ pin_subpackage(data['project']['name']) }} - {{ pin_subpackage(data['project']['name']) }}
script: script:
...@@ -23,6 +23,8 @@ requirements: ...@@ -23,6 +23,8 @@ requirements:
host: host:
- python >=3.10 - python >=3.10
- pip - pip
- hatchling
- versioningit
- clapper {{ clapper }} - clapper {{ clapper }}
- click {{ click }} - click {{ click }}
- credible {{ credible }} - credible {{ credible }}
...@@ -43,6 +45,7 @@ requirements: ...@@ -43,6 +45,7 @@ requirements:
- lightning >=2.2.0 - lightning >=2.2.0
run: run:
- python >=3.10 - python >=3.10
- versioningit
- {{ pin_compatible('clapper') }} - {{ pin_compatible('clapper') }}
- {{ pin_compatible('click') }} - {{ pin_compatible('click') }}
- {{ pin_compatible('credible') }} - {{ pin_compatible('credible') }}
......
...@@ -3,21 +3,22 @@ ...@@ -3,21 +3,22 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
[build-system] [build-system]
requires = ["setuptools>=61.0.0", "wheel"] requires = ["hatchling", "versioningit"]
build-backend = "setuptools.build_meta" build-backend = "hatchling.build"
[project] [project]
name = "mednet" name = "mednet"
version = "1.0.0b0" dynamic = ["version"]
requires-python = ">=3.10" requires-python = ">=3.10"
description = "Benchmarks for Computer-Aided Disease Detection from Medical Data." description = "Benchmarks for Computer-Aided Disease Detection from Medical Data."
dynamic = ["readme"] readme = "README.md"
license = { text = "GNU General Public License v3 (GPLv3)" } license = { text = "GNU General Public License v3 (GPLv3)" }
authors = [{ name = "Geoffrey Raposo", email = "geoffrey@raposo.ch" }] authors = [{ name = "Geoffrey Raposo", email = "geoffrey@raposo.ch" }]
maintainers = [ maintainers = [
{ name = "Andre Anjos", email = "andre.anjos@idiap.ch" }, { name = "Andre Anjos", email = "andre.anjos@idiap.ch" },
{ name = "Daniel Carron", email = "daniel.carron@idiap.ch" }, { name = "Daniel Carron", email = "daniel.carron@idiap.ch" },
] ]
classifiers = [ classifiers = [
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",
"Intended Audience :: Developers", "Intended Audience :: Developers",
...@@ -26,6 +27,7 @@ classifiers = [ ...@@ -26,6 +27,7 @@ classifiers = [
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Libraries :: Python Modules",
] ]
dependencies = [ dependencies = [
"clapper", "clapper",
"click", "click",
...@@ -44,8 +46,29 @@ dependencies = [ ...@@ -44,8 +46,29 @@ dependencies = [
"lightning>=2.2.0", "lightning>=2.2.0",
"tensorboard", "tensorboard",
"grad-cam>=1.4.8", "grad-cam>=1.4.8",
"versioningit",
]
[tool.hatch.version]
source = "versioningit"
[tool.hatch.build.targets.sdist]
include = [
"src/**/*.py",
"src/**/*.json",
"src/**/*.json.bz2",
"tests/**/*.py",
"tests/**/*.png",
"tests/**/*.csv",
"tests/**/*.json",
"doc/**/*.rst",
"doc/**/*.png",
"LICENSES/*.txt",
] ]
[tool.hatch.build.targets.wheel]
packages = ["src/mednet"]
[project.urls] [project.urls]
documentation = "https://www.idiap.ch/software/biosignal/software/docs/biosignal/software/mednet/main/sphinx/" documentation = "https://www.idiap.ch/software/biosignal/software/docs/biosignal/software/mednet/main/sphinx/"
homepage = "https://pypi.org/project/mednet" homepage = "https://pypi.org/project/mednet"
...@@ -235,16 +258,6 @@ nih-cxr14-padchest = "mednet.config.data.nih_cxr14_padchest.idiap" ...@@ -235,16 +258,6 @@ nih-cxr14-padchest = "mednet.config.data.nih_cxr14_padchest.idiap"
# montgomery-shenzhen-indian-padchest aggregated dataset # montgomery-shenzhen-indian-padchest aggregated dataset
montgomery-shenzhen-indian-padchest = "mednet.config.data.montgomery_shenzhen_indian_padchest.default" montgomery-shenzhen-indian-padchest = "mednet.config.data.montgomery_shenzhen_indian_padchest.default"
[tool.setuptools]
zip-safe = true
package-dir = { "" = "src" }
[tool.setuptools.dynamic]
readme = { file = "README.md" }
[tool.distutils.bdist_wheel]
universal = true
[tool.isort] [tool.isort]
profile = "black" profile = "black"
line_length = 80 line_length = 80
...@@ -261,27 +274,27 @@ junit_log_passing_tests = false ...@@ -261,27 +274,27 @@ junit_log_passing_tests = false
[tool.numpydoc_validation] [tool.numpydoc_validation]
checks = [ checks = [
"all", # report on all checks, except the below "all", # report on all checks, except the below
"ES01", # Not all functions require extended summaries "ES01", # Not all functions require extended summaries
"EX01", # Not all functions require examples "EX01", # Not all functions require examples
"GL01", # Expects text to be on the line after the opening quotes but that is in direct opposition of the sphinx recommendations and conflicts with other pre-commit hooks. "GL01", # Expects text to be on the line after the opening quotes but that is in direct opposition of the sphinx recommendations and conflicts with other pre-commit hooks.
"GL08", # Causes issues if we don't have a docstring at the top of the file. Disabling this might fail to catch actual missing docstrings. "GL08", # Causes issues if we don't have a docstring at the top of the file. Disabling this might fail to catch actual missing docstrings.
"PR04", # numpydoc does not currently support PEP484 typehints, which we are using "PR04", # numpydoc does not currently support PEP484 typehints, which we are using
"RT03", # Since sphinx is unable to understand type annotations we need to remove some types from 'Returns', which breaks this check. "RT03", # Since sphinx is unable to understand type annotations we need to remove some types from 'Returns', which breaks this check.
"SA01", # We do not use Also sections "SA01", # We do not use Also sections
"SS06", # Summary will span multiple lines if too long because of reformatting by other hooks. "SS06", # Summary will span multiple lines if too long because of reformatting by other hooks.
] ]
exclude = [ # don't report on objects that match any of these regex exclude = [ # don't report on objects that match any of these regex
'\.__len__$', '\.__len__$',
'\.__getitem__$', '\.__getitem__$',
'\.__iter__$', '\.__iter__$',
'\.__exit__$', '\.__exit__$',
] ]
override_SS05 = [ # override SS05 to allow docstrings starting with these words override_SS05 = [ # override SS05 to allow docstrings starting with these words
'^Process ', '^Process ',
'^Assess ', '^Assess ',
'^Access ', '^Access ',
'^This', '^This',
] ]
# SPDX-FileCopyrightText: Copyright © 2023 Idiap Research Institute <contact@idiap.ch>
#
# SPDX-License-Identifier: GPL-3.0-or-later
from setuptools import setup
setup()
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
import json import json
import logging import logging
import pathlib import pathlib
import re
import shutil import shutil
import lightning.pytorch import lightning.pytorch
...@@ -120,17 +121,37 @@ def execution_metadata() -> dict[str, int | float | str]: ...@@ -120,17 +121,37 @@ def execution_metadata() -> dict[str, int | float | str]:
# collects dependence information # collects dependence information
package_name = __package__.split(".")[0] package_name = __package__.split(".")[0]
requires = importlib.metadata.requires(package_name) or [] requires = importlib.metadata.requires(package_name) or []
dependence_names = [k.split()[0] for k in requires] dependence_names = [re.split(r"(\=|~|!|>|<|;|\s)+", k)[0] for k in requires]
dependencies = { dependencies = {
k: importlib.metadata.version(k) # version number as str k: importlib.metadata.version(k) # version number as str
for k in dependence_names for k in dependence_names
if importlib.util.find_spec(k) is not None # if is installed if importlib.util.find_spec(k) is not None # if is installed
} }
# checks if the current version corresponds to a dirty (uncommitted) change
# set, issues a warning to the user
current_version = importlib.metadata.version(package_name)
try:
import versioningit
actual_version = versioningit.get_version(".", config={})
if current_version != actual_version:
logger.warning(
f"Version mismatch between current version set "
f"({current_version}) and actual version returned by "
f"versioningit ({actual_version}). This typically happens "
f"when you commit changes locally and do not re-install the "
f"package. Run `pip install -e .` or equivalent to fix this."
)
except Exception as e:
# not in a git repo?
logger.debug(f"Error {e}")
pass
data = { data = {
"datetime": datetime, "datetime": datetime,
"package-name": __package__.split(".")[0], "package-name": __package__.split(".")[0],
"package-version": importlib.metadata.version(package_name), "package-version": current_version,
"dependencies": dependencies, "dependencies": dependencies,
"user": __import__("getpass").getuser(), "user": __import__("getpass").getuser(),
"conda-env": os.environ.get("CONDA_DEFAULT_ENV", ""), "conda-env": os.environ.get("CONDA_DEFAULT_ENV", ""),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment