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/
.pytest_cache/
results*/
trainlog.pdf
*_version.py
......@@ -12,6 +12,12 @@ variables:
GIT_SUBMODULE_DEPTH: 1
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:
before_script:
# 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 @@
package:
name: {{ data['project']['name'] }}
version: {{ data['project']['version'] }}
version: {{ environ.get('PACKAGE_VERSION') }}
source:
path: ..
build:
noarch: python
number: {{ environ.get('USE_BUILD_NUMBER', 0) }}
number: {{ environ.get('NEXT_BUILD_NUMBER', 0) }}
run_exports:
- {{ pin_subpackage(data['project']['name']) }}
script:
......@@ -23,6 +23,8 @@ requirements:
host:
- python >=3.10
- pip
- hatchling
- versioningit
- clapper {{ clapper }}
- click {{ click }}
- credible {{ credible }}
......@@ -43,6 +45,7 @@ requirements:
- lightning >=2.2.0
run:
- python >=3.10
- versioningit
- {{ pin_compatible('clapper') }}
- {{ pin_compatible('click') }}
- {{ pin_compatible('credible') }}
......
......@@ -3,21 +3,22 @@
# SPDX-License-Identifier: GPL-3.0-or-later
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "versioningit"]
build-backend = "hatchling.build"
[project]
name = "mednet"
version = "1.0.0b0"
dynamic = ["version"]
requires-python = ">=3.10"
description = "Benchmarks for Computer-Aided Disease Detection from Medical Data."
dynamic = ["readme"]
readme = "README.md"
license = { text = "GNU General Public License v3 (GPLv3)" }
authors = [{ name = "Geoffrey Raposo", email = "geoffrey@raposo.ch" }]
maintainers = [
{ name = "Andre Anjos", email = "andre.anjos@idiap.ch" },
{ name = "Daniel Carron", email = "daniel.carron@idiap.ch" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
......@@ -26,6 +27,7 @@ classifiers = [
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
"clapper",
"click",
......@@ -44,8 +46,29 @@ dependencies = [
"lightning>=2.2.0",
"tensorboard",
"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]
documentation = "https://www.idiap.ch/software/biosignal/software/docs/biosignal/software/mednet/main/sphinx/"
homepage = "https://pypi.org/project/mednet"
......@@ -235,16 +258,6 @@ nih-cxr14-padchest = "mednet.config.data.nih_cxr14_padchest.idiap"
# montgomery-shenzhen-indian-padchest aggregated dataset
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]
profile = "black"
line_length = 80
......@@ -261,27 +274,27 @@ junit_log_passing_tests = false
[tool.numpydoc_validation]
checks = [
"all", # report on all checks, except the below
"ES01", # Not all functions require extended summaries
"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.
"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
"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
"SS06", # Summary will span multiple lines if too long because of reformatting by other hooks.
"all", # report on all checks, except the below
"ES01", # Not all functions require extended summaries
"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.
"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
"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
"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
'\.__len__$',
'\.__getitem__$',
'\.__iter__$',
'\.__exit__$',
exclude = [ # don't report on objects that match any of these regex
'\.__len__$',
'\.__getitem__$',
'\.__iter__$',
'\.__exit__$',
]
override_SS05 = [ # override SS05 to allow docstrings starting with these words
'^Process ',
'^Assess ',
'^Access ',
'^This',
override_SS05 = [ # override SS05 to allow docstrings starting with these words
'^Process ',
'^Assess ',
'^Access ',
'^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 @@
import json
import logging
import pathlib
import re
import shutil
import lightning.pytorch
......@@ -120,17 +121,37 @@ def execution_metadata() -> dict[str, int | float | str]:
# collects dependence information
package_name = __package__.split(".")[0]
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 = {
k: importlib.metadata.version(k) # version number as str
for k in dependence_names
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 = {
"datetime": datetime,
"package-name": __package__.split(".")[0],
"package-version": importlib.metadata.version(package_name),
"package-version": current_version,
"dependencies": dependencies,
"user": __import__("getpass").getuser(),
"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