Skip to content

Commit

Permalink
fixed distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronearlerichardson committed Apr 23, 2024
1 parent 4115bbd commit 3c56937
Showing 1 changed file with 37 additions and 15 deletions.
52 changes: 37 additions & 15 deletions setup.py
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'))
Expand All @@ -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,
)

0 comments on commit 3c56937

Please sign in to comment.