Skip to content

Commit

Permalink
Update meta packag
Browse files Browse the repository at this point in the history
  • Loading branch information
wpreimes committed Jun 14, 2024
1 parent 4ac8d68 commit 6f568f8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
75 changes: 75 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,81 @@
Learn more under: https://pyscaffold.org/
"""
from setuptools import setup
from setuptools.command.build_ext import build_ext as _build_ext
from setuptools.command.sdist import sdist as _sdist
from setuptools.extension import Extension
import numpy


# list of C/Cython extensions
def get_ext_modules(ext):
return [
Extension(
"pytesmo.time_series.filters",
["src/pytesmo/time_series/filters" + ext],
include_dirs=[numpy.get_include()],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
),
Extension(
"pytesmo.metrics._fast",
["src/pytesmo/metrics/_fast" + ext],
include_dirs=[numpy.get_include()],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
),
Extension(
"pytesmo.metrics._fast_pairwise",
["src/pytesmo/metrics/_fast_pairwise" + ext],
include_dirs=[numpy.get_include()],
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
),
]


# defining a custom cythonize function that sets all the options we want and
# that can be reused for the different options
def cythonize_extensions():
from Cython.Build import cythonize

cythonize(
get_ext_modules(".pyx"),
compiler_directives={
"embedsignature": True,
"language_level": 3,
# "warn.undeclared": True,
# "warn.maybe_unitialized": True,
"warn.unused": True,
# "warn.unused_arg": True,
# "warn.unused_result": True,
},
# include_path=[numpy.get_include()],
)


class CythonizeMixin(object):

user_options = [
("cythonize", None, "recreate the c extionsions with cython")
]

def initialize_options(self):
super().initialize_options()
self.cythonize = False

def run(self):
if self.cythonize:
cythonize_extensions()
super().run()


class sdist(CythonizeMixin, _sdist):
user_options = getattr(_sdist, 'user_options', [])\
+ CythonizeMixin.user_options


class build_ext(CythonizeMixin, _build_ext):
user_options = getattr(_build_ext, 'user_options', [])\
+ CythonizeMixin.user_options


if __name__ == "__main__":
try:
Expand Down
12 changes: 12 additions & 0 deletions src/pytesmo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@
__version__ = "unknown"
finally:
del version, PackageNotFoundError

# custom code not generated by PyScaffold
__all__ = [
"metrics",
"scaling",
"temporal_matching",
"timedate",
"time_series",
"grid",
"colormaps",
"validation_framework"
]

0 comments on commit 6f568f8

Please sign in to comment.