|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +from __future__ import print_function |
| 4 | + |
| 5 | +import os |
| 6 | +import sys |
| 7 | +import time |
| 8 | +from distutils import log |
| 9 | +from distutils.core import setup |
| 10 | + |
| 11 | +# Work around a Cython problem in Python 3.8.x on macOS |
| 12 | +# https://github.com/cython/cython/issues/3262 |
| 13 | +if os.uname().sysname == 'Darwin': |
| 14 | + import multiprocessing |
| 15 | + multiprocessing.set_start_method('fork', force=True) |
| 16 | + |
| 17 | +######################################################### |
| 18 | +### Set source directory |
| 19 | +######################################################### |
| 20 | + |
| 21 | +import sage.env |
| 22 | +sage.env.SAGE_SRC = os.getcwd() |
| 23 | +from sage.env import * |
| 24 | + |
| 25 | +from sage_setup.excepthook import excepthook |
| 26 | +sys.excepthook = excepthook |
| 27 | + |
| 28 | +######################################################### |
| 29 | +### Configuration |
| 30 | +######################################################### |
| 31 | + |
| 32 | +if len(sys.argv) > 1 and sys.argv[1] == "sdist": |
| 33 | + sdist = True |
| 34 | +else: |
| 35 | + sdist = False |
| 36 | + |
| 37 | +######################################################### |
| 38 | +### Testing related stuff |
| 39 | +######################################################### |
| 40 | + |
| 41 | +# Remove (potentially invalid) star import caches |
| 42 | +import sage.misc.lazy_import_cache |
| 43 | +if os.path.exists(sage.misc.lazy_import_cache.get_cache_file()): |
| 44 | + os.unlink(sage.misc.lazy_import_cache.get_cache_file()) |
| 45 | + |
| 46 | + |
| 47 | +from sage_setup.command.sage_build import sage_build |
| 48 | +from sage_setup.command.sage_build_cython import sage_build_cython |
| 49 | +from sage_setup.command.sage_build_ext import sage_build_ext |
| 50 | + |
| 51 | + |
| 52 | +######################################################### |
| 53 | +### Discovering Sources |
| 54 | +######################################################### |
| 55 | + |
| 56 | +# TODO: This should be quiet by default |
| 57 | +print("Discovering Python/Cython source code....") |
| 58 | +t = time.time() |
| 59 | + |
| 60 | +distributions = [''] |
| 61 | + |
| 62 | +from sage_setup.optional_extension import is_package_installed_and_updated |
| 63 | + |
| 64 | +optional_packages_with_extensions = ['mcqd', 'bliss', 'tdlib', 'primecount', |
| 65 | + 'coxeter3', 'fes', 'sirocco', 'meataxe'] |
| 66 | + |
| 67 | +distributions += ['sage-{}'.format(pkg) |
| 68 | + for pkg in optional_packages_with_extensions |
| 69 | + if is_package_installed_and_updated(pkg)] |
| 70 | + |
| 71 | +log.warn('distributions = {0}'.format(distributions)) |
| 72 | + |
| 73 | +from sage_setup.find import find_python_sources |
| 74 | +python_packages, python_modules, cython_modules = find_python_sources( |
| 75 | + SAGE_SRC, ['sage', 'sage_setup'], distributions=distributions) |
| 76 | + |
| 77 | +log.debug('python_packages = {0}'.format(python_packages)) |
| 78 | + |
| 79 | +print("Discovered Python/Cython sources, time: %.2f seconds." % (time.time() - t)) |
| 80 | + |
| 81 | + |
| 82 | +from sage_setup.command.sage_install import sage_install |
| 83 | + |
| 84 | +######################################################### |
| 85 | +### Distutils |
| 86 | +######################################################### |
| 87 | + |
| 88 | +code = setup(name = 'sage', |
| 89 | + version = SAGE_VERSION, |
| 90 | + description = 'Sage: Open Source Mathematics Software', |
| 91 | + license = 'GNU Public License (GPL)', |
| 92 | + author = 'William Stein et al.', |
| 93 | + author_email= 'https://groups.google.com/group/sage-support', |
| 94 | + url = 'https://www.sagemath.org', |
| 95 | + packages = python_packages, |
| 96 | + package_data = { |
| 97 | + 'sage.libs.gap': ['sage.gaprc'], |
| 98 | + 'sage.interfaces': ['sage-maxima.lisp'], |
| 99 | + 'sage.doctest': ['tests/*'], |
| 100 | + 'sage': ['ext_data/*', |
| 101 | + 'ext_data/kenzo/*', |
| 102 | + 'ext_data/singular/*', |
| 103 | + 'ext_data/singular/function_field/*', |
| 104 | + 'ext_data/images/*', |
| 105 | + 'ext_data/doctest/*', |
| 106 | + 'ext_data/doctest/invalid/*', |
| 107 | + 'ext_data/doctest/rich_output/*', |
| 108 | + 'ext_data/doctest/rich_output/example_wavefront/*', |
| 109 | + 'ext_data/gap/*', |
| 110 | + 'ext_data/gap/joyner/*', |
| 111 | + 'ext_data/mwrank/*', |
| 112 | + 'ext_data/notebook-ipython/*', |
| 113 | + 'ext_data/nbconvert/*', |
| 114 | + 'ext_data/graphs/*', |
| 115 | + 'ext_data/pari/*', |
| 116 | + 'ext_data/pari/dokchitser/*', |
| 117 | + 'ext_data/pari/buzzard/*', |
| 118 | + 'ext_data/pari/simon/*', |
| 119 | + 'ext_data/magma/*', |
| 120 | + 'ext_data/magma/latex/*', |
| 121 | + 'ext_data/magma/sage/*', |
| 122 | + 'ext_data/valgrind/*', |
| 123 | + 'ext_data/threejs/*'] |
| 124 | + }, |
| 125 | + scripts = [## The sage script |
| 126 | + 'bin/sage', |
| 127 | + ## Other scripts that should be in the path also for OS packaging of sage: |
| 128 | + 'bin/sage-eval', |
| 129 | + 'bin/sage-runtests', # because it is useful for doctesting user scripts too |
| 130 | + 'bin/sage-fixdoctests', # likewise |
| 131 | + 'bin/sage-coverage', # because it is useful for coverage-testing user scripts too |
| 132 | + 'bin/sage-coverageall', # likewise |
| 133 | + 'bin/sage-cython', # deprecated, might be used in user package install scripts |
| 134 | + ## Helper scripts invoked by sage script |
| 135 | + ## (they would actually belong to something like libexec) |
| 136 | + 'bin/sage-cachegrind', |
| 137 | + 'bin/sage-callgrind', |
| 138 | + 'bin/sage-massif', |
| 139 | + 'bin/sage-omega', |
| 140 | + 'bin/sage-valgrind', |
| 141 | + 'bin/sage-version.sh', |
| 142 | + 'bin/sage-cleaner', |
| 143 | + ## Only makes sense in sage-the-distribution. TODO: Move to another installation script. |
| 144 | + 'bin/sage-list-packages', |
| 145 | + 'bin/sage-download-upstream', |
| 146 | + 'bin/sage-location', |
| 147 | + ## Uncategorized scripts in alphabetical order |
| 148 | + 'bin/math-readline', |
| 149 | + 'bin/sage-env', |
| 150 | + 'bin/sage-env-config', |
| 151 | + # sage-env-config.in -- not to be installed', |
| 152 | + 'bin/sage-gdb-commands', |
| 153 | + 'bin/sage-grep', |
| 154 | + 'bin/sage-grepdoc', |
| 155 | + 'bin/sage-inline-fortran', |
| 156 | + 'bin/sage-ipynb2rst', |
| 157 | + 'bin/sage-ipython', |
| 158 | + 'bin/sage-native-execute', |
| 159 | + 'bin/sage-notebook', |
| 160 | + 'bin/sage-num-threads.py', |
| 161 | + 'bin/sage-open', |
| 162 | + 'bin/sage-preparse', |
| 163 | + 'bin/sage-pypkg-location', |
| 164 | + 'bin/sage-python', |
| 165 | + 'bin/sage-rebase.bat', |
| 166 | + 'bin/sage-rebase.sh', |
| 167 | + 'bin/sage-rebaseall.bat', |
| 168 | + 'bin/sage-rebaseall.sh', |
| 169 | + 'bin/sage-rst2txt', |
| 170 | + 'bin/sage-run', |
| 171 | + 'bin/sage-run-cython', |
| 172 | + 'bin/sage-startuptime.py', |
| 173 | + 'bin/sage-update-src', |
| 174 | + 'bin/sage-update-version', |
| 175 | + 'bin/sage-upgrade', |
| 176 | + ], |
| 177 | + cmdclass = dict(build=sage_build, |
| 178 | + build_cython=sage_build_cython, |
| 179 | + build_ext=sage_build_ext, |
| 180 | + install=sage_install), |
| 181 | + ext_modules = cython_modules) |
0 commit comments