-
Notifications
You must be signed in to change notification settings - Fork 42
/
setup.py
131 lines (116 loc) · 4.21 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import os
from urllib.request import urlopen
import hashlib
from setuptools import setup, find_packages
from setuptools.command.develop import develop
from setuptools.command.sdist import sdist
from setuptools.command.build_py import build_py
import versioneer
requires = [
'numpy>=1.18.1',
'pyjnius>=1.2.1',
'matplotlib>=3.1.2',
'networkx>=2.4',
'scipy>=1.4.1',
'scikit-image>=0.19.2',
'scikit-learn>=0.21.1',
'tifffile>=2023.3.15',
'zarr>=2.11.3',
'blessed>=1.17',
]
VERSION = versioneer.get_version()
DESCRIPTION = ('Alignment by Simultaneous Harmonization of Layer/Adjacency '
'Registration')
LONG_DESCRIPTION='''
ASHLAR: Alignment by Simultaneous Harmonization of Layer/Adjacency Registration
Ashlar implements efficient combined stitching and registration of multi-channel
image mosaics collected using the Tissue-CycIF microscopy protocol [1]_. Although
originally developed for CycIF, it may also be applicable to other tiled and/or
cyclic imaging approaches. The package offers both a command line script for the
most common use cases as well as an API for building more specialized tools.
.. [1] Tissue-CycIF is multi-round immunofluorescence microscopy on large fixed
tissue samples. See https://doi.org/10.1101/151738 for details.
'''
AUTHOR = 'Jeremy Muhlich'
AUTHOR_EMAIL = '[email protected]'
LICENSE = 'MIT License'
HOMEPAGE = 'https://github.com/sorgerlab/ashlar'
LOCI_TOOLS_URL = 'https://downloads.openmicroscopy.org/bio-formats/6.3.1/artifacts/loci_tools.jar'
LOCI_TOOLS_SHA1 = 'bdf1a37b561fea02fd8d1c747bd34db3fc49667b'
def download_bioformats():
print("Ensuring latest bioformats is present:")
dist_root = os.path.abspath(os.path.dirname(__file__))
jar_dir = os.path.join(dist_root, 'ashlar', 'jars')
lt_jar_path = os.path.join(jar_dir, 'loci_tools.jar')
if not os.access(jar_dir, os.F_OK):
os.mkdir(jar_dir)
try:
with open(lt_jar_path, 'rb') as f:
existing_sha1 = hashlib.sha1(f.read()).hexdigest()
if existing_sha1 == LOCI_TOOLS_SHA1:
print(" Up to date!")
return
except IOError:
pass
print(" Downloading BioFormats from %s ..." % LOCI_TOOLS_URL)
# FIXME add progress bar
content = urlopen(LOCI_TOOLS_URL).read()
content_sha1 = hashlib.sha1(content).hexdigest()
with open(lt_jar_path, 'wb') as f:
f.write(content)
if content_sha1 != LOCI_TOOLS_SHA1:
raise RuntimeError("loci_tools.jar hash mismatch")
# Define some distutils command subclasses for a few key commands to trigger
# downloading the BioFormats JAR before they run.
class PreDevelop(develop):
def run(self):
download_bioformats()
develop.run(self)
class PreSdist(sdist):
def run(self):
download_bioformats()
sdist.run(self)
class PreBuildPy(build_py):
def run(self):
download_bioformats()
build_py.run(self)
cmdclass = {
'develop': PreDevelop,
'sdist': PreSdist,
'build_py': PreBuildPy,
}
setup(
name='ashlar',
version=VERSION,
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
long_description_content_type='text/x-rst',
cmdclass=versioneer.get_cmdclass(cmdclass),
packages=find_packages(),
include_package_data=True,
install_requires=requires,
entry_points={
'console_scripts': [
'ashlar=ashlar.scripts.ashlar:main',
'preview_slide=ashlar.scripts.preview_slide:main',
'make_alignment_movie=ashlar.scripts.make_alignment_movie:main'
]
},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: %s' % LICENSE,
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Visualization'
],
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=HOMEPAGE,
download_url='%s/archive/v%s.tar.gz' % (HOMEPAGE, VERSION),
keywords=['scripts', 'microscopy', 'registration', 'stitching'],
zip_safe=False,
)