Skip to content

Commit 944bc97

Browse files
author
Matthias Koeppe
committed
pkgs/sage-conf_conda: Fix setup.py
1 parent ab09607 commit 944bc97

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

pkgs/sage-conf_conda/setup.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import shutil
44
import sysconfig
55
import platform
6+
import fnmatch
7+
8+
from pathlib import Path
69

710
from setuptools import setup
811
from distutils.command.build_scripts import build_scripts as distutils_build_scripts
@@ -25,27 +28,28 @@ def run(self):
2528
arch_tag = f'{system}-{machine}'
2629
# TODO: These two should be user-configurable with options passed to "setup.py install"
2730
SAGE_ROOT = os.path.join(DOT_SAGE, f'sage-{sage_version}-{arch_tag}-conda')
28-
SAGE_LOCAL = os.path.join(SAGE_ROOT, 'local')
31+
32+
def ignore(path, names):
33+
# exclude all embedded src trees
34+
if fnmatch.fnmatch(path, f'*/build/pkgs/*'):
35+
return ['src']
36+
### ignore more stuff --- .tox etc.
37+
return [name for name in names
38+
if name in ('.tox',)]
39+
2940
if os.path.exists(os.path.join(SAGE_ROOT, 'config.status')):
3041
print(f'Reusing SAGE_ROOT={SAGE_ROOT}')
3142
else:
3243
# config.status and other configure output has to be writable.
3344
# So (until the Sage distribution supports VPATH builds - #21469), we have to make a copy of sage_root.
3445
try:
35-
shutil.copytree('sage_root', SAGE_ROOT) # will fail if already exists
36-
except Exception:
37-
raise DistutilsSetupError(f"the directory SAGE_ROOT={SAGE_ROOT} already exists but it is not configured. Please remove it and try again.")
38-
cmd = f"cd {SAGE_ROOT} && {SETENV} && ./configure --prefix={SAGE_LOCAL} --with-python={sys.executable} --enable-build-as-root --enable-download-from-upstream-url --with-system-python3=force --with-sage-venv --disable-notebook --disable-sagelib --disable-sage_conf --disable-doc"
39-
cmd += """
40-
--with-python=$CONDA_PREFIX/bin/python \
41-
--prefix=$CONDA_PREFIX \
42-
--enable-system-site-packages \
43-
$(for pkg in $(./sage -package list :standard: \
44-
--exclude rpy2 \
45-
--has-file spkg-configure.m4 \
46-
--has-file distros/conda.txt); do \
47-
echo --with-system-$pkg=force; \
48-
done)"""
46+
shutil.copytree('sage_root', SAGE_ROOT,
47+
ignore=ignore) # will fail if already exists
48+
except Exception as e:
49+
raise DistutilsSetupError(f"the directory SAGE_ROOT={SAGE_ROOT} already exists but it is not configured. Please remove it and try again. (Exception: {e})")
50+
cmd = f"cd {SAGE_ROOT} && ./configure --enable-build-as-root --with-system-python3=force --disable-notebook --disable-sagelib --disable-sage_conf --disable-doc"
51+
cmd += ' --with-python=$CONDA_PREFIX/bin/python --prefix="$CONDA_PREFIX" --enable-system-site-packages'
52+
cmd += ' $(for pkg in $(build/bin/sage-package list :standard: --exclude rpy2 --has-file spkg-configure.m4 --has-file distros/conda.txt); do echo --with-system-$pkg=force; done)'
4953
print(f"Running {cmd}")
5054
sys.stdout.flush()
5155
if os.system(cmd) != 0:

0 commit comments

Comments
 (0)