-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
135 lines (111 loc) · 4.01 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
132
133
134
135
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import
import os
import sys
import shutil
import subprocess
from fnmatch import fnmatchcase
from distutils.util import convert_path
# Do not EVER use setuptools, it makes cythonization fail
# Distribute fixes that
from distutils.core import setup, Extension
import numpy
from Cython.Distutils import build_ext
from Cython.Distutils.extension import Extension as CythonExtension
if sys.version_info[:2] < (2, 6):
raise Exception('flypy requires Python 2.6 or greater.')
import versioneer
#------------------------------------------------------------------------
# Setup constants and arguments
#------------------------------------------------------------------------
versioneer.versionfile_source = 'flypy/_version.py'
versioneer.versionfile_build = 'flypy/_version.py'
versioneer.tag_prefix = ''
versioneer.parentdir_prefix = 'flypy-'
cmdclass = versioneer.get_cmdclass()
cmdclass['build_ext'] = build_ext
setup_args = {
'long_description': open('README.md').read(),
}
flypy_root = os.path.dirname(os.path.abspath(__file__))
#------------------------------------------------------------------------
# Package finding
#------------------------------------------------------------------------
def find_packages(where='.', exclude=()):
out = []
stack=[(convert_path(where), '')]
while stack:
where, prefix = stack.pop(0)
for name in os.listdir(where):
fn = os.path.join(where,name)
if ('.' not in name and os.path.isdir(fn) and
os.path.isfile(os.path.join(fn, '__init__.py'))
):
out.append(prefix+name)
stack.append((fn, prefix+name+'.'))
if sys.version_info[0] == 3:
exclude = exclude + ('*py2only*', )
for pat in list(exclude) + ['ez_setup', 'distribute_setup']:
out = [item for item in out if not fnmatchcase(item, pat)]
return out
#------------------------------------------------------------------------
# 2to3
#------------------------------------------------------------------------
def run_2to3(cmdclass):
import lib2to3.refactor
from distutils.command.build_py import build_py_2to3 as build_py
print("Installing 2to3 fixers")
# need to convert sources to Py3 on installation
fixes = 'dict imports imports2 unicode metaclass basestring reduce ' \
'xrange itertools itertools_imports long types exec execfile'.split()
fixes = ['lib2to3.fixes.fix_' + fix
for fix in fixes]
build_py.fixer_names = fixes
cmdclass["build_py"] = build_py
# cmdclass["build"] = build_py
# Distribute options
# setup_args["use_2to3"] = True
if sys.version_info[0] >= 3:
run_2to3(cmdclass)
#------------------------------------------------------------------------
# setup
#------------------------------------------------------------------------
exclude_packages = (
)
setup(
name="flypy",
version=versioneer.get_version(),
author="Mark Florisson",
#author_email="",
#url="",
license="BSD",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
#"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Topic :: Utilities",
],
description="Compiling Python code using LLVM",
packages=find_packages(exclude=exclude_packages),
scripts=["bin/flypy"],
package_data={
'': ['*.md'],
'flypy.runtime.obj': ['*.c', '*.h', '*.pyx', '*.pxd'],
},
ext_modules=[
Extension(
name="flypy.runtime.lib.libcpy",
sources=["flypy/runtime/lib/libcpy.pyx"],
include_dirs=[numpy.get_include()],
depends=[]),
Extension(
name="flypy.runtime.gc.boehmlib",
sources=["flypy/runtime/gc/boehmlib.pyx"],
libraries=["gc"]),
],
cmdclass=cmdclass,
**setup_args
)