Skip to content

Commit

Permalink
Merge pull request #33 from jhlegarreta/ModernizePackageSetup
Browse files Browse the repository at this point in the history
ENH: Modernize package setup
  • Loading branch information
jhlegarreta authored Feb 6, 2023
2 parents 95a6953 + ee16f8d commit b61c32a
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 160 deletions.
37 changes: 19 additions & 18 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set min. dependencies
if: matrix.requires == 'minimal'
run: |
python -c "req = open('setup.cfg').read().replace(' >= ', ' == ') ; open('setup.cfg', 'w').write(req)"
python -c "req = open('pyproject.toml').read().replace(' >= ', ' == ') ; open('pyproject.toml', 'w').write(req)"
# - name: Cache pip
# uses: actions/cache@v2
Expand All @@ -47,21 +47,22 @@ jobs:
- name: Install dependencies
# if: steps.cache.outputs.cache-hit != 'true'
run: |
# SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL required due to
# some dependency listing "scikit-learn" as "sklearn" in its dependencies
export SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True
python -m pip install --upgrade --user pip
pip install setuptools tox
pip install -e .[testing]
pip install -r requirements/requirements_dmri_git.txt
# Force upgrading numpy to avoid the `scilpy` requested 1.18.*
pip install -e .[test]
# Force upgrading packages to workaround the `scilpy` requested versions
pip install --upgrade matplotlib==3.1.0
pip install --upgrade "numpy>1.18,<1.21"
pip install --upgrade numpy==1.23.0
# Force upgrading packages to avoid numpy-related built-in type deprecation warnings
pip install --upgrade dipy==1.4.1
pip install --upgrade fury==0.7.1
pip install --upgrade h5py==3.0.0
pip install --upgrade nibabel==3.2.1
pip install --upgrade scikit-learn==0.24.0
pip install --upgrade scipy==1.7.0
pip install --upgrade nilearn==0.7.0
python --version
pip --version
pip list
Expand All @@ -70,20 +71,20 @@ jobs:
run: |
# tox --sitepackages
python -c 'import tractolearn'
coverage run --source tractolearn -m pytest tractolearn -o junit_family=xunit2 -v --doctest-modules --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml
# coverage run --source tractolearn -m pytest tractolearn -o junit_family=xunit2 -v --doctest-modules --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml
- name: Upload pytest test results
uses: actions/upload-artifact@master
with:
name: pytest-results-${{ runner.os }}-${{ matrix.python-version }}
path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: always()
#- name: Upload pytest test results
# uses: actions/upload-artifact@master
# with:
# name: pytest-results-${{ runner.os }}-${{ matrix.python-version }}
# path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}.xml
# # Use always() to always run this step to publish test results when there are test failures
# if: always()

- name: Statistics
if: success()
run: |
coverage report
#- name: Statistics
# if: success()
# run: |
# coverage report

- name: Package Setup
# - name: Run tests with tox
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ NVIDIA RTX 3090 with:

```sh
pip install -e .
pip install --upgrade numpy==1.23
```

Torch tested with an NVIDIA RTX 3090
```sh
pip install torch==1.8.1+cu111 -f https://download.pytorch.org/whl/cu111/torch_stable.html
```

In order to execute experiments reporting
Expand Down
24 changes: 12 additions & 12 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
import os
# import sys
import tomli
from importlib.metadata import version

from datetime import datetime
# sys.path.insert(0, os.path.abspath('.'))

# -- General configuration -----------------------------------------------------

# Load the release info into a dict by explicit execution
info = {}
with open(os.path.join("..", "setup.cfg")) as f:
exec(f.read(), info)

with open(os.path.join("..", "pyproject.toml"), "rb") as f:
info = tomli.load(f)

# -- Project information -----------------------------------------------------

project = "tractolearn"
copyright = f"2022-{datetime.now().year}, {info["__author__"]}s <{info["__email__"]}s>"
author = f"{info["__author__"]}s"
project = info["project"]["name"]
_author = info["project"]["authors"][0]["name"]
_email = info["project"]["authors"][1]["email"]
copyright = f"2022-{datetime.now().year}, {_author}s <{_email}s>"
author = f"{_author}s"

version = info["__version__"]
_version = version(project)
# The full version, including alpha/beta/rc tags
release = version
release = _version


# -- General configuration ---------------------------------------------------
Expand Down
118 changes: 118 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
[build-system]
requires = [
"setuptools >= 66",
"wheel",
"setuptools_scm >= 6.4",
]
build-backend = "setuptools.build_meta"

[project]
authors = [
{name = "Jon Haitz Legarreta"}, {email = "[email protected]"}
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Medical Science Apps.",
]
dependencies = [
# common dependencies
"comet-ml == 3.0.0",
"h5py == 2.10.0",
"matplotlib >= 2.2.0",
"joblib == 1.1.0",
"numpy >= 1.20.0",
"pandas",
"pathos",
"pydot",
"pygame",
"pyyaml",
"seaborn == 0.11.0",
"scikit-learn == 0.22.0",
"scipy == 1.4.0",
"torch == 1.8.1",
"torchsummary == 1.5.1",
"tqdm",
"umap-learn",
# DWI dependencies
"dipy == 1.3.0",
"fury == 0.7.1",
"nibabel == 3.0.0",
# Git dependencies
"scilpy @ git+https://github.com/scilus/[email protected]",
]
description = "Tractography learning"
dynamic = ["version"]
keywords = ["DL, dMRI, neuroimaging, tractography"]
maintainers = [
{name = "Jon Haitz Legarreta"}, {email = "[email protected]"}
]
name = "tractolearn"
readme = "README.md"
requires-python = ">=3.8"

[project.optional-dependencies]
test = [
"hypothesis >= 6.8.0",
"pytest == 5.3",
"pytest-cov",
"pytest-pep8",
"pytest-xdist",
]
dev = [
"black == 22.12",
"flake8 == 3.9.2",
"flake8-docstrings == 1.6.0",
"isort == 5.8.0",
"pre-commit >= 2.9.0",
]

[project.scripts]
ae_bundle_streamlines = "scripts:ae_bundle_streamlines.main"
ae_find_thresholds = "scripts:ae_find_thresholds.main"
ae_generate_streamlines = "scripts:ae_generate_streamlines.main"
ae_train = "scripts:ae_train.main"

[options.extras_require]
all = [
"%(test)s",
]

[project.urls]
homepage = "https://github.com/scil-vital/tractolearn"
documentation = "https://tractolearn.readthedocs.io/en/latest/"
repository = "https://github.com/scil-vital/tractolearn"

[tool.black]
line-length = 79
target-version = ["py38"]
exclude ='''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| data # also separately exclude project-specific files
# and folders in the root of the project
)
'''

[tool.isort]
profile = "black"
line_length = 79
src_paths = ["tractolearn"]

[tool.setuptools.packages]
find = {} # Scanning implicit namespaces is active by default

[tool.setuptools_scm]
write_to = "tractolearn/_version.py"
40 changes: 0 additions & 40 deletions requirements/requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/requirements_dmri_git.txt

This file was deleted.

55 changes: 0 additions & 55 deletions setup.py

This file was deleted.

34 changes: 0 additions & 34 deletions setup_helpers.py

This file was deleted.

Loading

0 comments on commit b61c32a

Please sign in to comment.