forked from virgesmith/humanleague
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py_old
executable file
·69 lines (62 loc) · 2.44 KB
/
setup.py_old
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
#!/usr/bin/env python3
import os
import glob
import warnings
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
def readme():
with open('README.md') as f:
return f.read()
# Workaround for setup dependency on numpy
# delays getting the numpy include dir until numpy has been installed
class BuildExtNumpyWorkaround(build_ext):
def run(self):
import numpy
# Add numpy headers to include_dirs
self.include_dirs.append(numpy.get_include())
# Call original build_ext command
build_ext.run(self)
def list_files(dirs, exts, exclude=[]):
files = []
for directory in dirs:
for ext in exts:
files.extend(glob.glob(os.path.join(directory, "*." + ext)))
[f in files and files.remove(f) for f in exclude]
return files
# seems that this will clean build every time, might make more sense to just have a lightweight wrapper & precompiled lib?
cppmodule = Extension(
'humanleague',
define_macros = [('HUMANLEAGUE_VERSION', get_version()),
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')
],
extra_compile_args = ['-Wall', '-std=c++11'],
include_dirs = ['.', '/usr/include', '/usr/local/include'], # numpy include appended later
# full rebuild triggers if any of sources/depends are modified
sources = list_files(["src", "humanleague"], ["cpp", "c"], exclude=[os.path.join("src", "rcpp_api.cpp"),
os.path.join("src", "RcppExports.cpp"),
os.path.join("src", "humanleague_init.c")]),
depends = list_files(["src", "humanleague"], ["h"])
)
import unittest
def test_suite():
test_loader = unittest.TestLoader()
test_suite = test_loader.discover('tests', pattern='test_*.py')
return test_suite
# ignore distutils/setup warnings triggered by long_description_content_type
warnings.simplefilter("ignore", UserWarning)
#setuptools.
setup(
name = 'humanleague',
version = '2.1.1',
description = 'Microsynthesis using quasirandom sampling and/or IPF',
author = 'Andrew P Smith',
author_email = 'a.p.smith@leeds.ac.uk',
url = 'http://github.com/virgesmith/humanleague',
long_description = readme(),
long_description_content_type="text/markdown",
cmdclass = {'build_ext': BuildExtNumpyWorkaround},
ext_modules = [cppmodule],
setup_requires=['numpy'],
install_requires=['numpy'],
test_suite='setup.test_suite'
)