From 90b33d8a76b22ddada6c5be808c7720da8b803a9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 14 Jun 2020 21:03:25 -0700 Subject: [PATCH] Install sagelib, sage_tdlib via sdist defined by MANIFEST.in --- .gitignore | 2 ++ build/pkgs/sagelib/spkg-install | 21 ++++++++++++++++++++- build/pkgs/sagelib/src/MANIFEST.in | 1 + src/MANIFEST.in | 4 ++++ src/sage_setup/command/sage_install.py | 2 +- src/sage_setup/command/sage_install_lib.py | 12 ++++++++++++ src/setup.py | 2 ++ 7 files changed, 42 insertions(+), 2 deletions(-) create mode 120000 build/pkgs/sagelib/src/MANIFEST.in create mode 100644 src/sage_setup/command/sage_install_lib.py diff --git a/.gitignore b/.gitignore index 99b0a8e6dc6..313aef5a8b6 100644 --- a/.gitignore +++ b/.gitignore @@ -104,6 +104,8 @@ gitlab-build-docker.log /build/pkgs/*/src/build /build/pkgs/*/src/dist /build/pkgs/*/src/*.egg-info +/build/pkgs/*/src/MANIFEST +/src/MANIFEST ####################### # tox generated files # diff --git a/build/pkgs/sagelib/spkg-install b/build/pkgs/sagelib/spkg-install index 88c3ad33bce..fa5684c96e7 100755 --- a/build/pkgs/sagelib/spkg-install +++ b/build/pkgs/sagelib/spkg-install @@ -37,7 +37,26 @@ export SAGE_SHARE=/doesnotexist # export SAGE_LOCAL=/doesnotexist # --single-version-externally-managed prevents setuptools from installing an egg -time "$PYTHON" -u setup.py --no-user-cfg build install --single-version-externally-managed --root / || exit 1 +#time "$PYTHON" -u setup.py --no-user-cfg build install --single-version-externally-managed --root / || exit 1 + +# However, setuptools.command.install_lib installs too much (via copy_tree). +# FIXME: This should be fixed by a custom install command provided by sage_setup that uses find_extra_files +# and respects sage_setup + +# Until this is ready, we just build an sdist (driven by MANIFEST.in): +# - build/pkgs/sage_tdlib/src/MANIFEST.in includes/grafts some files/directories, +# - build/pkgs/sagelib/src/MANIFEST.in excludes/prunes the same files/directories. +# Then we pip-install the sdist. + +# (This duplicates the information encoded in the sage_setup directives in the files, +# and is therefore not a good long-term solution.) + +dist_dir="$SAGE_DISTFILES" +sage-python23 -u setup.py --no-user-cfg sdist --dist-dir "$dist_dir" || exit 1 +archive="$dist_dir"/$(sage-python23 -u setup.py --no-user-cfg --fullname | tail -1 2>/dev/null).tar.gz || exit 1 +# TODO: Go through sage-pip-install +sage-python23 -m pip install --ignore-installed --verbose --no-deps --no-index --isolated --no-build-isolation "$archive" || exit 1 + if [ "$UNAME" = "CYGWIN" ]; then sage-rebase.sh "$SAGE_LOCAL" 2>/dev/null; fi diff --git a/build/pkgs/sagelib/src/MANIFEST.in b/build/pkgs/sagelib/src/MANIFEST.in new file mode 120000 index 00000000000..44ab66c52a2 --- /dev/null +++ b/build/pkgs/sagelib/src/MANIFEST.in @@ -0,0 +1 @@ +../../../../src/MANIFEST.in \ No newline at end of file diff --git a/src/MANIFEST.in b/src/MANIFEST.in index ecc887652cb..4550524775b 100644 --- a/src/MANIFEST.in +++ b/src/MANIFEST.in @@ -36,3 +36,7 @@ graft doc/en/prep/media prune doc/en/reference/*/sage prune doc/en/reference/*/sagenb prune doc/output + +# sage-tdlib +exclude sage/graphs/graph_decompositions/tdlib* +prune sage/graphs/graph_decompositions/tdlib diff --git a/src/sage_setup/command/sage_install.py b/src/sage_setup/command/sage_install.py index 47eb5d9c5bd..6922e054644 100644 --- a/src/sage_setup/command/sage_install.py +++ b/src/sage_setup/command/sage_install.py @@ -5,7 +5,7 @@ import os import time from distutils import log -from distutils.command.install import install +from setuptools.command.install import install class sage_install(install): def run(self): diff --git a/src/sage_setup/command/sage_install_lib.py b/src/sage_setup/command/sage_install_lib.py new file mode 100644 index 00000000000..2dd5fd3098a --- /dev/null +++ b/src/sage_setup/command/sage_install_lib.py @@ -0,0 +1,12 @@ +from setuptools.command.install_lib import install_lib + +class sage_install_lib(install_lib): + + def get_exclusions(self): + + exclusions = install_lib.get_exclusions(self) + print("EXCLUSIONS: ", exclusions) + # FIXME: Exclude files outside of the current distribution + return exclusions + + pass diff --git a/src/setup.py b/src/setup.py index 1ba50edf314..20d3ce1dea6 100755 --- a/src/setup.py +++ b/src/setup.py @@ -82,6 +82,7 @@ import Cython.Utils Cython.Utils.is_package_dir = Cython.Build.Cythonize.is_package_dir = Cython.Build.Dependencies.is_package_dir = is_package_or_namespace_package_dir +from sage_setup.command.sage_install_lib import sage_install_lib from sage_setup.command.sage_install import sage_install ######################################################### @@ -128,5 +129,6 @@ cmdclass = dict(build=sage_build, build_cython=sage_build_cython, build_ext=sage_build_ext, + install_lib=sage_install_lib, install=sage_install), ext_modules = cython_modules)