|
19 | 19 | from pathlib import Path |
20 | 20 |
|
21 | 21 | import numpy as np |
22 | | -import versioneer |
23 | 22 | from setuptools import Extension, setup |
24 | 23 |
|
25 | | -VERSION = versioneer.get_version() |
26 | | - |
27 | 24 |
|
28 | 25 | def hasfunction(cc, funcname, include=None, extra_postargs=None): |
29 | 26 | """Check for function. |
@@ -92,7 +89,16 @@ def detect_openmp(): |
92 | 89 | mathlib = [] if os.name == "nt" else ["m"] |
93 | 90 |
|
94 | 91 | has_openmp = detect_openmp() |
95 | | - # If we are building a source distribution, the c code is already generated |
| 92 | + |
| 93 | + # There are two cases to consider when running setup.py: |
| 94 | + # 1. We are building from source, so we need cython to generate the .c files |
| 95 | + # from the .pyx files. |
| 96 | + # 2. we are building from a source distribution (sdist), in which case the |
| 97 | + # .c files are included and we don't need Cython. |
| 98 | + # If we are installing from a wheel, the binary is already built and the |
| 99 | + # setup.py is not run at all. |
| 100 | + # We can detect a sdist by checking for the presence of a setup.cfg file, |
| 101 | + # which is generated by setuptools when building the sdist. |
96 | 102 | use_cython = not Path("./setup.cfg").exists() |
97 | 103 | source_suffix = ".pyx" if use_cython else ".c" |
98 | 104 |
|
@@ -120,4 +126,4 @@ def detect_openmp(): |
120 | 126 | if not (Path(source).exists() and os.access(source, os.R_OK)): |
121 | 127 | raise OSError(f"Source file {source!r} not found.") |
122 | 128 |
|
123 | | - setup(cmdclass=versioneer.get_cmdclass(), version=VERSION, ext_modules=extensions) |
| 129 | + setup(use_scm_version=True, ext_modules=extensions) |
0 commit comments