-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.py
72 lines (63 loc) · 2.36 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
from setuptools import setup, find_packages, Extension
#######################################
# Prepare list of compiled extensions #
#######################################
extensions = []
# C extension called via ctypes
extensions.append(
Extension(
# "name" defines the location of the compiled module
# within the package tree:
name='pypkgexample.mymodule_c_with_ctypes.hellofcctyp',
# "sources" are the source files to be compiled
sources=[('pypkgexample/mymodule_c_with_ctypes/'
+ '/src/hellofunctions.c')],
include_dirs=[('pypkgexample/mymodule_c_with_ctypes'
+ '/include')],
# Here one can add compilation flags, libraries,
# macro declarations, etc. See setuptools documentation.
)
)
# C extension called via cython
from Cython.Build import cythonize
cython_extensions = [
Extension(
name='pypkgexample.mymodule_c_with_cython.hellofccyth',
sources=[('pypkgexample/mymodule_c_with_cython/'
+ 'hellocython.pyx'),
('pypkgexample/mymodule_c_with_cython/'
+ '/src/hellofunctions.c')],
include_dirs=[('pypkgexample/mymodule_c_with_cython'
+ '/include')],
),
# Other cython extensions can be added here
]
# Cython extensions need to be cythonized before being added to the main
# extension list:
extensions += cythonize(cython_extensions)
# f2py extension
# (to handle f2py extensions we need to replace the setup function and
# the Extension class with their extended version from the numpy package)
from numpy.distutils.core import Extension
from numpy.distutils.core import setup
extensions.append(
Extension(
name='pypkgexample.mymodule_fortran.helloffort',
sources=['pypkgexample/mymodule_fortran/hello_subr.f90'])
)
#########
# Setup #
#########
setup(
name='pypkgexample',
version='1.0.0',
description='Example python package with compiled extensions',
url='https://github.com/giadarol/pypkgexample',
author='Giovanni Iadarola',
packages=find_packages(),
ext_modules = extensions,
install_requires=[
'numpy>=1.0',
'pytest', # In principle could be made optional
]
)