forked from lrq3000/unireedsolomon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
93 lines (89 loc) · 4.44 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
# See:
# https://docs.python.org/2/distutils/setupscript.html
# http://docs.cython.org/src/reference/compilation.html
# https://docs.python.org/2/extending/building.html
# http://docs.cython.org/src/userguide/source_files_and_compilation.html
# http://www.ewencp.org/blog/a-brief-introduction-to-packaging-python/
# http://stackoverflow.com/questions/12966216/make-distutils-in-python-automatically-find-packages
# http://blog.ionelmc.ro/2014/05/25/python-packaging/
# http://blog.ionelmc.ro/2014/06/25/python-packaging-pitfalls/
# To add a commandline entry point: http://www.scotttorborg.com/python-packaging/command-line-scripts.html
# Also see pyroma and checkmanifest tools.
#
# To test, use `python setup.py develop`
# To package, use `python setup.py sdist --formats=gztar,zip bdist_wininst --plat-name=win32` and then try to `python setup.py install` and check if everything runs correctly.
# Then to upload to pypi, do `python setup.py register sdist --formats=gztar,zip bdist_wininst --plat-name=win32 upload`
try:
from setuptools import setup, find_packages
from setuptools import Extension
except ImportError:
from distutils.core import setup, find_packages
from distutils.extension import Extension
import os, sys
try:
# Test if Cython is installed
if '--nocython' in sys.argv:
# Skip if user does not want to use Cython
sys.argv.remove('--nocython')
raise(ImportError('Skip Cython'))
# If Cython is installed, transpile the optimized Cython module to C and compile as a .pyd to be distributed
from Cython.Build import cythonize
print("Cython is installed, building creedsolo module")
extensions = cythonize([
Extension('unireedsolomon.cff', [os.path.join('unireedsolomon', 'cff.pyx')]),
Extension('unireedsolomon.cpolynomial', [os.path.join('unireedsolomon', 'cpolynomial.pyx')]),
])
except ImportError:
# Else Cython is not installed (or user explicitly wanted to skip)
if '--native-compile' in sys.argv:
# Compile pyd from pre-transpiled creedsolo.c
print("Cython is not installed, but the creedsolo module will be built from the pre-transpiled creedsolo.c file using the locally installed C compiler")
sys.argv.remove('--native-compile')
extensions = [
Extension('unireedsolomon.cff', [os.path.join('unireedsolomon', 'cff.c')]),
Extension('unireedsolomon.cpolynomial', [os.path.join('unireedsolomon', 'cpolynomial.c')]),
]
else:
# Else run in pure python mode (no compilation)
print("Cython is not installed or is explicitly skipped using --nocython, no creedsolo module will be built")
extensions = None
setup(
name = "unireedsolomon",
version = "1.0.5",
description = "Universal errors-and-erasures Reed Solomon codec (error correcting code) in pure Python with extensive documentation",
author = "Andrew Brown, Stephen Larroque",
author_email = "[email protected]",
platforms = ["any"],
license = "MIT",
url = "https://github.com/lrq3000/unireedsolomon",
#packages = ["unireedsolomon"],
#py_modules = ["rs", 'polynomial', 'ff', '_compat'],
long_description = open("README.rst", "r").read(),
long_description_content_type = "text/x-rst",
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Cython",
"Topic :: Communications",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: System :: Archiving :: Backup",
"Topic :: System :: Recovery Tools",
],
keywords = 'error correction erasure reed solomon repair file network packet',
ext_modules = extensions,
test_suite='nose.collector',
tests_require=['nose'],
packages = find_packages(exclude=['build', 'docs', 'presentation'])
)