-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4115bbd
commit 3c56937
Showing
1 changed file
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
from setuptools.extension import Extension | ||
from Cython.Build import cythonize | ||
import numpy as np | ||
from setuptools import setup, find_packages | ||
import os.path as op | ||
from os import getcwd | ||
import sys | ||
import glob | ||
|
||
|
||
_numpy_abs = np.get_include() # get the numpy include path | ||
|
||
def get_file_list(path, ext): | ||
all_files = glob.glob(op.join(path, f"*{ext}")) | ||
for file in all_files: | ||
elem = op.split(file) | ||
name = op.splitext(".".join(elem))[0] | ||
yield name, [file] | ||
|
||
|
||
npymath_path = op.normpath(op.join(_numpy_abs, '..', 'lib')) | ||
npyrandom_path = op.normpath(op.join(_numpy_abs, '..', '..', 'random', 'lib')) | ||
|
@@ -35,35 +42,50 @@ | |
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")] | ||
) | ||
|
||
try: | ||
from Cython.Build import cythonize | ||
if not op.exists("ieeg/timefreq/hilbert.pyx"): | ||
raise ImportError("Cython file not found.") | ||
extensions = [ | ||
Extension( | ||
"ieeg.calc._fast.*", # the module name exposed to python | ||
['ieeg/calc/_fast/*.pyx'], # the Cython source file | ||
**kwargs | ||
), | ||
Extension( | ||
"ieeg.timefreq.hilbert", # the module name exposed to python | ||
['ieeg/timefreq/hilbert.pyx'], # the Cython source file | ||
**kwargs | ||
)] | ||
extensions = cythonize(extensions) | ||
except ImportError: | ||
USE_CYTHON = False | ||
print("Cython not found. Using C files.") | ||
if not op.exists("ieeg/timefreq/hilbert.c"): | ||
ValueError("C file not found.") | ||
|
||
extensions = [ | ||
Extension( | ||
"ieeg.calc._fast.*", # the module name exposed to python | ||
["ieeg/calc/_fast/*.pyx"], # the Cython source file | ||
**kwargs | ||
), | ||
Extension( | ||
"ieeg.calc._fast.ufuncs", # the module name exposed to python | ||
["ieeg/calc/_fast/ufuncs.c"], # the C source file | ||
**kwargs | ||
), | ||
Extension(name, source, **kwargs) for (name, source) in | ||
get_file_list("ieeg/calc/_fast", ".c")] | ||
extensions += [ | ||
Extension( | ||
"ieeg.timefreq.hilbert", # the module name exposed to python | ||
["ieeg/timefreq/hilbert.pyx"], # the Cython source file | ||
['ieeg/timefreq/hilbert.c'], # the Cython source file | ||
**kwargs | ||
), | ||
] | ||
|
||
setup( | ||
name='ieeg', | ||
version='0.2', | ||
version='0.3', | ||
packages=find_packages( | ||
where='.', | ||
include=['ieeg', 'ieeg*'], | ||
include=['ieeg*'], | ||
), | ||
package_dir={"": "."}, | ||
description='A Python package for iEEG data processing.', | ||
author='Aaron Earle-Richardson', | ||
author_email='[email protected]', | ||
url='https://github.com/coganlab/IEEG_Pipelines', | ||
ext_modules=cythonize(extensions), | ||
ext_modules=extensions, | ||
) |