Skip to content

Commit

Permalink
Build with setuptools
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronreidsmith committed Sep 25, 2024
1 parent 1300ccd commit 340c621
Showing 1 changed file with 31 additions and 42 deletions.
73 changes: 31 additions & 42 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

# Minimum allowed version
MIN_PYTHON = (3, 7)
IS_PYTHON_312 = sys.version_info[0] == 3 and sys.version_info[1] >= 12

# Hacky (!!), adopted from sklearn. This sets a global variable
# so pmdarima __init__ can detect if it's being loaded in the setup
Expand Down Expand Up @@ -54,6 +53,7 @@

# import restricted version of pmdarima that does not need the compiled code
import pmdarima

VERSION = pmdarima.__version__ # will be 0.0.0 unless tagging

# get the installation requirements:
Expand Down Expand Up @@ -139,17 +139,20 @@ def run(self):
os.environ['NPY_BLAS_ORDER'] = ''
os.environ['NPY_LAPACK_ORDER'] = ''


class build_ext_subclass(build_ext):
def build_extensions(self):
build_ext.build_extensions(self)


cmdclass['build_ext'] = build_ext_subclass

except ImportError:
# Numpy should not be a dependency just to be able to introspect
# that python 3.X is required.
pass


# Here is where scikit configures the wheelhouse uploader, but we don't deal
# with that currently. Maybe in the future...

Expand Down Expand Up @@ -318,47 +321,33 @@ def do_setup():
)
)

# for sdist, use setuptools so we get the long_description_content_type
if 'sdist' in sys.argv or IS_PYTHON_312:
from setuptools import setup
print("Setting up with setuptools")

# TODO: distutils is removed in Python 3.12+, so this should probably be the default
if IS_PYTHON_312:
from setuptools import Extension

import numpy

include_dirs = [numpy.get_include()]
metadata['ext_modules'] = [
Extension(
name='pmdarima.arima._arima',
sources=['pmdarima/arima/_arima.pyx'],
include_dirs=include_dirs
),
Extension(
name='pmdarima.preprocessing.exog._fourier',
sources=['pmdarima/preprocessing/exog/_fourier.pyx'],
include_dirs=include_dirs
),
Extension(
name='pmdarima.utils._array',
sources=['pmdarima/utils/_array.pyx'],
include_dirs=include_dirs
),
Extension(
name='pmdarima.__check_build._check_build',
sources=['pmdarima/__check_build/_check_build.pyx'],
include_dirs=include_dirs
)
]
else:
# we should only need numpy for building. Everything else can be
# collected via install_requires above
check_package_status('numpy', '1.16')

from numpy.distutils.core import setup
print("Setting up with numpy.distutils.core")
from setuptools import setup, Extension
import numpy
print("Setting up with setuptools")

include_dirs = [numpy.get_include()]
metadata['ext_modules'] = [
Extension(
name='pmdarima.arima._arima',
sources=['pmdarima/arima/_arima.pyx'],
include_dirs=include_dirs
),
Extension(
name='pmdarima.preprocessing.exog._fourier',
sources=['pmdarima/preprocessing/exog/_fourier.pyx'],
include_dirs=include_dirs
),
Extension(
name='pmdarima.utils._array',
sources=['pmdarima/utils/_array.pyx'],
include_dirs=include_dirs
),
Extension(
name='pmdarima.__check_build._check_build',
sources=['pmdarima/__check_build/_check_build.pyx'],
include_dirs=include_dirs
)
]

# add the config to the metadata
metadata['configuration'] = configuration
Expand Down

0 comments on commit 340c621

Please sign in to comment.