|
3 | 3 | import os
|
4 | 4 | import sys
|
5 | 5 |
|
6 |
| -if "READTHEDOCS" in os.environ: |
7 |
| - # When building with readthedocs, install the dependencies too. |
8 |
| - # See https://github.com/rtfd/readthedocs.org/issues/2776 |
9 |
| - for reqs in ["requirements.txt"]: |
10 |
| - if os.path.isfile(reqs): |
11 |
| - from subprocess import check_call |
12 |
| - check_call([sys.executable, "-m", "pip", "install", "-r", reqs]) |
13 |
| - |
14 |
| - # Print PARI/GP defaults and environment variables for debugging |
15 |
| - from subprocess import Popen, PIPE |
16 |
| - Popen(["gp", "-f", "-q"], stdin=PIPE).communicate(b"default()") |
17 |
| - for item in os.environ.items(): |
18 |
| - print("%s=%r" % item) |
19 |
| - |
20 |
| - |
21 | 6 | from setuptools import setup
|
22 | 7 | from distutils.command.build_ext import build_ext as _build_ext
|
23 | 8 | from setuptools.command.bdist_egg import bdist_egg as _bdist_egg
|
|
26 | 11 | from autogen import rebuild
|
27 | 12 | from autogen.paths import include_dirs, library_dirs
|
28 | 13 |
|
| 14 | +ext_kwds = dict(include_dirs=include_dirs(), library_dirs=library_dirs()) |
| 15 | + |
| 16 | + |
| 17 | +if "READTHEDOCS" in os.environ: |
| 18 | + # When building with readthedocs, disable optimizations to decrease |
| 19 | + # resource usage during build |
| 20 | + ext_kwds["extra_compile_args"] = ["-O0"] |
| 21 | + |
| 22 | + # Print PARI/GP defaults and environment variables for debugging |
| 23 | + from subprocess import Popen, PIPE |
| 24 | + Popen(["gp", "-f", "-q"], stdin=PIPE).communicate(b"default()") |
| 25 | + for item in os.environ.items(): |
| 26 | + print("%s=%r" % item) |
| 27 | + |
29 | 28 |
|
30 | 29 | # Adapted from Cython's new_build_ext
|
31 | 30 | class build_ext(_build_ext):
|
@@ -76,8 +75,7 @@ def run(self):
|
76 | 75 | author="Luca De Feo, Vincent Delecroix, Jeroen Demeyer, Vincent Klein",
|
77 | 76 |
|
78 | 77 | license='GNU General Public License, version 2 or later',
|
79 |
| - ext_modules=[Extension("*", ["cypari2/*.pyx"], |
80 |
| - include_dirs=include_dirs(), library_dirs=library_dirs())], |
| 78 | + ext_modules=[Extension("*", ["cypari2/*.pyx"], **ext_kwds)], |
81 | 79 | keywords='PARI/GP number theory',
|
82 | 80 | packages=['cypari2'],
|
83 | 81 | package_dir={'cypari2': 'cypari2'},
|
|
0 commit comments