Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/pkgs/sagemath-standard/setup.py
4081 views
1
#!/usr/bin/env python
2
3
import os
4
import sys
5
import time
6
# Import setuptools before importing distutils, so that setuptools
7
# can replace distutils by its own vendored copy.
8
import setuptools
9
from distutils import log
10
from setuptools import setup
11
12
# Work around a Cython problem in Python 3.8.x on macOS
13
# https://github.com/cython/cython/issues/3262
14
if os.uname().sysname == 'Darwin':
15
import multiprocessing
16
multiprocessing.set_start_method('fork', force=True)
17
18
# If build isolation is not in use and setuptools_scm is installed,
19
# then its file_finders entry point is invoked, which we don't need.
20
# Workaround from ​https://github.com/pypa/setuptools_scm/issues/190#issuecomment-351181286
21
try:
22
import setuptools_scm.integration
23
setuptools_scm.integration.find_files = lambda _: []
24
except ImportError:
25
pass
26
27
# Different workaround: disable `walk_revctrl` in setuptools
28
# This is needed for setuptools_scm >= 8, should work for any version
29
import setuptools.command.egg_info
30
setuptools.command.egg_info.walk_revctrl = lambda: ()
31
32
#########################################################
33
### Set source directory
34
#########################################################
35
36
# PEP 517 builds do not have . in sys.path
37
sys.path.insert(0, os.path.dirname(__file__))
38
39
import sage.env
40
sage.env.SAGE_SRC = os.getcwd()
41
from sage.env import *
42
43
#########################################################
44
### Configuration
45
#########################################################
46
47
from sage_setup.excepthook import excepthook
48
sys.excepthook = excepthook
49
50
from sage_setup.setenv import setenv
51
setenv()
52
53
from sage_setup.command.sage_build_cython import sage_build_cython
54
from sage_setup.command.sage_build_ext import sage_build_ext
55
from sage_setup.command.sage_install import sage_develop, sage_install
56
57
cmdclass = dict(build_cython=sage_build_cython,
58
build_ext=sage_build_ext,
59
develop=sage_develop,
60
install=sage_install)
61
62
#########################################################
63
### Discovering Sources
64
#########################################################
65
66
if any(x in sys.argv
67
for x in ['build', 'build_ext', 'bdist_wheel', 'install']):
68
log.info("Generating auto-generated sources")
69
from sage_setup.autogen import autogen_all
70
autogen_all()
71
72
# TODO: This should be quiet by default
73
print("Discovering Python/Cython source code....")
74
t = time.time()
75
distributions = ['sagemath-categories',
76
'sagemath-environment',
77
'sagemath-objects',
78
'sagemath-repl',
79
'']
80
log.warn('distributions = {0}'.format(distributions))
81
from sage_setup.find import find_python_sources
82
python_packages, python_modules, cython_modules = find_python_sources(
83
SAGE_SRC, ['sage'], distributions=distributions)
84
85
log.debug('python_packages = {0}'.format(python_packages))
86
log.debug('python_modules = {0}'.format(python_modules))
87
log.debug('cython_modules = {0}'.format(cython_modules))
88
89
print("Discovered Python/Cython sources, time: %.2f seconds." % (time.time() - t))
90
91
#########################################################
92
### Distutils
93
#########################################################
94
95
code = setup(
96
packages=python_packages,
97
cmdclass=cmdclass,
98
ext_modules=cython_modules,
99
)
100
101