Skip to content

Commit 39ccf71

Browse files
committed
setup.py: fixes building
1 parent 5334384 commit 39ccf71

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ build-pkg:
3434

3535
build-ext:
3636
@echo "\033[1m>> Building extension... <<\033[0m"
37-
@STOCK_PANDAS_BUILDING=1 python setup.py build_ext --inplace
37+
@STOCK_PANDAS_BUILDING_EXT=1 python setup.py build_ext --inplace
3838

3939
build-doc:
4040
sphinx-build -b html docs build_docs

setup.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import numpy as np
1111

12-
BUILDING = os.environ.get('STOCK_PANDAS_BUILDING')
12+
BUILDING_EXT = os.environ.get('STOCK_PANDAS_BUILDING_EXT')
1313

1414
ext_kwargs = dict(
1515
# Ignore warning caused by cpython for using deprecated apis
@@ -19,7 +19,7 @@
1919

2020
# Distribution ref
2121
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
22-
if BUILDING:
22+
if BUILDING_EXT:
2323
from Cython.Build import cythonize
2424
extensions = cythonize(
2525
Extension(
@@ -33,6 +33,8 @@
3333
'language_level': 3
3434
}
3535
)
36+
37+
# When packaging the package, use the pre-compiled c++ file
3638
else:
3739
extensions = [
3840
Extension(
@@ -42,13 +44,15 @@
4244
)
4345
]
4446

45-
setup(
46-
ext_modules=extensions,
47-
packages=[
48-
'stock_pandas',
49-
'stock_pandas.commands',
50-
'stock_pandas.directive',
51-
'stock_pandas.math',
52-
'stock_pandas.meta'
53-
]
54-
)
47+
# Only run setup when building the package
48+
if __name__ == '__main__':
49+
setup(
50+
ext_modules=extensions,
51+
packages=[
52+
'stock_pandas',
53+
'stock_pandas.commands',
54+
'stock_pandas.directive',
55+
'stock_pandas.math',
56+
'stock_pandas.meta'
57+
]
58+
)

0 commit comments

Comments
 (0)