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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
|
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2018, imageio contributors
#
# imageio is distributed under the terms of the (new) BSD License.
# The full license can be found in 'license.txt'.
# styletest: skip
"""
Before release:
* Run test suite on pypy (with numpy)
* Run test suite on Windows 32
* Run test suite on Windows 64
* Run test suite on OS X
* Write release notes
* Check if docs are still good
* Maybe test pypi page via "python setup.py register -r test"
Release:
* Increase __version__
* git tag the release (and push the tag to Github)
* Upload to Pypi: python setup.py sdist upload
* Update conda recipe on conda-forge feedstock
After release:
* Set __version__ to dev
* Announce
"""
import os
import os.path as op
import sys
import shutil
from distutils.core import Command
from distutils.command.sdist import sdist
from distutils.command.build_py import build_py
from itertools import chain
try:
from setuptools import setup # Supports wheels
except ImportError:
from distutils.core import setup # Supports anything else
try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
bdist_wheel = object
name = "imageio"
description = "Library for reading and writing a wide range of image, video, scientific, and volumetric data formats."
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
# Get version and docstring
__version__ = None
__doc__ = ""
docStatus = 0 # Not started, in progress, done
initFile = os.path.join(THIS_DIR, "imageio", "__init__.py")
for line in open(initFile).readlines():
if line.startswith("__version__"):
exec(line.strip())
elif line.startswith('"""'):
if docStatus == 0:
docStatus = 1
line = line.lstrip('"')
elif docStatus == 1:
docStatus = 2
if docStatus == 1:
__doc__ += line.rstrip() + "\n"
# Template for long description. __doc__ gets inserted here
long_description = """
.. image:: https://travis-ci.org/imageio/imageio.svg?branch=master
:target: https://travis-ci.org/imageio/imageio'
.. image:: https://coveralls.io/repos/imageio/imageio/badge.png?branch=master
:target: https://coveralls.io/r/imageio/imageio?branch=master
__doc__
Release notes: http://imageio.readthedocs.io/en/latest/releasenotes.html
Example:
.. code-block:: python
>>> import imageio
>>> im = imageio.imread('imageio:astronaut.png')
>>> im.shape # im is a numpy array
(512, 512, 3)
>>> imageio.imwrite('astronaut-gray.jpg', im[:, :, 0])
See the `user API <http://imageio.readthedocs.io/en/latest/userapi.html>`_
or `examples <http://imageio.readthedocs.io/en/latest/examples.html>`_
for more information.
"""
# Prepare resources dir
package_data = [
"resources/shipped_resources_go_here",
"resources/*.*",
"resources/images/*.*",
"resources/freeimage/*.*",
"resources/ffmpeg/*.*",
"resources/avbin/*.*",
]
def _set_crossplatform_resources(resource_dir):
import imageio
# Clear now
if op.isdir(resource_dir):
shutil.rmtree(resource_dir)
os.mkdir(resource_dir)
open(op.join(resource_dir, "shipped_resources_go_here"), "wb")
# Load images
for fname in [
"images/chelsea.png",
"images/chelsea.zip",
"images/astronaut.png",
"images/newtonscradle.gif",
"images/cockatoo.mp4",
"images/realshort.mp4",
"images/stent.npz",
]:
imageio.core.get_remote_file(fname, resource_dir, force_download=True)
def _set_platform_resources(resource_dir, platform):
import imageio
# Create file to show platform
assert platform
open(op.join(resource_dir, "platform_%s" % platform), "wb")
# Load freeimage
fname = imageio.plugins.freeimage.FNAME_PER_PLATFORM[platform]
imageio.core.get_remote_file(
"freeimage/" + fname, resource_dir, force_download=True
)
# Load ffmpeg
# fname = imageio.plugins.ffmpeg.FNAME_PER_PLATFORM[platform]
# imageio.core.get_remote_file('ffmpeg/'+fname, resource_dir,
# force_download=True)
class test_command(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
from imageio import testing
os.environ["IMAGEIO_NO_INTERNET"] = "1" # run tests without inet
sys.exit(testing.test_unit())
class build_with_fi(build_py):
def run(self):
# Download images and libs
import imageio
resource_dir = imageio.core.resource_dirs()[0]
_set_crossplatform_resources(resource_dir)
_set_platform_resources(resource_dir, imageio.core.get_platform())
# Build as normal
build_py.run(self)
class build_with_images(sdist):
def run(self):
# Download images
import imageio
resource_dir = imageio.core.resource_dirs()[0]
_set_crossplatform_resources(resource_dir)
# Build as normal
sdist.run(self)
extras_require = {"fits": ["astropy"], "gdal": ["gdal"], "simpleitk": ["SimpleITK"]}
extras_require["full"] = sorted(set(chain.from_iterable(extras_require.values())))
install_requires = ["numpy", "pillow"]
if sys.version_info < (3, 4):
install_requires.append("enum34")
if sys.version_info < (3, 2):
install_requires.append("futures")
setup(
cmdclass={ # 'bdist_wheel_all': bdist_wheel_all,
# 'sdist_all': sdist_all,
"build_with_images": build_with_images,
"build_with_fi": build_with_fi,
"sdist": build_with_images,
"test": test_command,
},
name=name,
version=__version__,
author="imageio contributors",
author_email="almar.klein@gmail.com",
license="(new) BSD",
url="http://imageio.github.io/",
download_url="http://pypi.python.org/pypi/imageio",
keywords="image video volume imread imwrite io animation ffmpeg",
description=description,
long_description=long_description.replace("__doc__", __doc__),
platforms="any",
provides=["imageio"],
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*",
install_requires=install_requires,
extras_require=extras_require,
packages=["imageio", "imageio.core", "imageio.plugins"],
package_dir={"imageio": "imageio"},
# Data in the package
package_data={"imageio": package_data},
entry_points={
"console_scripts": [
"imageio_download_bin=imageio.__main__:download_bin_main",
"imageio_remove_bin=imageio.__main__:remove_bin_main",
]
},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: Education",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
],
)
|