-
-
Notifications
You must be signed in to change notification settings - Fork 528
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #31377: ./configure --enable-editable
This configure switch will install sagelib in "develop" ("editable", "in-place") mode instead of using sagelib's custom incremental build system. This will clutter the source directory with build artifacts (which are `.gitignore`'d, of course) but it has the benefit that for changes to Python files, one does not need to run `./sage -b`; restarting Sage is enough. It may also have benefits in certain develop environments that get confused by sagelib's nonstandard build system. This ticket is based on a subset of the changes in #30371, which developed a version of `setup.py` suitable for the in-place build. This version is `src/setup.py` and distinct from `build/pkgs/sagelib/src/setup.py`. The configure switch switches to this version of the build system. To test: {{{ ./bootstrap ./configure --enable-editable make build }}} Then use and test as normal. Verify that `local/lib/...site-packages/` no longer contains a copy of `sage` - instead there is an "egg-link" back to the source directory. Switching to a standard build system (getting rid of the sage-specific "installation cleaner") will also simplify the next step of the modularization effort (#29705). URL: https://trac.sagemath.org/31377 Reported by: mkoeppe Ticket author(s): Tobias Diez, Matthias Koeppe Reviewer(s): Matthias Koeppe, Tobias Diez, Jonathan Kliem
- Loading branch information
Showing
16 changed files
with
314 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
AC_ARG_ENABLE([editable], | ||
[AS_HELP_STRING([--enable-editable], | ||
[use an editable install of the Sage library])], | ||
[AC_SUBST([SAGE_EDITABLE], [yes])]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
import multiprocessing | ||
from setuptools.command.build_ext import build_ext | ||
|
||
|
||
class sage_build_ext_minimal(build_ext): | ||
""" | ||
In contrast to :func:`~sage_setup.sage_build_ext.sage_build_ext`, this build extension is designed | ||
to be used in combination with Cython's cythonize function. | ||
Thus, we only take care of some options and letting Cython do the main work. | ||
""" | ||
|
||
def initialize_options(self): | ||
build_ext.initialize_options(self) | ||
self.parallel = self.get_default_number_build_jobs() | ||
|
||
@staticmethod | ||
def get_default_number_build_jobs() -> int: | ||
""" | ||
Get number of parallel build jobs used by default, i.e. unless explicitly | ||
set by the --parallel command line argument of setup.py. | ||
First, the environment variable `SAGE_NUM_THREADS` is checked. | ||
If that is unset, return the number of processors on the system, | ||
with a maximum of 10 (to prevent overloading the system if there a lot of CPUs). | ||
OUTPUT: | ||
number of parallel jobs that should be run | ||
""" | ||
try: | ||
cpu_count = len(os.sched_getaffinity(0)) | ||
except AttributeError: | ||
cpu_count = multiprocessing.cpu_count() | ||
cpu_count = min(cpu_count, 10) | ||
return int(os.environ.get("SAGE_NUM_THREADS", cpu_count)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
def create_extension(template, kwds): | ||
from Cython.Build.Dependencies import default_create_extension | ||
from sage.env import sage_include_directories | ||
|
||
# Add numpy and source folder to the include search path used by the compiler | ||
# This is a workaround for https://github.com/cython/cython/issues/1480 | ||
include_dirs = kwds.get('include_dirs', []) + sage_include_directories(use_sources=True) | ||
kwds['include_dirs'] = include_dirs | ||
return default_create_extension(template, kwds) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.