Skip to content

Commit eaa2f0a

Browse files
author
Release Manager
committedAug 12, 2020
Trac #29950: Build sagelib from build/pkgs/sagelib/src, fix setup.py sdist, add spkg-src and tox.ini
As a follow-up to #29411, we set up a separate directory `build/pkgs/sagelib/src` with symlinks into `SAGE_ROOT/src` so that sagelib's `setup.py` does not have access to the whole tree `SAGE_ROOT/src`. We fix `setup.py sdist`, which can be tested using `spkg-src` (which builds a pip-installable tarball in `upstream/`) and `tox`: {{{ ./sage -sh -c '(cd build/pkgs/sagelib/src && tox -v -v)' ./sage -sh -c 'build/pkgs/sagelib/src/.tox/python/bin/sage-ipython' }}} The call of `./sage -sh` is necessary so that `SAGE_LOCAL` is set. Moreover, for scripts that use `sage-env`, also `SAGE_ENV_SOURCED` is crucial for the correct operation; otherwise `sage-env` sets things based on `SAGE_LOCAL` again. URL: https://trac.sagemath.org/29950 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): Dima Pasechnik
2 parents e002ee0 + ccc67b0 commit eaa2f0a

File tree

14 files changed

+100
-45
lines changed

14 files changed

+100
-45
lines changed
 

‎.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ gitlab-build-docker.log
101101
/src/bin/sage-env-config
102102
/build/bin/sage-build-env-config
103103

104+
/build/pkgs/*/src/build
105+
/build/pkgs/*/src/dist
106+
/build/pkgs/*/src/MANIFEST
107+
/build/pkgs/*/src/*.egg-info
108+
/build/pkgs/*/src/.tox
109+
104110
#######################
105111
# tox generated files #
106112
#######################

‎build/make/Makefile.in

+2-2
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ clean:
331331
@echo "Deleting package build directories..."
332332
rm -rf "$(SAGE_LOCAL)/var/tmp/sage/build"
333333

334-
# c_lib .cython_version are from old sage versions
334+
# "c_lib", ".cython_version", "build" in $(SAGE_SRC) are from old sage versions
335335
sagelib-clean:
336336
@echo "Deleting Sage library build artifacts..."
337-
cd "$(SAGE_SRC)" && (rm -rf c_lib .cython_version; rm -rf build; find . -name '*.pyc' | xargs rm -f; rm -rf sage/ext/interpreters)
337+
(cd "$(SAGE_SRC)" && rm -rf c_lib .cython_version; rm -rf build; find . -name '*.pyc' | xargs rm -f; rm -rf sage/ext/interpreters) && (cd "$(SAGE_ROOT)/build/pkgs/sagelib/src/" && rm -rf build)
338338

339339
build-clean: clean doc-clean sagelib-clean
340340

‎build/pkgs/sagelib/spkg-install

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
cd "$SAGE_SRC"
2+
cd src
33
## All sagelib-building is done by setup.py.
44
## This is so that sagelib can be installed by standard Python procedures,
55
## such as "./setup.py install" or "pip install ."

‎build/pkgs/sagelib/spkg-src

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Script to prepare an sdist tarball for sagelib
4+
# This script is not used during build.
5+
#
6+
# HOW TO MAKE THE TARBALL:
7+
# ./sage --sh build/pkgs/sagelib/spkg-src
8+
9+
if [ -z "$SAGE_ROOT" ] ; then
10+
echo >&2 "Error - SAGE_ROOT undefined ... exiting"
11+
echo >&2 "Maybe run 'sage -sh'?"
12+
exit 1
13+
fi
14+
15+
# Exit on failure
16+
set -e
17+
18+
cd build/pkgs/sagelib
19+
20+
cd src
21+
sage-python23 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES"

‎build/pkgs/sagelib/src/MANIFEST.in

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
global-include *.c *.cc *.cpp *.h *.hh *.hpp *.inc *.py *.pyx *.pxd *.pxi *.rst *.txt *.tex
2+
3+
include MANIFEST.in
4+
5+
prune .tox
6+
7+
graft sage/libs/gap/test
8+
prune sage/ext/interpreters # In particular, __init__.py must not be present in the distribution; or sage_setup.autogen.interpreters.rebuild will not generate the code

‎build/pkgs/sagelib/src/bin

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../src/bin
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#sage_conf
2+
#sage_setup
3+
six # use of six should be removed from sage_setup
4+
Cython==0.29.17
5+
pkgconfig
6+
cysignals
7+
gmpy2==2.1.0b1
8+
9+
numpy # already needed by sage.env
10+
jinja2 # sage_setup.autogen.interpreters
11+
12+
cypari2 # but building bdist_wheel of cypari2 fails with recent pip... https://github.com/sagemath/cypari2/issues/93
13+
14+
########## Runtime
15+
16+
psutil
17+
pexpect
18+
pplpy
19+
ipython<=5.8

‎build/pkgs/sagelib/src/sage

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../src/sage

‎build/pkgs/sagelib/src/sage_setup

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../src/sage_setup

‎build/pkgs/sagelib/src/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../src/setup.py

‎build/pkgs/sagelib/src/tox.ini

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# First pip-install tox:
2+
#
3+
# ./sage -pip install tox
4+
#
5+
# To build and test in the tox environment:
6+
#
7+
# ./sage -sh -c '(cd build/pkgs/sagelib/src && tox -v -v)'
8+
#
9+
# To test interactively:
10+
#
11+
# build/pkgs/sagelib/src/.tox/python/bin/python
12+
#
13+
[tox]
14+
15+
[testenv]
16+
deps = -rrequirements.txt
17+
18+
passenv =
19+
SAGE_LOCAL
20+
21+
setenv =
22+
# Sage scripts such as sage-runtests like to use $HOME/.sage
23+
HOME={envdir}
24+
25+
whitelist_externals =
26+
bash
27+
28+
commands =
29+
# Beware of the treacherous non-src layout. "./sage/" shadows the install sage package.
30+
python -c 'import sys; "" in sys.path and sys.path.remove(""); import sage.all; print(sage.all.__file__)'
31+
32+
# FIXME: The following loads sage-env, which loads the wrong Python.
33+
sage -c 'import sys; print("sys.path =", sys.path); import sage.all; print(sage.all.__file__)'
34+
35+
#sage -t --all

‎src/MANIFEST.in

-38
This file was deleted.

‎src/sage_setup/clean.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module
7777
course. We check that when the doctest is being run, that is,
7878
after installation, there are no stale files::
7979
80-
sage: from sage.env import SAGE_SRC, SAGE_LIB
81-
sage: cythonized_dir = os.path.join(SAGE_SRC, "build", "cythonized")
80+
sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_ROOT
81+
sage: cythonized_dir = os.path.join(SAGE_ROOT, "build", "pkgs", "sagelib", "src", "build", "cythonized")
8282
sage: from sage_setup.find import find_python_sources, find_extra_files
8383
sage: python_packages, python_modules, cython_modules = find_python_sources(
8484
....: SAGE_SRC, ['sage', 'sage_setup'])

‎src/sage_setup/find.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[]):
207207
EXAMPLES::
208208
209209
sage: from sage_setup.find import find_extra_files
210-
sage: from sage.env import SAGE_SRC
211-
sage: cythonized_dir = os.path.join(SAGE_SRC, "build", "cythonized")
210+
sage: from sage.env import SAGE_SRC, SAGE_ROOT
211+
sage: cythonized_dir = os.path.join(SAGE_ROOT, "build", "pkgs", "sagelib", "src", "build", "cythonized")
212212
sage: extras = find_extra_files(SAGE_SRC, ["sage"], cythonized_dir)
213213
sage: extras["sage/libs/mpfr"]
214214
[...sage/libs/mpfr/types.pxd...]

0 commit comments

Comments
 (0)
Please sign in to comment.