Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
build/pkgs/sagelib: Invoke install cleaner explicitly, remove it from…
Browse files Browse the repository at this point in the history
… pkgs/sagemath-standard/setup.py
  • Loading branch information
Matthias Koeppe committed Nov 27, 2021
1 parent ecc0886 commit 00d5f59
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 7 deletions.
1 change: 1 addition & 0 deletions build/pkgs/sagelib/install-cleaner/LICENSE.txt
1 change: 1 addition & 0 deletions build/pkgs/sagelib/install-cleaner/VERSION.txt
1 change: 1 addition & 0 deletions build/pkgs/sagelib/install-cleaner/build
1 change: 1 addition & 0 deletions build/pkgs/sagelib/install-cleaner/sage
1 change: 1 addition & 0 deletions build/pkgs/sagelib/install-cleaner/setup.cfg
86 changes: 86 additions & 0 deletions build/pkgs/sagelib/install-cleaner/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#!/usr/bin/env python

import os
import sys
import time
# Import setuptools before importing distutils, so that setuptools
# can replace distutils by its own vendored copy.
import setuptools
from distutils import log
from setuptools import setup

#########################################################
### Set source directory
#########################################################

import sage.env
sage.env.SAGE_SRC = os.getcwd()
from sage.env import *

#########################################################
### Configuration
#########################################################

if len(sys.argv) > 1 and (sys.argv[1] == "sdist" or sys.argv[1] == "egg_info"):
sdist = True
else:
sdist = False

if sdist:
cmdclass = {}
else:
from sage_setup.excepthook import excepthook
sys.excepthook = excepthook

from sage_setup.setenv import setenv
setenv()

from sage_setup.command.sage_build import sage_build
from sage_setup.command.sage_build_cython import sage_build_cython
from sage_setup.command.sage_build_ext import sage_build_ext
from sage_setup.command.sage_install import sage_clean

cmdclass = dict(build=sage_build,
build_cython=sage_build_cython,
build_ext=sage_build_ext,
install=sage_clean)

#########################################################
### Discovering Sources
#########################################################

if sdist:
# No need to compute distributions. This avoids a dependency on Cython
# just to make an sdist.
distributions = None
python_packages = []
python_modules = []
cython_modules = []
else:
# TODO: This should be quiet by default
print("Discovering Python/Cython source code....")
t = time.time()
from sage_setup.optional_extension import is_package_installed_and_updated
distributions = ['']
optional_packages_with_extensions = ['mcqd', 'bliss', 'tdlib', 'primecount',
'coxeter3', 'fes', 'sirocco', 'meataxe']
distributions += ['sagemath-{}'.format(pkg)
for pkg in optional_packages_with_extensions
if is_package_installed_and_updated(pkg)]
log.warn('distributions = {0}'.format(distributions))
from sage_setup.find import find_python_sources
python_packages, python_modules, cython_modules = find_python_sources(
SAGE_SRC, ['sage'], distributions=distributions)

log.debug('python_packages = {0}'.format(python_packages))
print("Discovered Python/Cython sources, time: %.2f seconds." % (time.time() - t))


#########################################################
### Distutils
#########################################################

code = setup(
packages = python_packages,
cmdclass = cmdclass,
ext_modules = cython_modules)
5 changes: 4 additions & 1 deletion build/pkgs/sagelib/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ if [ "$SAGE_EDITABLE" = yes ]; then
else
# Likewise, we should remove the egg-link that may have been installed previously.
(cd "$SITEPACKAGESDIR" && rm -f sagemath-standard.egg-link)
time python3 -u setup.py --no-user-cfg build install || exit 1
time python3 -u setup.py --no-user-cfg install || exit 1
# Run the installation cleaner (no longer part of the sagemath-standard install procedure.)
# FIXME: It needs to clean the right build directory!
(cd ../install-cleaner && python3 -u setup.py --no-user-cfg install)
fi

if [ "$UNAME" = "CYGWIN" ]; then
Expand Down
5 changes: 3 additions & 2 deletions build/pkgs/sagelib/spkg-src
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ set -e

cd build/pkgs/sagelib

cd src
python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES"
for src in src*; do
(cd $src && python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES")
done
4 changes: 2 additions & 2 deletions pkgs/sagemath-standard/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
from sage_setup.command.sage_build import sage_build
from sage_setup.command.sage_build_cython import sage_build_cython
from sage_setup.command.sage_build_ext import sage_build_ext
from sage_setup.command.sage_install import sage_install_and_clean
from sage_setup.command.sage_install import sage_install

cmdclass = dict(build=sage_build,
build_cython=sage_build_cython,
build_ext=sage_build_ext,
install=sage_install_and_clean)
install=sage_install)

#########################################################
### Testing related stuff
Expand Down
10 changes: 8 additions & 2 deletions src/sage_setup/command/sage_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def install_kernel_spec(self):
# the install_data directory for installing our Jupyter files.
SageKernelSpec.update(prefix=self.install_data)

class sage_install_and_clean(sage_install):

class sage_clean(install):

def run(self):
sage_install.run(self)
t = time.time()
self.clean_stale_files()
log.info('Finished cleaning, time: %.2f seconds.' % (time.time() - t))
Expand Down Expand Up @@ -85,3 +85,9 @@ def clean_stale_files(self):
dist.ext_modules,
data_files,
nobase_data_files)

class sage_install_and_clean(sage_install, sage_clean):

def run(self):
sage_install.run(self)
sage_clean.run(self)

0 comments on commit 00d5f59

Please sign in to comment.