Skip to content

Commit

Permalink
Merge pull request #15 from alexpron/packaging
Browse files Browse the repository at this point in the history
Installation mechanism and basic CI.
That worked like a charm for me.
  • Loading branch information
quentinduche authored Jul 19, 2024
2 parents 2e4097d + cbbe985 commit 6fa3b89
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 3 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/conda-installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Python installation

on: [push]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
#TODO: use github action to read python version from pyproject.toml
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
activate-environment: working-env
python-version: ${{ matrix.python-version }}
auto-activate-base: false
- name: Install dependencies
shell: bash -el {0}
run: |
conda config --set pip_interop_enabled True
python -m pip install .
conda update --all
conda install -c conda-forge heudiconv bids-validator dcm2niix git-annex=*=alldep* datalad
# Create virtual env under each python version
# (optional and a bit redundant because we are already on a specific python)
# it insures installation instruction provided in README are working
# - name: Test with pytest
# run: pytest tests.py --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml
# - name: Upload pytest test results
# uses: actions/upload-artifact@v4
# with:
# name: pytest-results-${{ matrix.python-version }}
# path: junit/test-results-${{ matrix.python-version }}.xml
# # Use always() to always run this step to publish test results when there are test failures
# if: ${{ always() }}
36 changes: 36 additions & 0 deletions .github/workflows/pip-installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Python installation

on: [push]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
#TODO: use github action to read python version from pyproject.toml
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Python # Set Python version
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Create virtual env under each python version
# (optional and a bit redundant because we are already on a specific python)
# it insures installation instruction provided in README are working
- name: Install dependencies
run: |
python -m venv working-env --clear
source working-env/bin/activate
python -m pip install --upgrade pip
python -m pip install -e .
# - name: Test with pytest
# run: pytest tests.py --doctest-modules --junitxml=junit/test-results-${{ matrix.python-version }}.xml
# - name: Upload pytest test results
# uses: actions/upload-artifact@v4
# with:
# name: pytest-results-${{ matrix.python-version }}
# path: junit/test-results-${{ matrix.python-version }}.xml
# # Use always() to always run this step to publish test results when there are test failures
# if: ${{ always() }}
20 changes: 17 additions & 3 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,28 @@ The scripts `convert_dicoms_to_niftis.py` and `create_previews.py` enable to con

## Install

It is advised to install the project in [a virtual environment](https://docs.python.org/3/tutorial/venv.html).

[Install python with pip](https://www.python.org/downloads/) ; then use `pip install -r requirements.txt` to install python dependencies.
It is advised to install the project in python virtual environment relying either on [venv](https://docs.python.org/3/tutorial/venv.html) or preferably [(mini)conda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
### Installation with pip
[Install python with pip](https://www.python.org/downloads/) ; then use `pip install .` to install python dependencies.

Optionally, rename the `.env.example` to `.env` and set the variables (`shanoir_password`, `gpg_recipient`) to your needs.

*See the "Installing DicomAnonymizer" section if you want to use DicomAnonymizer for the dicom anonymization instead of PyDicom.*

### Installation with conda
> [!IMPORTANT]
> This installation method is required if shanoir2bids.py is used
In an active conda virtual environment type
```bash
#use pip packages as dependencies
conda config --set pip_interop_enabled True
pip install .
#replace pip packages with conda packages when equivalent
conda update --all
# install missing conda packages (far simpler than using pip)
conda install -c conda-forge heudiconv git-annex=*=alldep* datalad
```
## Usage

There are three scripts to download datasets:
Expand Down
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "shanoir-downloader"
version = "0.0.1"

dynamic = ["dependencies", "optional-dependencies"]

requires-python = ">=3.8, <3.11"

authors = [
{name = "Arthur Masson",email = "[email protected]"},
{name = "Quentin Duché", email = "[email protected]"},
{name = "Malo Gaubert", email = "[email protected]"},
]
maintainers = [
{name = "Quentin Duché", email = "[email protected]"}
]
description = "Download Shanoir Datasets in various format using Python"
readme = "README.md"
license = {file = "LICENSE"}
keywords = ["Shanoir", "DICOM", "NIFTI", "BIDS"]
classifiers = [
"Programming Language :: Python"
]

[project.urls]
Repository = "https://github.com/Inria-Empenn/shanoir_downloader.git"
"Bug Tracker" = "https://github.com/Inria-Empenn/shanoir_downloader/issues"
Changelog = "https://github.com/Inria-Empenn/shanoir_downloader/blob/master/CHANGELOG.md"

[tool.setuptools]
py-modules = []

[tool.setuptools_scm]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}


#optional-dependencies = {dev = { file = ["requirements-dev.txt"] }}
#[project.scripts]
#spam-cli = "shanoir-downloader:main_cli"

#
#[project.entry-points."spam.magical"]
#tomatoes = "spam:main_tomatoes"

0 comments on commit 6fa3b89

Please sign in to comment.