Skip to content

Commit

Permalink
Make package ready for PyPI
Browse files Browse the repository at this point in the history
* remove unused packages
* add fields to setup.py to make our package easier to find on PyPI
* remove extra_requires.tf and merged it with install_requires.
* remove lpips_tf from dependencies (it is not on PyPI so it made pushing atlalign to PyPI impossible)
* make Tox install lpips_tf before running tests that require it.
  • Loading branch information
FrancescoCasalegno authored Feb 4, 2021
1 parent 2f204bb commit 9d307a0
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 45 deletions.
48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,43 @@ brain atlases obtained with ISH gene expression and Nissl stains.


### Official documentation
All details related to installation and logic are described in the official documentation. Once
deployed a link will be added. Until then one can generate it locally following the instructions
below.
All details related to installation and logic are described in the
[official documentation](https://atlas-alignment.readthedocs.io/).


### Normal installation
Make sure the `pip` version is at least `19.1`.
### Installation

```bash
pip install --upgrade pip
pip --version # make sure >= 19.1
#### Installation Requirements

Some of the functionalities of `atlalign` depend on the [TensorFlow implementation
of the Learned Perceptual Image Patch Similarity (LPIPS)](https://github.com/alexlee-gk/lpips-tensorflow). Unfortunately, the
package is not available on PyPI and must be installed manually as follows.
```shell script
pip install git+http://github.com/alexlee-gk/lpips-tensorflow.git#egg=lpips_tf
```

Then one can move on to installing the actual `atlalign` package:
You can now move on to installing the actual `atlalign` package!

#### Installation from PyPI
The `atlalign` package can be easily installed from PyPI.
```shell script
pip install atlalign
```
pip install git+https://github.com/BlueBrain/atlas_alignment#egg=atlalign[tf]
```
The extras entry `[tf]` represents TensorFlow and can be dropped if it is already installed.


### Development installation + docs
As described above, make sure to get the most recent `pip`.
#### Installation from source
As an alternative to installing from PyPI, if you want to try the latest version
you can also install from source.
```shell script
pip install git+https://github.com/BlueBrain/atlas_alignment#egg=atlalign
```

#### Installation for development
If you want a dev install, you should install the latest version from source with
all the extra requirements for running test and generating docs.
```shell script
git clone https://github.com/BlueBrain/atlas_alignment
cd atlas_alignment
pip install -e .[dev,docs,tf]
```

Assuming the user ran the above it should be possible to generate the docs
```
cd docs
make clean && make html
pip install -e .[dev,docs]
```

### Examples
Expand Down
14 changes: 13 additions & 1 deletion atlalign/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@
from functools import wraps

import ants
import lpips_tf

try:
import lpips_tf
except ModuleNotFoundError as err:
raise ModuleNotFoundError(
"""
LPIPS-TensorFlow required but not found.
Please install it by running the following command:
$ pip install git+http://github.com/alexlee-gk/lpips-tensorflow.git#egg=lpips_tf
"""
) from err

import numpy as np
import pandas as pd
import tensorflow as tf
Expand Down
14 changes: 13 additions & 1 deletion atlalign/ml_utils/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@

import keras
import keras.backend as K
import lpips_tf

try:
import lpips_tf
except ModuleNotFoundError as err:
raise ModuleNotFoundError(
"""
LPIPS-TensorFlow required but not found.
Please install it by running the following command:
$ pip install git+http://github.com/alexlee-gk/lpips-tensorflow.git#egg=lpips_tf
"""
) from err

import numpy as np
import tensorflow as tf

Expand Down
35 changes: 22 additions & 13 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,41 @@ Installation
============
It is highly recommended to install the project into a new virtual environment.

Requirements
------------
Python Requirements
-------------------
The project is only available for **Python 3.7**. The main reason for this
restriction is an external dependency **ANTsPy** that does
not provide many precompiled wheels on PyPI.


Standard installation
External Dependencies
---------------------
First of all make sure the :code:`pip` version is at least :code:`19.1`
(`PyPA <https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers>`_).
Some of the functionalities of :code:`atlalign` depend on the
`TensorFlow implementation of the Learned Perceptual Image Patch Similarity <https://github.com/alexlee-gk/lpips-tensorflow>`_.
Unfortunately, the
package is not available on PyPI and must be installed manually as follows.

.. code-block:: bash
pip install --upgrade pip
pip --version # make sure >= 19.1
pip install git+http://github.com/alexlee-gk/lpips-tensorflow.git#egg=lpips_tf
You can now move on to installing the actual `atlalign` package!

Then one can move on to installing the actual :code:`atlalign` package:
Installation from PyPI
----------------------
The :code:`atlalign` package can be easily installed from PyPI.

.. code-block:: bash
pip install git+https://github.com/BlueBrain/atlas_alignment#egg=atlalign[tf]
pip install atlalign
The extras entry :code:`[tf]` represents **TensorFlow** and can be dropped if it is already installed.
Installation from source
------------------------
As an alternative to installing from PyPI, if you want to try the latest version
you can also install from source.

.. code-block:: bash
pip install git+https://github.com/BlueBrain/atlas_alignment#egg=atlalign
Development installation
------------------------
Expand All @@ -37,13 +47,12 @@ following way:

- **dev** - pytest + plugins, flake8, pydocstyle, tox
- **docs** - sphinx
- **tf** - tensorflow

.. code-block:: bash
git clone https://github.com/BlueBrain/atlas_alignment
cd atlas_alignment
pip install -e .[dev,docs,tf]
pip install -e .[dev,docs]
Generating documentation
Expand Down
28 changes: 22 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,49 @@

# Preparations
VERSION = atlalign.__version__
DESCRIPTION = "Blue Brain multi-modal registration and alignment toolbox"

LONG_DESCRIPTION = """
Atlas Alignment is a toolbox to perform multimodal image registration. It
includes both traditional and supervised deep learning models.
This project originated from the Blue Brain Project efforts on aligning mouse
brain atlases obtained with ISH gene expression and Nissl stains."""

PYTHON_REQUIRES = "~=3.7.0"
INSTALL_REQUIRES = [
"antspyx==0.2.4",
"allensdk>=0.16.3",
"imgaug<0.3",
"Keras==2.2.4",
"keras_contrib @ git+http://github.com/keras-team/keras-contrib.git@e1574a1#egg=keras_contrib",
"lpips_tf @ git+http://github.com/alexlee-gk/lpips-tensorflow.git#egg=lpips_tf",
"matplotlib>=3.0.3",
"mlflow",
"nibabel>=2.4.0",
"numpy>=1.16.3",
"statsmodels>=0.9.0",
"scikit-image>=0.16.0",
"scikit-learn>=0.20.2",
"scipy==1.2.1",
"tensorflow>=1.15.4,<2",
]

setup(
name="atlalign",
version=VERSION,
description="Image registration with deep learning",
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
url="https://github.com/BlueBrain/atlas_alignment",
author="Blue Brain Project, EPFL",
license="LGPLv3",
packages=find_packages(),
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: Unix",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Software Development :: Libraries :: Python Modules",
],
python_requires=PYTHON_REQUIRES,
install_requires=INSTALL_REQUIRES,
extras_require={
Expand All @@ -39,12 +57,10 @@
"flake8>=3.7.4",
"pydocstyle>=3.0.0",
"pytest>=3.10.1",
"pytest-benchmark>=3.2.2",
"pytest-cov",
"pytest-mock>=1.10.1",
],
"docs": ["sphinx>=1.3", "sphinx-bluebrain-theme"],
"tf": ["tensorflow>=1.15.4,<2"],
},
entry_points={"console_scripts": ["label-tool = atlalign.label.cli:main"]},
)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ envlist =

[testenv]
download = true
deps =
lpips_tf @ git+http://github.com/alexlee-gk/lpips-tensorflow.git#egg=lpips_tf
extras =
dev
tf
commands =
pytest {posargs:tests}

Expand Down Expand Up @@ -44,7 +45,6 @@ basepython = python3.7
changedir = docs
extras =
dev
tf
docs
whitelist_externals = make
commands =
Expand Down

0 comments on commit 9d307a0

Please sign in to comment.