Skip to content

Commit 92d6659

Browse files
authored
MAINT, BLD: more setup.py cleanups (scipy#19331)
* deal with the `setup.py`-related `TODO` comment in the `stats` build system surrounding `templated_pyufunc.pxd`, now that we no longer have `setup.py` * remove `setup.py` handling from our coverage config (I think our coverage infrastructure is a bit dormant at the moment in any case) * remove some stray comments/other configs related to `setup.py` * I've avoided some potentially more complex cleanups for now, like `messagestream_config.h.in` (and yes, there are other places in the `meson` build system where we can cleanup, but I'm less confident to tackle those at this time) [skip cirrus]
1 parent 1992efc commit 92d6659

File tree

9 files changed

+21
-50
lines changed

9 files changed

+21
-50
lines changed

.coveragerc

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@
22
branch = True
33
include = */scipy/*
44
omit =
5-
scipy/setup.py
6-
scipy/*/setup.py
75
scipy/signal/_max_len_seq_inner.py
86
disable_warnings = include-ignored

.github/CODEOWNERS

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
# Build related files
1616
pyproject.toml @rgommers
17-
setup.py @rgommers @larsoner
1817
environment.yml @rgommers
1918
meson* @rgommers
2019

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ _configtest.c
5656

5757
# Python files #
5858
################
59-
# setup.py working directory
59+
# build directory
6060
build
6161
# sphinx build directory
6262
doc/_build
6363
# cython files
6464
cythonize.dat
65-
# setup.py dist directory
65+
# sdist directory
6666
dist
6767
# Egg metadata
6868
*.egg-info

scipy/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666

6767
from scipy._lib import _pep440
6868
# In maintenance branch, change to np_maxversion N+3 if numpy is at N
69-
# See setup.py for more details
7069
np_minversion = '1.22.4'
7170
np_maxversion = '9.9.99'
7271
if (_pep440.parse(__numpy_version__) < _pep440.Version(np_minversion) or

scipy/sparse/_generate_sparsetools.py

-3
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,6 @@ def main():
397397
if options.outdir:
398398
# Used by Meson (options.outdir == scipy/sparse/sparsetools)
399399
outdir = os.path.join(os.getcwd(), options.outdir)
400-
else:
401-
# Used by setup.py
402-
outdir = os.path.join(os.path.dirname(__file__), 'sparsetools')
403400

404401
dst = os.path.join(outdir,
405402
unit_name + '_impl.h')

scipy/sparse/linalg/_propack/meson.build

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if use_g77_abi
9191
endif
9292
foreach ele: elements
9393
# PROPACK integration is pretty much broken, see for example gh-15108.
94-
# Note that in setup.py, adding `g77_abi_wrappers` is skipped for 32-bit
94+
# Note that in setup.py, adding `g77_abi_wrappers` was skipped for 32-bit
9595
# architectures (stated reason: "it blows up").
9696
propack_lib = static_library('lib_' + ele[0],
9797
ele[1],

scipy/stats/_boost/include/code_gen.py

+3-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from typing import NamedTuple
44
from warnings import warn
55
from textwrap import dedent
6-
from shutil import copyfile
76
import pathlib
87
import argparse
98

@@ -160,18 +159,10 @@ def _ufunc_gen(scipy_dist: str, types: list, ctor_args: tuple,
160159
args = parser.parse_args()
161160

162161
_boost_dir = pathlib.Path(__file__).resolve().parent.parent
163-
if args.outdir:
164-
src_dir = pathlib.Path(args.outdir)
162+
if not args.outdir:
163+
raise ValueError("A path to the output directory is required")
165164
else:
166-
# We're using setup.py here, not Meson. Create target directory
167-
src_dir = _boost_dir / 'src'
168-
src_dir.mkdir(exist_ok=True, parents=True)
169-
170-
# copy contents of include into directory to satisfy Cython
171-
# PXD include conditions
172-
inc_dir = _boost_dir / 'include'
173-
src = 'templated_pyufunc.pxd'
174-
copyfile(inc_dir / src, src_dir / src)
165+
src_dir = pathlib.Path(args.outdir)
175166

176167
# generate the PXD and PYX wrappers
177168
_gen_func_defs_pxd(

scipy/stats/_generate_pyx.py

+4-13
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@
55
import argparse
66

77

8-
def make_boost(outdir, distutils_build=False):
8+
def make_boost(outdir):
99
# Call code generator inside _boost directory
1010
code_gen = pathlib.Path(__file__).parent / '_boost/include/code_gen.py'
11-
if distutils_build:
12-
subprocess.run([sys.executable, str(code_gen), '-o', outdir,
13-
'--distutils-build', 'True'], check=True)
14-
else:
15-
subprocess.run([sys.executable, str(code_gen), '-o', outdir],
16-
check=True)
11+
subprocess.run([sys.executable, str(code_gen), '-o', outdir],
12+
check=True)
1713

1814

1915
if __name__ == '__main__':
@@ -23,12 +19,7 @@ def make_boost(outdir, distutils_build=False):
2319
args = parser.parse_args()
2420

2521
if not args.outdir:
26-
# We're dealing with a distutils build here, write in-place:
27-
outdir_abs = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
28-
outdir_abs_boost = outdir_abs / '_boost' / 'src'
29-
if not os.path.exists(outdir_abs_boost):
30-
os.makedirs(outdir_abs_boost)
31-
make_boost(outdir_abs_boost, distutils_build=True)
22+
raise ValueError("A path to the output directory is required")
3223
else:
3324
# Meson build
3425
srcdir_abs = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))

scipy/stats/meson.build

+11-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ _stats_pxd = [
22
fs.copyfile('__init__.py'),
33
fs.copyfile('_stats.pxd'),
44
fs.copyfile('_biasedurn.pxd'),
5+
fs.copyfile('_boost/include/templated_pyufunc.pxd'),
56
]
67

78
stats_special_cython_gen = generator(cython,
@@ -81,12 +82,11 @@ _stats_gen_pyx = custom_target('_stats_gen_pyx',
8182
'func_defs.pxd', # 2 (S_B)
8283
'hypergeom_ufunc.pyx', # 3 (S_B)
8384
'nbinom_ufunc.pyx', # 4 (S_B)
84-
'templated_pyufunc.pxd', # 5 (S_B)
85-
'ncf_ufunc.pyx', # 6 (S_B)
86-
'ncx2_ufunc.pyx', # 7 (S_B)
87-
'nct_ufunc.pyx', # 8 (S_B)
88-
'skewnorm_ufunc.pyx', # 9 (S_B)
89-
'invgauss_ufunc.pyx', # 10 (S_B)
85+
'ncf_ufunc.pyx', # 5 (S_B)
86+
'ncx2_ufunc.pyx', # 6 (S_B)
87+
'nct_ufunc.pyx', # 7 (S_B)
88+
'skewnorm_ufunc.pyx', # 8 (S_B)
89+
'invgauss_ufunc.pyx', # 9 (S_B)
9090
],
9191
input: '_generate_pyx.py',
9292
command: [py3, '@INPUT@', '-o', '@OUTDIR@'],
@@ -95,10 +95,6 @@ _stats_gen_pyx = custom_target('_stats_gen_pyx',
9595
'_boost/include/code_gen.py',
9696
'_boost/include/gen_func_defs_pxd.py',
9797
'_boost/include/_info.py',
98-
# TODO: once setup.py is gone, remove this .pxd file from here and from the
99-
# output of this custom_target, and stop copying it manually in
100-
# code_gen.py. Instead, use fs.copyfile at the top of this file.
101-
'_boost/include/templated_pyufunc.pxd',
10298
]
10399
)
104100

@@ -121,11 +117,11 @@ beta_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[0])
121117
binom_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[1])
122118
hypergeom_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[3])
123119
nbinom_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[4])
124-
ncf_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[6])
125-
ncx2_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[7])
126-
nct_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[8])
127-
skewnorm_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[9])
128-
invgauss_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[10])
120+
ncf_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[5])
121+
ncx2_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[6])
122+
nct_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[7])
123+
skewnorm_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[8])
124+
invgauss_ufunc_pyx = cython_stats_gen_cpp.process(_stats_gen_pyx[9])
129125

130126

131127
biasedurn = py3.extension_module('_biasedurn',

0 commit comments

Comments
 (0)