diff --git a/.github/workflows/conda-installation.yml b/.github/workflows/conda-installation.yml new file mode 100644 index 0000000..c7d1079 --- /dev/null +++ b/.github/workflows/conda-installation.yml @@ -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() }} diff --git a/.github/workflows/pip-installation.yml b/.github/workflows/pip-installation.yml new file mode 100644 index 0000000..50c97b9 --- /dev/null +++ b/.github/workflows/pip-installation.yml @@ -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() }} diff --git a/Readme.md b/README.md similarity index 90% rename from Readme.md rename to README.md index 0c2ea88..eaeb567 100644 --- a/Readme.md +++ b/README.md @@ -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: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9ce4885 --- /dev/null +++ b/pyproject.toml @@ -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 = "arthur.masson@inria.fr"}, + {name = "Quentin Duché", email = "quentin.duche@irisa.fr"}, + {name = "Malo Gaubert", email = "malo.gaubert@irisa.fr"}, +] +maintainers = [ + {name = "Quentin Duché", email = "quentin.duche@irisa.fr"} +] +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" \ No newline at end of file