diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a6b7691a817..3d9f331a252 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -91,7 +91,7 @@ jobs: - "src/sage/[a-f]*" - "src/sage/[g-o]*" - "src/sage/[p-z]*" - - "src/doc src/sage_docbuild src/sage_setup" + - "src/doc src/sage_docbuild" steps: - name: Maximize build disk space uses: easimon/maximize-build-space@v10 diff --git a/.github/workflows/ci-distro.yml b/.github/workflows/ci-distro.yml index c7957050fa6..b9b59c5f278 100644 --- a/.github/workflows/ci-distro.yml +++ b/.github/workflows/ci-distro.yml @@ -22,7 +22,6 @@ on: - 'configure.ac' - '!build/pkgs/sage_conf/**' - '!build/pkgs/sage_docbuild/**' - - '!build/pkgs/sage_setup/**' - '!build/pkgs/sage_sws2rst/**' - '!build/pkgs/sagelib/**' - '!build/pkgs/sagemath_*/**' diff --git a/.github/workflows/ci-meson.yml b/.github/workflows/ci-meson.yml index 83b92739c59..62010262f40 100644 --- a/.github/workflows/ci-meson.yml +++ b/.github/workflows/ci-meson.yml @@ -161,10 +161,6 @@ jobs: - name: Test shell: bash -l {0} run: | - # We don't install sage_setup, so don't try to test it - # If editable then deleting the directory will cause sage to detect rebuild, which will cause ninja to fail - # so we don't delete the directory in this case - ${{ matrix.editable && 'true' || 'rm -R ./src/sage_setup/' }} if [[ "$RUNNER_OS" == "Windows" ]]; then # Ignore errors on Windows, for now pytest --doctest-ignore-import-errors --doctest -rfEs -s src || true diff --git a/.gitignore b/.gitignore index 51cf481afa1..5aa03c2c60a 100644 --- a/.gitignore +++ b/.gitignore @@ -140,11 +140,6 @@ __pycache__/ **/*.py[cod] *$py.class -# Generated by sage_setup.autogen -/src/sage/ext/interpreters -!/src/sage/ext/interpreters/meson.build -!/src/sage/ext/interpreters/README - # Generated Cython files *.so **/*.so @@ -317,6 +312,7 @@ subprojects/packagecache src/sage/interfaces/__init__.py src/sage/crypto/block_cipher/__init__.py src/sage/crypto/public_key/__init__.py +src/sage/ext/interpreters/__init__.py src/sage/logic/__init__.py src/sage/parallel/__init__.py src/sage/dynamics/cellular_automata/__init__.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 887f416bfc4..d0f64abe241 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,9 +10,7 @@ // Exclude symbolic links into SAGE_ROOT/src/ "pkgs/sage-conf_pypi/sage_root": true, "pkgs/sage-docbuild/sage_docbuild": true, - "pkgs/sage-setup/sage_setup": true, "pkgs/sagemath-*/sage": true, - "pkgs/sagemath-*/sage_setup": true }, "python.testing.pytestEnabled": true, "python.testing.pytestArgs": [ diff --git a/Makefile b/Makefile index 06a87e8f265..14c0fb966a6 100644 --- a/Makefile +++ b/Makefile @@ -131,9 +131,6 @@ sagelib-clean: sage_docbuild-clean: (cd "$(SAGE_ROOT)/build/pkgs/sage_docbuild/src" && rm -rf build) -sage_setup-clean: - (cd "$(SAGE_ROOT)/build/pkgs/sage_setup/src" && rm -rf build) - build-clean: clean doc-clean sagelib-clean sage_docbuild-clean doc-clean: diff --git a/build/make/Makefile.in b/build/make/Makefile.in index db7394b44cc..32f8e24b895 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -749,7 +749,7 @@ $(1)-uninstall: $(1)-$(4)-uninstall $(1)-clean: $(1)-uninstall -$(1)-sdist: FORCE python_build sage_setup cython +$(1)-sdist: FORCE python_build cython $(AM_V_at) cd '$$(SAGE_ROOT)' && \ . '$$(SAGE_ROOT)/src/bin/sage-src-env-config' && \ . '$$(SAGE_ROOT)/src/bin/sage-env-config' && \ diff --git a/build/pkgs/sage_setup/SPKG.rst b/build/pkgs/sage_setup/SPKG.rst deleted file mode 120000 index b4545b4bda6..00000000000 --- a/build/pkgs/sage_setup/SPKG.rst +++ /dev/null @@ -1 +0,0 @@ -src/README.rst \ No newline at end of file diff --git a/build/pkgs/sage_setup/dependencies b/build/pkgs/sage_setup/dependencies deleted file mode 100644 index 497a8118c28..00000000000 --- a/build/pkgs/sage_setup/dependencies +++ /dev/null @@ -1,4 +0,0 @@ - cython pkgconfig jinja2 $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/autogen/interpreters/internal/specs/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/command/*.py | $(PYTHON_TOOLCHAIN) $(PYTHON) - ----------- -All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_setup/package-version.txt b/build/pkgs/sage_setup/package-version.txt deleted file mode 120000 index c4fcb84c1a7..00000000000 --- a/build/pkgs/sage_setup/package-version.txt +++ /dev/null @@ -1 +0,0 @@ -../../../VERSION.txt \ No newline at end of file diff --git a/build/pkgs/sage_setup/spkg-install.in b/build/pkgs/sage_setup/spkg-install.in deleted file mode 100644 index da7d7a2870f..00000000000 --- a/build/pkgs/sage_setup/spkg-install.in +++ /dev/null @@ -1,9 +0,0 @@ -cd src -if [ "$SAGE_EDITABLE" = yes ]; then - sdh_pip_editable_install . - if [ "$SAGE_WHEELS" = yes ]; then - sdh_build_and_store_wheel --no-isolation . - fi -else - sdh_pip_install . -fi diff --git a/build/pkgs/sage_setup/spkg-src b/build/pkgs/sage_setup/spkg-src deleted file mode 100755 index 1b137206a5c..00000000000 --- a/build/pkgs/sage_setup/spkg-src +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -# -# Script to prepare an sdist tarball for sage_setup -# This script is not used during build. -# -# HOW TO MAKE THE TARBALL: -# ./sage --sh build/pkgs/sage_setup/spkg-src - -if [ -z "$SAGE_ROOT" ] ; then - echo >&2 "Error - SAGE_ROOT undefined ... exiting" - echo >&2 "Maybe run 'sage -sh'?" - exit 1 -fi - -# Exit on failure -set -e - -cd build/pkgs/sage_setup - -cd src -# Get rid of old *.egg-info/SOURCES.txt -rm -Rf *.egg-info - -python3 -m build --sdist --no-isolation --skip-dependency-check --outdir "$SAGE_DISTFILES" diff --git a/build/pkgs/sage_setup/src b/build/pkgs/sage_setup/src deleted file mode 120000 index 60bb9a77ef9..00000000000 --- a/build/pkgs/sage_setup/src +++ /dev/null @@ -1 +0,0 @@ -../../../pkgs/sage-setup \ No newline at end of file diff --git a/build/pkgs/sage_setup/type b/build/pkgs/sage_setup/type deleted file mode 100644 index a6a7b9cd726..00000000000 --- a/build/pkgs/sage_setup/type +++ /dev/null @@ -1 +0,0 @@ -standard diff --git a/build/pkgs/sage_setup/version_requirements.txt b/build/pkgs/sage_setup/version_requirements.txt deleted file mode 100644 index 6a3f93ce1b7..00000000000 --- a/build/pkgs/sage_setup/version_requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -# This file is updated on every release by the update-version script -sage-setup ~= 10.8b4 diff --git a/build/pkgs/sagelib/spkg-install.in b/build/pkgs/sagelib/spkg-install.in index 0b5d45e35ca..dae51c695da 100644 --- a/build/pkgs/sagelib/spkg-install.in +++ b/build/pkgs/sagelib/spkg-install.in @@ -29,9 +29,6 @@ export SAGE_DOC_SRC=/doesnotexist export SAGE_PKGCONFIG=/doesnotexist export SAGE_SHARE=/doesnotexist -# However, we only unset SAGE_PKG_CONFIG_PATH. -# sage_setup.setenv receives them from sage_conf via sage.env; -# the poisoned environment variables would override them. unset SAGE_PKG_CONFIG_PATH # Issue #30903: We cannot poison SAGE_DOC because setup.py installs the Jupyter kernel diff --git a/configure.ac b/configure.ac index f147b79bd98..b0c9a4e06bb 100644 --- a/configure.ac +++ b/configure.ac @@ -543,7 +543,7 @@ AC_ARG_ENABLE([doc], AC_ARG_ENABLE([sagelib], AS_HELP_STRING([--disable-sagelib], [disable build of the Sage library and packages depending on it]), [ - for pkg in sagelib sage_docbuild sage_setup; do + for pkg in sagelib sage_docbuild; do AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval]) done ]) diff --git a/conftest.py b/conftest.py index 5ab4ef025d4..8f9bb8deea1 100644 --- a/conftest.py +++ b/conftest.py @@ -11,7 +11,7 @@ import inspect import sys import warnings -from typing import Any, Iterable, Optional, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Iterable, Optional import pytest from _pytest.doctest import ( @@ -280,7 +280,6 @@ def pytest_ignore_collect( root = config.rootpath if ( is_subpath(collection_path, root / "src" / "sage_docbuild") - or is_subpath(collection_path, root / "src" / "sage_setup") or collection_path == root / "src" / "build-docs.py" ): # Fails to import with Meson @@ -390,8 +389,8 @@ def tmpfile(): * https://github.com/pytest-dev/pytest/issues/13669 """ - from tempfile import NamedTemporaryFile from os import unlink + from tempfile import NamedTemporaryFile t = NamedTemporaryFile(delete=False) yield t unlink(t.name) diff --git a/constraints_pkgs.txt b/constraints_pkgs.txt deleted file mode 100644 index e68a35fa3ad..00000000000 --- a/constraints_pkgs.txt +++ /dev/null @@ -1,38 +0,0 @@ -# This "constraints file" can be used for forcing pip -# (and any tools that delegate to pip, such as pypa/build) -# to install the distribution packages included in -# the SageMath monorepository only from their source trees -# in SAGE_ROOT/pkgs/ instead of from PyPI. -# -# Example: Building a sagemath-standard wheel -# -# [alice@localhost sage]$ ./bootstrap -# [alice@localhost sage]$ ./configure -# [alice@localhost sage]$ export MAKE="make -j16" SAGE_NUM_THREADS=16 -# [alice@localhost sage]$ make all-sage-local -# [alice@localhost sage]$ export PIP_CONSTRAINT="$(pwd)/constraints_pkgs.txt" -# [alice@localhost sage]$ ./sage -sh -c 'python3 -m build -v -v pkgs/sagemath-standard' -# -# Non-example: Installing the built wheel using the same -# constraints file will fail because sagemath-standard is one -# of the distribution packages listed below. It will conflict -# with the built wheel for sagemath-standard! -# Use "pkgs/sagemath-standard/constraints_pkgs.txt" instead. - -# Reference on the format: -# https://pip.pypa.io/en/stable/user_guide/#constraints-files -# -sage_conf @ file://${SAGE_ROOT}/pkgs/sage-conf -sage_docbuild @ file://${SAGE_ROOT}/pkgs/sage-docbuild -sage_setup @ file://${SAGE_ROOT}/pkgs/sage-setup -sagemath-bliss @ file://${SAGE_ROOT}/pkgs/sagemath-bliss -sagemath-categories @ file://${SAGE_ROOT}/pkgs/sagemath-categories -sagemath-coxeter3 @ file://${SAGE_ROOT}/pkgs/sagemath-coxeter3 -sagemath-environment @ file://${SAGE_ROOT}/pkgs/sagemath-environment -sagemath-mcqd @ file://${SAGE_ROOT}/pkgs/sagemath-mcqd -sagemath-meataxe @ file://${SAGE_ROOT}/pkgs/sagemath-meataxe -sagemath-objects @ file://${SAGE_ROOT}/pkgs/sagemath-objects -sagemath-repl @ file://${SAGE_ROOT}/pkgs/sagemath-repl -sagemath-sirocco @ file://${SAGE_ROOT}/pkgs/sagemath-sirocco -sagemath-standard @ file://${SAGE_ROOT}/pkgs/sagemath-standard -sagemath-tdlib @ file://${SAGE_ROOT}/pkgs/sagemath-tdlib diff --git a/pkgs/sage-setup/README.rst b/pkgs/sage-setup/README.rst deleted file mode 100644 index 4d6f4106546..00000000000 --- a/pkgs/sage-setup/README.rst +++ /dev/null @@ -1,4 +0,0 @@ -sage-setup: Build system of the SageMath library -================================================ - -This is the build system of the Sage library, based on setuptools. diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt deleted file mode 100644 index dfd31477943..00000000000 --- a/pkgs/sage-setup/VERSION.txt +++ /dev/null @@ -1 +0,0 @@ -10.8.beta5 diff --git a/pkgs/sage-setup/pyproject.toml b/pkgs/sage-setup/pyproject.toml deleted file mode 100644 index 820da4fbbeb..00000000000 --- a/pkgs/sage-setup/pyproject.toml +++ /dev/null @@ -1,49 +0,0 @@ -[build-system] -requires = ["setuptools>=61.2"] -build-backend = "setuptools.build_meta" - -[project] -name = "sage-setup" -description = "Sage: Open Source Mathematics Software: Build system of the Sage library" -license = {text = "GNU General Public License (GPL) v2 or later"} -authors = [{name = "The Sage Developers", email = "sage-support@googlegroups.com"}] -classifiers = [ - "Development Status :: 6 - Mature", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", - "Operating System :: POSIX", - "Operating System :: MacOS :: MacOS X", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Scientific/Engineering :: Mathematics", -] -urls = {Homepage = "https://www.sagemath.org"} -requires-python = ">=3.9, <3.14" -dependencies = [] -dynamic = ["version"] - -[project.readme] -file = "README.rst" -content-type = "text/x-rst" - -[project.optional-dependencies] -autogen = ["jinja2"] - -[tool.setuptools] -packages = [ - "sage_setup", - "sage_setup.autogen", - "sage_setup.autogen.interpreters", - "sage_setup.autogen.interpreters.internal", - "sage_setup.autogen.interpreters.internal.specs", - "sage_setup.command", -] -include-package-data = false - -[tool.setuptools.dynamic] -version = {file = ["VERSION.txt"]} diff --git a/pkgs/sage-setup/requirements.txt b/pkgs/sage-setup/requirements.txt deleted file mode 100644 index 3853e7d55b7..00000000000 --- a/pkgs/sage-setup/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Cython -pkgconfig -jinja2 diff --git a/pkgs/sage-setup/sage_setup b/pkgs/sage-setup/sage_setup deleted file mode 120000 index 88b8133df49..00000000000 --- a/pkgs/sage-setup/sage_setup +++ /dev/null @@ -1 +0,0 @@ -../../src/sage_setup \ No newline at end of file diff --git a/pkgs/sage-setup/setup.py b/pkgs/sage-setup/setup.py deleted file mode 100644 index cd42da33ffe..00000000000 --- a/pkgs/sage-setup/setup.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup -from setuptools.dist import Distribution - -# setuptools plugins considered harmful: -# If build isolation is not in use and setuptools_scm is installed, -# then its file_finders entry point is invoked, which we don't need. -# And with setuptools_scm 8, we get more trouble: -# LookupError: pyproject.toml does not contain a tool.setuptools_scm section -# LookupError: setuptools-scm was unable to detect version ... -# We just remove all handling of "setuptools.finalize_distribution_options" entry points. -Distribution._removed = staticmethod(lambda ep: True) - -setup() diff --git a/pkgs/sage-setup/tox.ini b/pkgs/sage-setup/tox.ini deleted file mode 100644 index e8a22f03101..00000000000 --- a/pkgs/sage-setup/tox.ini +++ /dev/null @@ -1,40 +0,0 @@ -# First pip-install tox: -# -# ./sage -pip install tox -# -# To build and test in the tox environment: -# -# ./sage -sh -c '(cd pkgs/sage-setup && tox -e sagepython)' -# -# To test interactively: -# -# pkgs/sage-setup/.tox/sagepython/bin/python -# -[tox] - -requires = - # Because of https://github.com/tox-dev/tox/issues/3238, need <4.14.1 - tox<4.14.1 - -[testenv] -deps = -rrequirements.txt - -setenv = - # Sage scripts such as sage-runtests like to use $HOME/.sage - HOME={envdir} - -allowlist_externals = - bash - -commands = - # Beware of the treacherous non-src layout. - python -c 'import sys; "" in sys.path and sys.path.remove(""); import sage_setup; import sage_setup.find' - -# TODO: Test importing sage_setup.library_order -- when that can handle missing pkgconfig libraries... -# TODO: Test more modules -- when the dependency on sage.env has been removed... - -[testenv:sagepython] -passenv = - SAGE_VENV - -basepython = {env:SAGE_VENV}/bin/python3 diff --git a/pkgs/sagemath-bliss/pyproject.toml.m4 b/pkgs/sagemath-bliss/pyproject.toml.m4 index 40bfebf2489..4857c047d55 100644 --- a/pkgs/sagemath-bliss/pyproject.toml.m4 +++ b/pkgs/sagemath-bliss/pyproject.toml.m4 @@ -4,7 +4,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- requires = [ SPKG_INSTALL_REQUIRES_setuptools SPKG_INSTALL_REQUIRES_sage_conf - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython SPKG_INSTALL_REQUIRES_cysignals diff --git a/pkgs/sagemath-categories/pyproject.toml.m4 b/pkgs/sagemath-categories/pyproject.toml.m4 index edbafa59242..acfe26288fe 100644 --- a/pkgs/sagemath-categories/pyproject.toml.m4 +++ b/pkgs/sagemath-categories/pyproject.toml.m4 @@ -4,7 +4,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- requires = [ SPKG_INSTALL_REQUIRES_setuptools SPKG_INSTALL_REQUIRES_wheel - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_sagemath_objects SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-coxeter3/pyproject.toml.m4 b/pkgs/sagemath-coxeter3/pyproject.toml.m4 index 58d4483f8bd..c507e53ff16 100644 --- a/pkgs/sagemath-coxeter3/pyproject.toml.m4 +++ b/pkgs/sagemath-coxeter3/pyproject.toml.m4 @@ -3,7 +3,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- # Minimum requirements for the build system to execute. requires = [ SPKG_INSTALL_REQUIRES_setuptools - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_sagemath_objects SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-mcqd/pyproject.toml.m4 b/pkgs/sagemath-mcqd/pyproject.toml.m4 index 55a58611334..e1c49d1c6b4 100644 --- a/pkgs/sagemath-mcqd/pyproject.toml.m4 +++ b/pkgs/sagemath-mcqd/pyproject.toml.m4 @@ -3,7 +3,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- # Minimum requirements for the build system to execute. requires = [ SPKG_INSTALL_REQUIRES_setuptools - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython SPKG_INSTALL_REQUIRES_memory_allocator diff --git a/pkgs/sagemath-meataxe/pyproject.toml.m4 b/pkgs/sagemath-meataxe/pyproject.toml.m4 index fdbcd55424f..012a40357c5 100644 --- a/pkgs/sagemath-meataxe/pyproject.toml.m4 +++ b/pkgs/sagemath-meataxe/pyproject.toml.m4 @@ -3,7 +3,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- # Minimum requirements for the build system to execute. requires = [ SPKG_INSTALL_REQUIRES_setuptools - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_sagemath_objects SPKG_INSTALL_REQUIRES_cython diff --git a/pkgs/sagemath-objects/pyproject.toml.m4 b/pkgs/sagemath-objects/pyproject.toml.m4 index 68cfbafe935..02a892f991a 100644 --- a/pkgs/sagemath-objects/pyproject.toml.m4 +++ b/pkgs/sagemath-objects/pyproject.toml.m4 @@ -4,7 +4,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- requires = [ SPKG_INSTALL_REQUIRES_setuptools SPKG_INSTALL_REQUIRES_wheel - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython SPKG_INSTALL_REQUIRES_gmpy2 diff --git a/pkgs/sagemath-sirocco/pyproject.toml.m4 b/pkgs/sagemath-sirocco/pyproject.toml.m4 index 6f2874254ab..289a5448e1c 100644 --- a/pkgs/sagemath-sirocco/pyproject.toml.m4 +++ b/pkgs/sagemath-sirocco/pyproject.toml.m4 @@ -3,7 +3,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- # Minimum requirements for the build system to execute. requires = [ SPKG_INSTALL_REQUIRES_setuptools - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython SPKG_INSTALL_REQUIRES_cypari diff --git a/pkgs/sagemath-tdlib/pyproject.toml.m4 b/pkgs/sagemath-tdlib/pyproject.toml.m4 index d3efaf52cc1..9c96c888bb5 100644 --- a/pkgs/sagemath-tdlib/pyproject.toml.m4 +++ b/pkgs/sagemath-tdlib/pyproject.toml.m4 @@ -3,7 +3,6 @@ include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*- # Minimum requirements for the build system to execute. requires = [ SPKG_INSTALL_REQUIRES_setuptools - SPKG_INSTALL_REQUIRES_sage_setup SPKG_INSTALL_REQUIRES_sagemath_environment SPKG_INSTALL_REQUIRES_cython SPKG_INSTALL_REQUIRES_cysignals diff --git a/pyproject.toml b/pyproject.toml index 1a9c5db0f0d..9382e6e0f80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -109,7 +109,7 @@ sage = "sage.cli:main" platforms = ['linux-64', 'linux-aarch64', 'osx-64', 'osx-arm64'] [tool.pytest.ini_options] -norecursedirs = "local prefix venv build builddir pkgs .git src/doc src/bin src/sage_setup/autogen/flint tools subprojects" +norecursedirs = "local prefix venv build builddir pkgs .git src/doc src/bin tools subprojects" python_files = "*_test.py" # The "no:warnings" is to stop pytest from capturing warnings so that they are printed to the output of the doctest addopts = "--import-mode importlib -p no:warnings" diff --git a/src/bin/sage-list-packages b/src/bin/sage-list-packages index 637fab8dd4f..2ed39516814 100755 --- a/src/bin/sage-list-packages +++ b/src/bin/sage-list-packages @@ -4,10 +4,10 @@ Script to list the Sage packages This is script can be called with one argument which might be either "all", "standard", "optional", or "experimental". It is mostly a -script interface to sage_setup.packages.list_packages. +script interface to sage.misc.package.list_packages. """ -import os import argparse +import os if "SAGE_ROOT" not in os.environ: raise RuntimeError("The environment variable SAGE_ROOT must be set.") diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index 6a17db917ef..ca26108a445 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -874,11 +874,6 @@ def all_installed_modules(): self.log("Doctesting all installed modules of the Sage library.") import sage self.files.extend(sage.__path__) - try: - import sage_setup - self.files.extend(sage_setup.__path__) - except ImportError: - pass try: import sage_docbuild self.files.extend(sage_docbuild.__path__) @@ -895,15 +890,10 @@ def all_files(): return all_installed_modules() self.log("Doctesting entire Sage library.") self.files.append(opj(SAGE_SRC, 'sage')) - # Only test sage_setup and sage_docbuild if the relevant + # Only test sage_docbuild if the relevant # imports work. They may not work if not in a build # environment or if the documentation build has been # disabled. - try: - import sage_setup - self.files.append(opj(SAGE_SRC, 'sage_setup')) - except ImportError: - pass try: import sage_docbuild self.files.append(opj(SAGE_SRC, 'sage_docbuild')) diff --git a/src/sage/ext/interpreters/README b/src/sage/ext/interpreters/README deleted file mode 100644 index 1e42d921e68..00000000000 --- a/src/sage/ext/interpreters/README +++ /dev/null @@ -1 +0,0 @@ -The files in this directory, except meson.build, are autogenerated by sage_setup.autogen diff --git a/src/sage/ext/interpreters/meson.build b/src/sage/ext/interpreters/meson.build index f965ce83da0..53c916d3fb4 100644 --- a/src/sage/ext/interpreters/meson.build +++ b/src/sage/ext/interpreters/meson.build @@ -23,8 +23,8 @@ interpreters = custom_target( 'interp_rr.c', '__init__.py', ], - input: '../../../sage_setup/autogen/interpreters/internal/__init__.py', - command: ['../../../sage_setup/autogen/interpreters/__main__.py', '@OUTDIR@'], + input: '../../../../tools/autogen/interpreters/internal/__init__.py', + command: ['../../../../tools/autogen/interpreters/__main__.py', '@OUTDIR@'], # Manually install the generated files instead of using install_sources # this is a workaround for https://github.com/mesonbuild/meson/issues/7372 install: true, diff --git a/src/sage_setup/autogen/interpreters/internal/specs/__init__.py b/src/sage_setup/autogen/interpreters/internal/specs/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/sage_setup/command/__init__.py b/src/sage_setup/command/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/sage_setup/command/sage_build_cython.py b/src/sage_setup/command/sage_build_cython.py deleted file mode 100644 index 2e04bd80f87..00000000000 --- a/src/sage_setup/command/sage_build_cython.py +++ /dev/null @@ -1,313 +0,0 @@ -######################################################################## -## -## Customize the Extensions processed by Cython -## -######################################################################## - -import os -import sys -import time -import json - -# 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 Command - -from sage_setup.util import stable_uniq -from sage_setup.find import find_extra_files -from sage_setup.cython_options import compiler_directives, compile_time_env_variables - -# Do not put all, but only the most common libraries and their headers -# (that are likely to change on an upgrade) here: -# [At least at the moment. Make sure the headers aren't copied with "-p", -# or explicitly touch them in the respective spkg's spkg-install.] -lib_headers = dict() - -# Set by build/bin/sage-build-env-config. Empty if the system package is used. -gmp_prefix = os.environ.get("SAGE_GMP_PREFIX", "") -if gmp_prefix: - lib_headers["gmp"] = [os.path.join(gmp_prefix, 'include', 'gmp.h')] # cf. #8664, #9896 - lib_headers["gmpxx"] = [os.path.join(gmp_prefix, 'include', 'gmpxx.h')] -ntl_prefix = os.environ.get("SAGE_NTL_PREFIX", "") -if ntl_prefix: - lib_headers["ntl"] = [os.path.join(ntl_prefix, 'include', 'NTL', 'config.h')] - -# Manually add -fno-strict-aliasing, which is needed to compile Cython -# and disappears from the default flags if the user has set CFLAGS. -# -# Add -DCYTHON_CLINE_IN_TRACEBACK=1 which causes the .c line number to -# always appear in exception tracebacks (by default, this is a runtime -# setting in Cython which causes some overhead every time an exception -# is raised). -extra_compile_args = ["-fno-strict-aliasing", "-DCYTHON_CLINE_IN_TRACEBACK=1"] -extra_link_args = [ ] - -DEVEL = False -if DEVEL: - extra_compile_args.append('-ggdb') - - -class sage_build_cython(Command): - name = 'build_cython' - description = "compile Cython extensions into C/C++ extensions" - - user_options = [ - # TODO: Temporarily disabled since the value for this option is - # hard-coded; change as part of work on #21525 - #('build-dir=', 'd', - # "directory for compiled C/C++ sources and header files"), - ('profile', 'p', - "enable Cython profiling support"), - ('parallel=', 'j', - "run cythonize in parallel with N processes"), - ('force=', 'f', - "force files to be cythonized even if the are not changed") - ] - - boolean_options = ['debug', 'profile', 'force'] - - built_distributions = None - - def initialize_options(self): - self.extensions = None - self.build_base = None - self.build_dir = None - - # Always have Cython produce debugging info by default, unless - # SAGE_DEBUG=no explicitly - self.debug = True - self.profile = None - self.parallel = None - self.force = None - - self.cython_directives = None - self.compile_time_env = None - - self.build_lib = None - self.cythonized_files = None - - def finalize_options(self): - self.extensions = self.distribution.ext_modules - - # Let Cython generate its files in the "cythonized" - # subdirectory of the build_base directory. - self.set_undefined_options('build', ('build_base', 'build_base')) - self.build_dir = os.path.join(self.build_base, "cythonized") - - # Inherit some options from the 'build_ext' command if possible - # (this in turn implies inheritance from the 'build' command) - inherit_opts = [('build_lib', 'build_lib'), - ('debug', 'debug'), - ('force', 'force')] - - # Python 3.5 now has a parallel option as well - inherit_opts.append(('parallel', 'parallel')) - - self.set_undefined_options('build_ext', *inherit_opts) - - # Always produce debugging output unless SAGE_DEBUG=no is given - # explicitly - self.debug = os.environ.get('SAGE_DEBUG', None) != 'no' - - if self.debug: - log.info('Enabling Cython debugging support') - - if self.profile is None: - self.profile = os.environ.get('SAGE_PROFILE') == 'yes' - - if self.profile: - log.info('Enabling Cython profiling support') - - if self.parallel is None: - self.parallel = os.environ.get('SAGE_NUM_THREADS', '0') - - try: - self.parallel = int(self.parallel) - except ValueError: - raise ValueError("parallel should be an integer") - - try: - import Cython - except ImportError: - raise ImportError( - "Cython must be installed and importable in order to run " - "the cythonize command") - - self.cython_directives = compiler_directives(self.profile) - self.compile_time_env = compile_time_env_variables() - - # We check the Cython version and some relevant configuration - # options from the earlier build to see if we need to force a - # recythonization. If the version or options have changed, we - # must recythonize all files. - self._version_file = os.path.join(self.build_dir, '.cython_version') - self._version_stamp = json.dumps({ - 'version': Cython.__version__, - 'debug': self.debug, - 'directives': self.cython_directives, - 'compile_time_env': self.compile_time_env, - }, sort_keys=True) - - # Read an already written version file if it exists and compare to the - # current version stamp - try: - if open(self._version_file).read() == self._version_stamp: - force = False - else: - # version_file exists but its contents are not what we - # want => recythonize all Cython code. - force = True - # In case this cythonization is interrupted, we end up - # in an inconsistent state with C code generated by - # different Cython versions or with different options. - # To ensure that this inconsistent state will be fixed, - # we remove the version_file now to force a - # recythonization the next time we build Sage. - os.unlink(self._version_file) - except OSError: - # Most likely, the version_file does not exist - # => (re)cythonize all Cython code. - force = True - - # If the --force flag was given at the command line, always force; - # otherwise use what we determined from reading the version file - if self.force is None: - self.force = force - - def get_cythonized_package_files(self): - """ - Return a list of files found in the Sage sources and/or Cythonize - output directory that should be installed with Python packages (a la - ``package_files``). - """ - - if self.cythonized_files is not None: - return self.cythonized_files - - self.cythonized_files = list(find_extra_files( - ".", ["sage"], self.build_dir, [], - distributions=self.built_distributions).items()) - log.debug(f"cythonized_files = {self.cythonized_files}") - - return self.cythonized_files - - def run(self): - """ - Call ``cythonize()`` to replace the ``ext_modules`` with the - extensions containing Cython-generated C code. - """ - from sage.env import (cython_aliases, sage_include_directories) - # Set variables used in self.create_extension - from ..library_order import library_order - self.library_order = library_order - # Search for dependencies in the source tree and add to the list of include directories - self.sage_include_dirs = sage_include_directories(use_sources=True) - - from Cython.Build import cythonize - import Cython.Compiler.Options - - Cython.Compiler.Options.embed_pos_in_docstring = True - - log.info("Updating Cython code....") - t = time.time() - - from sage.misc.package_dir import cython_namespace_package_support - - with cython_namespace_package_support(): - extensions = cythonize( - self.extensions, - nthreads=self.parallel, - build_dir=self.build_dir, - force=self.force, - aliases=cython_aliases(), - compiler_directives=self.cython_directives, - compile_time_env=self.compile_time_env, - create_extension=self.create_extension, - # Debugging - gdb_debug=self.debug, - output_dir=os.path.join(self.build_lib, "sage"), - # Disable Cython caching, which is currently too broken to - # use reliably: https://github.com/sagemath/sage/issues/17851 - cache=False, - ) - - # We use [:] to change the list in-place because the same list - # object is pointed to from different places. - self.extensions[:] = extensions - - log.info("Finished Cythonizing, time: %.2f seconds." % (time.time() - t)) - - with open(self._version_file, 'w') as f: - f.write(self._version_stamp) - - # Finally, copy relevant cythonized files from build/cythonized - # tree into the build-lib tree - for (dst_dir, src_files) in self.get_cythonized_package_files(): - dst = os.path.join(self.build_lib, dst_dir) - self.mkpath(dst) - for src in src_files: - self.copy_file(src, dst, preserve_mode=False) - - def create_extension(self, template, kwds): - """ - Create a distutils Extension given data from Cython. - - This adjust the ``kwds`` in the following ways: - - - Make everything depend on *this* setup.py file - - - Add dependencies on header files for certain libraries - - - Sort the libraries according to the library order - - - Add some default compile/link args and directories - - - Choose C99 standard for C code and C++11 for C++ code - - - Drop -std=c99 and similar from C++ extensions - - - Ensure that each flag, library, ... is listed at most once - """ - lang = kwds.get('language', 'c') - cplusplus = (lang == "c++") - - # Libraries: sort them - libs = kwds.get('libraries', []) - kwds['libraries'] = sorted(set(libs), - key=lambda lib: self.library_order.get(lib, 0)) - - # Dependencies: add setup.py and lib_headers - depends = kwds.get('depends', []) + [self.distribution.script_name] - for lib, headers in lib_headers.items(): - if lib in libs: - depends += headers - kwds['depends'] = depends # These are sorted and uniq'ed by Cython - - # Process extra_compile_args - cflags = [] - for flag in kwds.get('extra_compile_args', []): - if flag.startswith("-std="): - if cplusplus and "++" not in flag: - continue # Skip -std=c99 and similar for C++ - cflags.append(flag) - cflags = extra_compile_args + cflags - kwds['extra_compile_args'] = stable_uniq(cflags) - - # Process extra_link_args - ldflags = kwds.get('extra_link_args', []) + extra_link_args - kwds['extra_link_args'] = stable_uniq(ldflags) - - # Process library_dirs - lib_dirs = kwds.get('library_dirs', []) - kwds['library_dirs'] = stable_uniq(lib_dirs) - - # Process include_dirs - inc_dirs = kwds.get('include_dirs', []) + self.sage_include_dirs + [self.build_dir] - kwds['include_dirs'] = stable_uniq(inc_dirs) - - from Cython.Build.Dependencies import default_create_extension - - return default_create_extension(template, kwds) diff --git a/src/sage_setup/command/sage_build_ext.py b/src/sage_setup/command/sage_build_ext.py deleted file mode 100644 index 5ef452316f0..00000000000 --- a/src/sage_setup/command/sage_build_ext.py +++ /dev/null @@ -1,210 +0,0 @@ -import os -import errno - -# Import setuptools before importing distutils, so that setuptools -# can replace distutils by its own vendored copy. -import setuptools - -from distutils import log -from setuptools.command.build_ext import build_ext -from distutils.dep_util import newer_group -try: - # Available since https://setuptools.pypa.io/en/latest/history.html#v59-0-0 - from setuptools.errors import DistutilsSetupError -except ImportError: - from distutils.errors import DistutilsSetupError -from sage_setup.run_parallel import execute_list_of_commands - - -class sage_build_ext(build_ext): - def finalize_options(self): - build_ext.finalize_options(self) - self.check_flags() - - def run(self): - # Always run the Cythonize command before building extensions - self.run_command('build_cython') - build_ext.run(self) - - def check_flags(self): - """ - Sanity check the compiler flags used to build the extensions - """ - forbidden = None - if os.environ.get("SAGE_FAT_BINARY") == "yes": - # When building with SAGE_FAT_BINARY=yes, we should not - # enable CPU features which do not exist on every CPU. - # Such flags usually come from other libraries adding the - # flags to the pkgconfig configuration. So if you hit these - # errors, the problem is most likely with some external - # library and not with Sage. - import re - forbidden = re.compile(r"-march=|-mpcu=|-msse3|-msse4|-mpopcnt|-mavx") - - if forbidden is not None: - errors = 0 - for ext in self.extensions: - flags = ext.extra_compile_args - for flag in flags: - if forbidden.match(flag): - log.error("%s uses forbidden flag '%s'", ext.name, flag) - errors += 1 - if errors: - raise RuntimeError("forbidden flags used") - - def build_extensions(self): - - from distutils.debug import DEBUG - - if DEBUG: - print("self.compiler.compiler:") - print(self.compiler.compiler) - print("self.compiler.compiler_cxx:") - print(self.compiler.compiler_cxx) # currently not used - print("self.compiler.compiler_so:") - print(self.compiler.compiler_so) - print("self.compiler.linker_so:") - print(self.compiler.linker_so) - # There are further interesting variables... - - if DEBUG: - print("self.compiler.linker_so (after fixing library dirs):") - print(self.compiler.linker_so) - - # First, sanity-check the 'extensions' list - self.check_extensions_list(self.extensions) - - import time - t = time.time() - - compile_commands = [] - for ext in self.extensions: - need_to_compile, p = self.prepare_extension(ext) - if need_to_compile: - compile_commands.append((self.build_extension, p)) - - execute_list_of_commands(compile_commands) - - print("Total time spent compiling C/C++ extensions: %.2f seconds." % (time.time() - t)) - - def prepare_extension(self, ext): - sources = ext.sources - if sources is None or not isinstance(sources, (list, tuple)): - raise DistutilsSetupError(("in 'ext_modules' option (extension '%s'), " + - "'sources' must be present and must be " + - "a list of source filenames") % ext.name) - sources = list(sources) - - fullname = self.get_ext_fullname(ext.name) - if self.inplace: - # ignore build-lib -- put the compiled extension into - # the source tree along with pure Python modules - - modpath = fullname.split('.') - package = '.'.join(modpath[0:-1]) - base = modpath[-1] - - build_py = self.get_finalized_command('build_py') - package_dir = build_py.get_package_dir(package) - ext_filename = os.path.join(package_dir, - self.get_ext_filename(base)) - relative_ext_filename = self.get_ext_filename(base) - else: - ext_filename = os.path.join(self.build_lib, - self.get_ext_filename(fullname)) - relative_ext_filename = self.get_ext_filename(fullname) - - # while dispatching the calls to gcc in parallel, we sometimes - # hit a race condition where two separate build_ext objects - # try to create a given directory at the same time; whoever - # loses the race then seems to throw an error, saying that - # the directory already exists. so, instead of fighting to - # fix the race condition, we simply make sure the entire - # directory tree exists now, while we're processing the - # extensions in serial. - relative_ext_dir = os.path.split(relative_ext_filename)[0] - prefixes = ['', self.build_lib, self.build_temp] - for prefix in prefixes: - path = os.path.join(prefix, relative_ext_dir) - try: - os.makedirs(path) - except OSError as e: - assert e.errno == errno.EEXIST, 'Cannot create %s.' % path - depends = sources + ext.depends - if not (self.force or newer_group(depends, ext_filename, 'newer')): - log.debug("skipping '%s' extension (up-to-date)", ext.name) - need_to_compile = False - else: - log.info("building '%s' extension", ext.name) - need_to_compile = True - - return need_to_compile, (sources, ext, ext_filename) - - def build_extension(self, p): - - sources, ext, ext_filename = p - - # First, scan the sources for SWIG definition files (.i), run - # SWIG on 'em to create .c files, and modify the sources list - # accordingly. - sources = self.swig_sources(sources, ext) - - # Next, compile the source code to object files. - - # XXX not honouring 'define_macros' or 'undef_macros' -- the - # CCompiler API needs to change to accommodate this, and I - # want to do one thing at a time! - - # Two possible sources for extra compiler arguments: - # - 'extra_compile_args' in Extension object - # - CFLAGS environment variable (not particularly - # elegant, but people seem to expect it and I - # guess it's useful) - # The environment variable should take precedence, and - # any sensible compiler will give precedence to later - # command line args. Hence we combine them in order: - extra_args = ext.extra_compile_args or [] - - macros = ext.define_macros[:] - for undef in ext.undef_macros: - macros.append((undef,)) - - objects = self.compiler.compile(sources, - output_dir=self.build_temp, - macros=macros, - include_dirs=ext.include_dirs, - debug=self.debug, - extra_postargs=extra_args, - depends=ext.depends) - - # XXX -- this is a Vile HACK! - # - # The setup.py script for Python on Unix needs to be able to - # get this list so it can perform all the clean up needed to - # avoid keeping object files around when cleaning out a failed - # build of an extension module. Since Distutils does not - # track dependencies, we have to get rid of intermediates to - # ensure all the intermediates will be properly re-built. - # - self._built_objects = objects[:] - - # Now link the object files together into a "shared object" -- - # of course, first we have to figure out all the other things - # that go into the mix. - if ext.extra_objects: - objects.extend(ext.extra_objects) - extra_args = ext.extra_link_args or [] - - # Detect target language, if not provided - language = ext.language or self.compiler.detect_language(sources) - - self.compiler.link_shared_object( - objects, ext_filename, - libraries=self.get_libraries(ext), - library_dirs=ext.library_dirs, - runtime_library_dirs=ext.runtime_library_dirs, - extra_postargs=extra_args, - export_symbols=self.get_export_symbols(ext), - debug=self.debug, - build_temp=self.build_temp, - target_lang=language) diff --git a/src/sage_setup/command/sage_build_ext_minimal.py b/src/sage_setup/command/sage_build_ext_minimal.py deleted file mode 100644 index 25cab109ff8..00000000000 --- a/src/sage_setup/command/sage_build_ext_minimal.py +++ /dev/null @@ -1,35 +0,0 @@ -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)) diff --git a/src/sage_setup/command/sage_build_py.py b/src/sage_setup/command/sage_build_py.py deleted file mode 100644 index 9ec936815c6..00000000000 --- a/src/sage_setup/command/sage_build_py.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools.command.build_py import build_py - - -class sage_build_py(build_py): - - def find_package_modules(self, package, package_dir): - r""" - Do not expand packages to modules. - - Our :func:`sage_setup.find.find_python_sources` already lists all modules. - """ - return [] diff --git a/src/sage_setup/command/sage_install.py b/src/sage_setup/command/sage_install.py deleted file mode 100644 index 052fbecc71e..00000000000 --- a/src/sage_setup/command/sage_install.py +++ /dev/null @@ -1,47 +0,0 @@ -######################################################### -### Install Jupyter kernel spec -######################################################### - -import os -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 distutils.command.install import install -from setuptools.command.develop import develop - - -class install_kernel_spec_mixin: - - def install_kernel_spec(self): - """ - Install the Jupyter kernel spec. - - .. NOTE:: - - The files are generated, not copied. Therefore, we cannot - use ``data_files`` for this. - """ - from sage.repl.ipython_kernel.install import SageKernelSpec - # Jupyter packages typically use the data_files option to - # setup() to install kernels and nbextensions. So we should use - # the install_data directory for installing our Jupyter files. - SageKernelSpec.update(prefix=self.install_data) - - -class sage_install(install, install_kernel_spec_mixin): - - def run(self): - install.run(self) - self.install_kernel_spec() - - -class sage_develop(develop, install_kernel_spec_mixin): - - def run(self): - develop.run(self) - if not self.uninstall: - self.install_kernel_spec() diff --git a/src/sage_setup/cython_options.py b/src/sage_setup/cython_options.py deleted file mode 100644 index 078d670983a..00000000000 --- a/src/sage_setup/cython_options.py +++ /dev/null @@ -1,44 +0,0 @@ -import sys - - -def compiler_directives(profile: bool): - """ - Return a list of Cython directives used for compilation. - """ - return dict( - # Do not generate __reduce__ methods - auto_pickle=False, - # Do not create __test__ dictionary automatically from docstrings - autotestdict=False, - # When enabled, functions will be bound to an instance when looked up as a - # class attribute (hence the name) and will emulate the attributes of - # Python functions, including introspections like argument names and - # annotations - binding=True, - c_api_binop_methods=True, - # Do not check for division by 0 (this is about 35% quicker than with check) - cdivision=True, - cpow=True, - # Embed a textual copy of the call signature in the docstring (to support tools like IPython) - embedsignature=True, - fast_getattr=True, - # Use Python 3 (including source code semantics) for module compilation - language_level="3", - legacy_implicit_noexcept=True, - # Enable support for late includes (make declarations in Cython code available to C include files) - preliminary_late_includes_cy28=True, - # Add hooks for Python profilers into the compiled C code - profile=profile, - ) - - -def compile_time_env_variables(): - """ - Return a list of environmental variables used for compilation. - """ - return dict( - PY_PLATFORM=sys.platform, - # The following two constants are here only for backwards compatibility of user packages - PY_VERSION_HEX=sys.hexversion, - PY_MAJOR_VERSION=sys.version_info[0] - ) diff --git a/src/sage_setup/excepthook.py b/src/sage_setup/excepthook.py deleted file mode 100644 index a40cf7cec4d..00000000000 --- a/src/sage_setup/excepthook.py +++ /dev/null @@ -1,31 +0,0 @@ -import os -import sys - - -def excepthook(*exc): - """ - When an error occurs, display an error message similar to the error - messages from ``sage-spkg``. - - In particular, ``build/make/install`` will recognize "sage" as a failed - package, see :issue:`16774`. - """ - stars = '*' * 72 - - print(stars, file=sys.stderr) - import traceback - traceback.print_exception(*exc, file=sys.stderr) - print(stars, file=sys.stderr) - print("Error building the Sage library", file=sys.stderr) - print(stars, file=sys.stderr) - - try: - logfile = os.environ['SAGE_LOGFILE'] # Set by build/bin/sage-logger - except Exception: - pass - else: - print("Please email sage-devel (http://groups.google.com/group/sage-devel)", file=sys.stderr) - print("explaining the problem and including the relevant part of the log file", file=sys.stderr) - print(" " + logfile, file=sys.stderr) - print("Describe your computer, operating system, etc.", file=sys.stderr) - print(stars, file=sys.stderr) diff --git a/src/sage_setup/extensions.py b/src/sage_setup/extensions.py deleted file mode 100644 index 4e1a17c6ced..00000000000 --- a/src/sage_setup/extensions.py +++ /dev/null @@ -1,10 +0,0 @@ - -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) diff --git a/src/sage_setup/find.py b/src/sage_setup/find.py deleted file mode 100644 index fa963c2a124..00000000000 --- a/src/sage_setup/find.py +++ /dev/null @@ -1,490 +0,0 @@ -# sage.doctest: needs SAGE_SRC -""" -Recursive Directory Contents -""" -# **************************************************************************** -# Copyright (C) 2014 Volker Braun -# 2014 R. Andrew Ohana -# 2015-2018 Jeroen Demeyer -# 2017 Erik M. Bray -# 2021 Tobias Diez -# 2020-2022 Matthias Koeppe -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# http://www.gnu.org/licenses/ -# **************************************************************************** - -import importlib.machinery -import importlib.util - -import os - -from collections import defaultdict - -from sage.misc.package_dir import is_package_or_sage_namespace_package_dir as is_package_or_namespace_package_dir -from sage.misc.package_dir import read_distribution, SourceDistributionFilter - -assert read_distribution # unused in this file, re-export for compatibility - - -def find_python_sources(src_dir, modules=['sage'], distributions=None, - exclude_distributions=None): - """ - Find all Python packages and Python/Cython modules in the sources. - - INPUT: - - - ``src_dir`` -- root directory for the sources - - - ``modules`` -- (default: ``['sage']``) sequence of strings: - the top-level directories in ``src_dir`` to be considered - - - ``distributions`` -- (default: ``None``) if not ``None``, - should be a sequence or set of strings: only find modules whose - ``distribution`` (from a ``# sage_setup: distribution = PACKAGE`` - directive in the module source file) is an element of - ``distributions``. - - - ``exclude_distributions`` -- (default: ``None``) if not ``None``, - should be a sequence or set of strings: exclude modules whose - ``distribution`` (from a ``# sage_setup: distribution = PACKAGE`` - directive in the module source file) is in ``exclude_distributions``. - - OUTPUT: - - Triple consisting of - - - the list of package names (corresponding to ordinary packages - or namespace packages, according to - :func:`sage.misc.namespace_package.is_package_or_sage_namespace_package_dir`) - - - Python module names (corresponding to ``*.py`` files in ordinary - or namespace packages) - - - Cython extensions (corresponding to ``*.pyx`` files). - - Both use dot as separator. - - EXAMPLES:: - - sage: from sage.env import SAGE_SRC - sage: from sage_setup.find import find_python_sources - sage: py_packages, py_modules, cy_modules = find_python_sources(SAGE_SRC) - - Ordinary package (with ``__init__.py``):: - - sage: ['sage.structure' in L for L in (py_packages, py_modules)] - [True, False] - - Python module in an ordinary package:: - - sage: ['sage.structure.formal_sum' in L for L in (py_packages, py_modules)] - [False, True] - - Cython module in an ordinary package:: - - sage: ['sage.structure.sage_object' in L for L in (py_packages, py_modules)] - [False, False] - - Subdirectory without any Python files:: - - sage: ['sage.doctest.tests' in L for L in (py_packages, py_modules)] - [False, False] - - Another subdirectory that is neither an ordinary nor a namespace package:: - - sage: ['sage.extdata' in L for L in (py_packages, py_modules)] - [False, False] - - Package designated to become an implicit namespace package (no ``__init__.py``, PEP 420, - but with an ``all.py`` file per Sage library conventions):: - - sage: ['sage.graphs.graph_decompositions' in L for L in (py_packages, py_modules)] - [True, False] - - Python module in a package designated to become an implicit namespace package:: - - sage: ['sage.graphs.graph_decompositions.modular_decomposition' in L for L in (py_packages, py_modules)] - [False, True] - - Python file (not module) in a directory that is neither an ordinary nor a namespace package:: - - sage: ['sage.ext_data.nbconvert.postprocess' in L for L in (py_packages, py_modules)] - [False, False] - - Filtering by distribution (distribution package):: - - sage: find_python_sources(SAGE_SRC, distributions=['sagemath-tdlib']) - ([], [], []) - - Benchmarking:: - - sage: timeit('find_python_sources(SAGE_SRC)', # random output - ....: number=1, repeat=1) - 1 loops, best of 1: 30 ms per loop - - sage: timeit('find_python_sources(SAGE_SRC, distributions=[""])', # random output - ....: number=1, repeat=1) - 1 loops, best of 1: 850 ms per loop - - sage: find_python_sources(SAGE_SRC, modules=['sage_setup']) - (['sage_setup', ...], [...'sage_setup.find'...], []) - """ - from setuptools import Extension - - PYMOD_EXT = get_extensions('source')[0] - - python_packages = [] - python_modules = [] - cython_modules = [] - - distribution_filter = SourceDistributionFilter(distributions, exclude_distributions) - - cwd = os.getcwd() - try: - os.chdir(src_dir) - for module in modules: - for dirpath, dirnames, filenames in os.walk(module): - package = dirpath.replace(os.path.sep, '.') - if not is_package_or_namespace_package_dir(dirpath): - # Skip any subdirectories - dirnames[:] = [] - continue - # Ordinary package or namespace package. - if distributions is None or '' in distributions: - python_packages.append(package) - - for filename in filenames: - base, ext = os.path.splitext(filename) - filepath = os.path.join(dirpath, filename) - if ext == PYMOD_EXT and base != '__init__': - if filepath in distribution_filter: - python_modules.append(package + '.' + base) - if ext == '.pyx': - if filepath in distribution_filter: - cython_modules.append(Extension(package + '.' + base, - sources=[os.path.join(dirpath, filename)])) - - finally: - os.chdir(cwd) - return python_packages, python_modules, cython_modules - - -def filter_cython_sources(src_dir, distributions, exclude_distributions=None): - """ - Find all Cython modules in the given source directory that belong to the - given distributions. - - INPUT: - - - ``src_dir`` -- root directory for the sources - - - ``distributions`` -- a sequence or set of strings: only find modules whose - ``distribution`` (from a ``# sage_setup: distribution = PACKAGE`` - directive in the module source file) is an element of - ``distributions``. - - OUTPUT: list of absolute paths to Cython files (``*.pyx``) - - EXAMPLES:: - - sage: from sage.env import SAGE_SRC - sage: from sage_setup.find import filter_cython_sources - sage: cython_modules = filter_cython_sources(SAGE_SRC, ["sagemath-tdlib"]) - - Cython module relying on tdlib:: - - sage: any(f.endswith('sage/graphs/graph_decompositions/tdlib.pyx') for f in cython_modules) - True - - Cython module not relying on tdlib:: - - sage: any(f.endswith('sage/structure/sage_object.pyx') for f in cython_modules) - False - - Benchmarking:: - - sage: timeit('filter_cython_sources(SAGE_SRC, ["sagemath-tdlib"])', # random output - ....: number=1, repeat=1) - 1 loops, best of 1: 850 ms per loop - """ - files: list[str] = [] - distribution_filter = SourceDistributionFilter(distributions, exclude_distributions) - for dirpath, dirnames, filenames in os.walk(src_dir): - for filename in filenames: - filepath = os.path.join(dirpath, filename) - base, ext = os.path.splitext(filename) - if ext == '.pyx' and filepath in distribution_filter: - files.append(filepath) - - return files - - -def _cythonized_dir(src_dir=None, editable_install=None): - """ - Return the path where Cython-generated files are placed by the build system. - - INPUT: - - - ``src_dir`` -- string or path (default: the value of ``SAGE_SRC``). The - root directory for the sources. - - - ``editable_install`` -- boolean (default: determined from the existing - installation). Whether this is an editable install of the Sage library. - - EXAMPLES:: - - sage: from sage_setup.find import _cythonized_dir - sage: from sage.env import SAGE_SRC - sage: _cythonized_dir(SAGE_SRC) - PosixPath('...') - sage: _cythonized_dir(SAGE_SRC, editable_install=False) # optional - sage_spkg - PosixPath('.../build/cythonized') - - """ - from importlib import import_module - from pathlib import Path - from sage.env import SAGE_ROOT, SAGE_SRC - if editable_install is None: - if src_dir is None: - src_dir = SAGE_SRC - src_dir = Path(src_dir) - # sage.cpython is an ordinary package, so it has __file__ - sage_cpython = import_module('sage.cpython') - d = Path(sage_cpython.__file__).resolve().parent.parent.parent - editable_install = d == src_dir.resolve() - if editable_install: - # Editable install: Cython generates files in the source tree - return src_dir - else: - return Path(SAGE_ROOT) / "build" / "pkgs" / "sagelib" / "src" / "build" / "cythonized" - - -def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[], *, - distributions=None): - """ - Find all extra files which should be installed. - - These are (for each ``module`` in ``modules``): - - 1. From ``src_dir/module``: all .pyx, .pxd and .pxi files and files - listed in ``special_filenames``. - 2. From ``cythonized_dir/module``: all .h files (both the .h files - from the sources, as well as all Cython-generated .h files). - - The directories are searched recursively, but only package - directories (containing ``__init__.py`` or a Cython equivalent) - are considered. - - INPUT: - - - ``src_dir`` -- root directory for the sources - - - ``modules`` -- sequence of strings: - the top-level directories in ``src_dir`` to be considered - - - ``cythonized_dir`` -- the directory where the Cython-generated - files are - - - ``special_filenames`` -- a list of filenames to be installed from - ``src_dir`` - - - ``distributions`` -- (default: ``None``) if not ``None``, - should be a sequence or set of strings: only find files whose - ``distribution`` (from a ``# sage_setup: distribution = PACKAGE`` - directive in the file) is an element of ``distributions``. - - OUTPUT: dict with items ``{dir: files}`` where ``dir`` is a - directory relative to ``src_dir`` and ``files`` is a list of - filenames inside that directory. - - EXAMPLES:: - - sage: from sage_setup.find import find_extra_files, _cythonized_dir - sage: from sage.env import SAGE_SRC, SAGE_ROOT - sage: cythonized_dir = _cythonized_dir(SAGE_SRC) - sage: extras = find_extra_files(SAGE_SRC, ["sage"], cythonized_dir) - sage: extras["sage/libs/mpfr"] - [...sage/libs/mpfr/types.pxd...] - sage: sorted(extras["sage/ext/interpreters"]) - ['.../sage/ext/interpreters/wrapper_cdf.h', ...wrapper_cdf.pxd...] - """ - data_files = {} - cy_exts = ('.pxd', '.pxi', '.pyx') - - cwd = os.getcwd() - try: - os.chdir(src_dir) - for module in modules: - for dir, dirnames, filenames in os.walk(module): - if not is_package_or_namespace_package_dir(dir): - continue - sdir = os.path.join(src_dir, dir) - cydir = os.path.join(cythonized_dir, dir) - - files = [os.path.join(sdir, f) for f in filenames - if f.endswith(cy_exts) or f in special_filenames] - if os.path.isdir(cydir): # Not every directory contains Cython files - files += [os.path.join(cydir, f) for f in os.listdir(cydir) - if f.endswith(".h")] - else: - files += [os.path.join(sdir, f) for f in filenames - if f.endswith(".h")] - - if distributions is not None: - files = [f for f in files - if read_distribution(f) in distributions] - - if files: - data_files[dir] = files - finally: - os.chdir(cwd) - - return data_files - - -def installed_files_by_module(site_packages, modules=('sage',)): - """ - Find all currently installed files - - INPUT: - - - ``site_packages`` -- string. The root Python path where the Sage - library is being installed. If the path doesn't exist, returns - an empty dictionary. - - - ``modules`` -- list/tuple/iterable of strings (default: - ``('sage',)``). The top-level directory name(s) in - ``site_packages``. - - OUTPUT: - - A dictionary whose keys are module names (``'sage.module.foo'``) - and values are list of corresponding file names - ``['sage/module/foo.py', 'sage/module/foo.pyc']`` relative to - ``site_packages``. - - EXAMPLES:: - - sage: site_packages = os.path.dirname(os.path.dirname(os.path.dirname(sage.cpython.__file__))) - sage: from sage_setup.find import installed_files_by_module - sage: files_by_module = installed_files_by_module(site_packages) - sage: (f,) = files_by_module['sage.structure.sage_object']; f - 'sage/structure/sage_object...' - sage: (f1, f2) = sorted(files_by_module['sage.structure']) - sage: f1 - 'sage/structure/__init__.py' - sage: f2 - 'sage/structure/....pyc' - - This takes about 30ms with warm cache:: - - sage: timeit('installed_files_by_module(site_packages)', # random output - ....: number=1, repeat=1) - 1 loops, best of 1: 29.6 ms per loop - """ - - module_files = defaultdict(set) - module_exts = get_extensions() - - def add(module, filename, dirpath): - # Find the longest extension that matches the filename - best_ext = '' - - for ext in module_exts: - if filename.endswith(ext) and len(ext) > len(best_ext): - best_ext = ext - - if not best_ext: - return - - base = filename[:-len(best_ext)] - filename = os.path.join(dirpath, filename) - - if base != '__init__': - module += '.' + base - - module_files[module].add(filename) - - cache_filename = importlib.util.cache_from_source(filename) - if os.path.exists(cache_filename): - module_files[module].add(cache_filename) - - cwd = os.getcwd() - try: - os.chdir(site_packages) - except OSError: - return module_files - try: - for module in modules: - for dirpath, dirnames, filenames in os.walk(module): - module_dir = '.'.join(dirpath.split(os.path.sep)) - - if os.path.basename(dirpath) == '__pycache__': - continue - - for filename in filenames: - add(module_dir, filename, dirpath) - finally: - os.chdir(cwd) - return module_files - - -def get_extensions(type=None): - """ - Returns the filename extensions for different types of Python module files. - - By default returns all extensions, but can be filtered by type. The - possible types are 'source' (for pure Python sources), 'bytecode' (for - compiled bytecode files (i.e. pyc files), or 'extension' for C extension - modules. - - INPUT: - - - ``type`` -- the module type ('source', 'bytecode', or 'extension') or - None - - EXAMPLES:: - - sage: from sage_setup.find import get_extensions - sage: get_extensions() # random - depends on Python version - ['.so', 'module.so', '.py', '.pyc'] - sage: get_extensions('source') - ['.py'] - sage: get_extensions('bytecode') - ['.pyc'] - sage: get_extensions('extension') # random - depends on Python version - ['.so', 'module.so'] - """ - - if type: - type = type.lower() - if type not in ('source', 'bytecode', 'extension'): - raise ValueError( - "type must by one of 'source' (for Python sources), " - "'bytecode' (for compiled Python bytecoe), or 'extension' " - "(for C extension modules).") - - # Note: There is at least one case, for extension modules, where the - # 'extension' does not begin with '.', but rather with 'module', for cases - # in Python's stdlib, for example, where an extension module can be named - # like "module.so". This breaks things for us if we have a Cython - # module literally named "module". - return [ext for ext in _get_extensions(type) if ext[0] == '.'] - - -def _get_extensions(type): - """ - Python 3.3+ implementation of ``get_extensions()`` using the - `importlib.extensions` module. - """ - - if type: - return {'source': importlib.machinery.SOURCE_SUFFIXES, - 'bytecode': importlib.machinery.BYTECODE_SUFFIXES, - 'extension': importlib.machinery.EXTENSION_SUFFIXES}[type] - - return importlib.machinery.all_suffixes() diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py deleted file mode 100644 index 3a2321e7760..00000000000 --- a/src/sage_setup/library_order.py +++ /dev/null @@ -1,42 +0,0 @@ -######################################################### -### Library order -######################################################### - -# This list defines the *order* of linking libraries. A library should -# be put *before* any library it links to. Cython allows -# defining libraries using "# distutils: libraries = LIB". However, if -# there are multiple libraries, the order is undefined so we need to -# manually reorder the libraries according to this list. Any libraries which are not -# listed here will be added at the end of the list (without changing -# their relative order). -from sage.env import cython_aliases, default_required_modules, default_optional_modules - -modules = default_required_modules + default_optional_modules - -aliases = cython_aliases(required_modules=(), optional_modules=modules) - -library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [ - "intl", "curl", - "ec", "ecm" -] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [ - "pari", "flint", "ecl", "glpk", "ppl", -] + [ - "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx", - "brial", - "brial_groebner", - "m4rie", -] + aliases.get("M4RI_LIBRARIES", []) + [ - "gap", -] + aliases.get("GDLIB_LIBRARIES", []) + aliases.get("LIBPNG_LIBRARIES", []) + [ - "m", "readline", "Lfunction", -] + aliases.get("CBLAS_LIBRARIES", []) + aliases.get("ZLIB_LIBRARIES", []) - -# Make a dict with library:order pairs, where the order are negative -# integers sorted according to library_order_list. When sorting, -# unlisted libraries have order 0, so they appear after the libraries -# in library_order_list. -n = len(library_order_list) -library_order = {} -for i in range(n): - lib = library_order_list[i] - library_order[lib] = i-n diff --git a/src/sage_setup/run_parallel.py b/src/sage_setup/run_parallel.py deleted file mode 100644 index a920f4070e8..00000000000 --- a/src/sage_setup/run_parallel.py +++ /dev/null @@ -1,139 +0,0 @@ -######################################################################## -## -## Parallel gcc execution -## -## This code is responsible for making distutils dispatch the calls to -## build_ext in parallel. Since distutils doesn't seem to do this by -## default, we create our own extension builder and override the -## appropriate methods. Unfortunately, in distutils, the logic of -## deciding whether an extension needs to be recompiled and actually -## making the call to gcc to recompile the extension are in the same -## function. As a result, we can't just override one function and have -## everything magically work. Instead, we split this work between two -## functions. This works fine for our application, but it means that -## we can't use this modification to make the other parts of Sage that -## build with distutils call gcc in parallel. -## -######################################################################## - -import os -import sys -import time - -keep_going = False - - -def run_command(cmd): - """ - INPUT: - - - ``cmd`` -- a string; a command to run - - OUTPUT: prints ``cmd`` to the console and then runs - ``os.system(cmd)``. - """ - print(cmd) - sys.stdout.flush() - return os.system(cmd) - - -def apply_func_progress(p): - """ - Given a triple p consisting of a function, value and a string, - output the string and apply the function to the value. - - The string could for example be some progress indicator. - - This exists solely because we can't pickle an anonymous function - in execute_list_of_commands_in_parallel below. - """ - sys.stdout.write(p[2]) - sys.stdout.flush() - return p[0](p[1]) - - -def execute_list_of_commands_in_parallel(command_list, nthreads): - """ - Execute the given list of commands, possibly in parallel, using - ``nthreads`` threads. Terminates ``setup.py`` with an exit code - of 1 if an error occurs in any subcommand. - - INPUT: - - - ``command_list`` -- a list of commands, each given as a pair of - the form ``[function, argument]`` of a function to call and its - argument - - - ``nthreads`` -- integer; number of threads to use - - WARNING: commands are run roughly in order, but of course successive - commands may be run at the same time. - """ - # Add progress indicator strings to the command_list - N = len(command_list) - progress_fmt = "[{:%i}/{}] " % len(str(N)) - for i in range(N): - progress = progress_fmt.format(i+1, N) - command_list[i] = command_list[i] + (progress,) - - from multiprocessing import Pool - # map_async handles KeyboardInterrupt correctly if an argument is - # given to get(). Plain map() and apply_async() do not work - # correctly, see Issue #16113. - pool = Pool(nthreads) - result = pool.map_async(apply_func_progress, command_list, 1).get(99999) - pool.close() - pool.join() - process_command_results(result) - - -def process_command_results(result_values): - error = None - for r in result_values: - if r: - print("Error running command, failed with status %s." % r) - if not keep_going: - sys.exit(1) - error = r - if error: - sys.exit(1) - - -def execute_list_of_commands(command_list): - """ - INPUT: - - - ``command_list`` -- a list of strings or pairs - - OUTPUT: - - For each entry in command_list, we attempt to run the command. - If it is a string, we call ``os.system()``. If it is a pair [f, v], - we call f(v). - - If the environment variable :envvar:`SAGE_NUM_THREADS` is set, use - that many threads. - """ - t = time.time() - # Determine the number of threads from the environment variable - # SAGE_NUM_THREADS, which is set automatically by sage-env - try: - nthreads = int(os.environ['SAGE_NUM_THREADS']) - except KeyError: - nthreads = 1 - - # normalize the command_list to handle strings correctly - command_list = [ [run_command, x] if isinstance(x, str) else x for x in command_list ] - - # No need for more threads than there are commands, but at least one - nthreads = min(len(command_list), nthreads) - nthreads = max(1, nthreads) - - def plural(n, noun): - if n == 1: - return "1 %s" % noun - return "%i %ss" % (n, noun) - - print("Executing %s (using %s)" % (plural(len(command_list),"command"), plural(nthreads,"thread"))) - execute_list_of_commands_in_parallel(command_list, nthreads) - print("Time to execute %s: %.2f seconds." % (plural(len(command_list),"command"), time.time() - t)) diff --git a/src/sage_setup/setenv.py b/src/sage_setup/setenv.py deleted file mode 100644 index e7ad6552440..00000000000 --- a/src/sage_setup/setenv.py +++ /dev/null @@ -1,50 +0,0 @@ -# Set some environment variables in the running process - -import os -import platform -from pathlib import Path - - -def _environ_prepend(var, value, separator=':'): - if value: - if var in os.environ: - os.environ[var] = value + separator + os.environ[var] - else: - os.environ[var] = value - - -def setenv(): - from sage.env import SAGE_LOCAL, SAGE_VENV, SAGE_ARCHFLAGS, SAGE_PKG_CONFIG_PATH - - ## - ## from sage-env: - ## - - # not done: CC, CXX, FC, OBJC, OBJCXX, F77, F90, F95 - if 'ARCHFLAGS' not in os.environ and SAGE_ARCHFLAGS != "unset": - os.environ['ARCHFLAGS'] = SAGE_ARCHFLAGS - _environ_prepend('PKG_CONFIG_PATH', SAGE_PKG_CONFIG_PATH) - # Issue #32057: As sage.env gives SAGE_LOCAL a fallback value from SAGE_VENV, - # SAGE_LOCAL is never unset. So we only set it if it differs from SAGE_VENV. - # We assume that compiling/linking against libraries installed in SAGE_VENV - # works -- that's the responsibility of the venv activation, not ours. - if SAGE_LOCAL and Path(SAGE_VENV).resolve() != Path(SAGE_LOCAL).resolve(): - _environ_prepend('PATH', f'{SAGE_LOCAL}/bin') - _environ_prepend('LIBRARY_PATH', f'{SAGE_LOCAL}/lib') - _environ_prepend('CPATH', f'{SAGE_LOCAL}/include') - _environ_prepend('LDFLAGS', f'-L{SAGE_LOCAL}/lib -Wl,-rpath,{SAGE_LOCAL}/lib', - separator=' ') - if platform.system() == 'Linux': - _environ_prepend('LDFLAGS', f'-Wl,-rpath-link,{SAGE_LOCAL}/lib', - separator=' ') - if Path(SAGE_VENV).resolve() != Path(SAGE_LOCAL).resolve(): - # This condition is always true, but we are keeping it for clarity. - _environ_prepend('PATH', f'{SAGE_VENV}/bin') - # the following two are not done by sage-env - #_environ_prepend('LIBRARY_PATH', f'{SAGE_VENV}/lib') - #_environ_prepend('CPATH', f'{SAGE_VENV}/include') - - # not done: PATH prepend of SAGE_SRC/bin, SAGE_ROOT/build/bin - # not done: MACOSX_DEPLOYMENT_TARGET - # not done: PATH prepend for ccache & CCACHE_BASEDIR - # not done: OPENBLAS_NUM_THREADS diff --git a/src/sage_setup/util.py b/src/sage_setup/util.py deleted file mode 100644 index 774de3eed30..00000000000 --- a/src/sage_setup/util.py +++ /dev/null @@ -1,57 +0,0 @@ -r""" -Utility functions for building Sage -""" - -# **************************************************************************** -# Copyright (C) 2017 Jeroen Demeyer -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# https://www.gnu.org/licenses/ -# **************************************************************************** - - -def stable_uniq(L) -> list: - """ - Given an iterable L, remove duplicate items from L by keeping only - the last occurrence of any item. - - The items must be hashable. - - EXAMPLES:: - - sage: from sage_setup.util import stable_uniq - sage: stable_uniq( (1, 2, 3, 4, 5, 6, 3, 7, 5, 1, 5, 9) ) - [2, 4, 6, 3, 7, 1, 5, 9] - """ - D = {} - for pos, item in enumerate(L): - D[item] = pos # Store the last position where an item appears - return sorted(D, key=lambda item: D[item]) - - -def have_module(name) -> bool: - """ - Check whether a Python module named ``name`` can be imported. - - This is done by trying to import that module and returning ``True`` - if that import succeeded. So, as a side effect, the module is - actually imported if possible. - - EXAMPLES:: - - sage: from sage_setup.util import have_module - sage: have_module("itertools") - True - sage: have_module("sage.rings.integer") - True - sage: have_module("no.such.module") - False - """ - try: - __import__(name, {}, {}, [], 0) - return True - except ImportError: - return False diff --git a/src/sage_setup/autogen/__init__.py b/tools/autogen/__init__.py similarity index 85% rename from src/sage_setup/autogen/__init__.py rename to tools/autogen/__init__.py index 2ec85acde21..0a38fecc3b5 100644 --- a/src/sage_setup/autogen/__init__.py +++ b/tools/autogen/__init__.py @@ -1,6 +1,6 @@ import os -from sage_setup.autogen.interpreters.internal import rebuild +from .interpreters.internal import rebuild def autogen_all(): diff --git a/src/sage_setup/autogen/__main__.py b/tools/autogen/__main__.py similarity index 100% rename from src/sage_setup/autogen/__main__.py rename to tools/autogen/__main__.py diff --git a/src/sage_setup/autogen/flint/README.md b/tools/autogen/flint/README.md similarity index 94% rename from src/sage_setup/autogen/flint/README.md rename to tools/autogen/flint/README.md index 2205b7ed82e..4e80776d12e 100644 --- a/src/sage_setup/autogen/flint/README.md +++ b/tools/autogen/flint/README.md @@ -21,7 +21,7 @@ autogeneration 5. Set the environment variable `FLINT_GIT_DIR` 6. Run the `flint_autogen.py` script e.g. `python - $SAGE_ROOT/src/sage_setup/autogen/flint_autogen.py`. The script writes down + tools/autogen/flint_autogen.py`. The script writes down the headers in the sage source tree `$SAGE_ROOT/src/sage/libs/flint/` diff --git a/src/sage_setup/autogen/flint/__init__.py b/tools/autogen/flint/__init__.py similarity index 100% rename from src/sage_setup/autogen/flint/__init__.py rename to tools/autogen/flint/__init__.py diff --git a/src/sage_setup/autogen/flint/env.py b/tools/autogen/flint/env.py similarity index 100% rename from src/sage_setup/autogen/flint/env.py rename to tools/autogen/flint/env.py diff --git a/src/sage_setup/autogen/flint/macros/acb_macros.pxd b/tools/autogen/flint/macros/acb_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/acb_macros.pxd rename to tools/autogen/flint/macros/acb_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd b/tools/autogen/flint/macros/acb_mat_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/acb_mat_macros.pxd rename to tools/autogen/flint/macros/acb_mat_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd b/tools/autogen/flint/macros/acb_poly_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/acb_poly_macros.pxd rename to tools/autogen/flint/macros/acb_poly_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/arb_macros.pxd b/tools/autogen/flint/macros/arb_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/arb_macros.pxd rename to tools/autogen/flint/macros/arb_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd b/tools/autogen/flint/macros/arb_mat_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/arb_mat_macros.pxd rename to tools/autogen/flint/macros/arb_mat_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd b/tools/autogen/flint/macros/fmpq_mat_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/fmpq_mat_macros.pxd rename to tools/autogen/flint/macros/fmpq_mat_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/fmpz_macros.pxd b/tools/autogen/flint/macros/fmpz_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/fmpz_macros.pxd rename to tools/autogen/flint/macros/fmpz_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd b/tools/autogen/flint/macros/fmpz_mat_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/fmpz_mat_macros.pxd rename to tools/autogen/flint/macros/fmpz_mat_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd b/tools/autogen/flint/macros/fmpz_poly_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/fmpz_poly_macros.pxd rename to tools/autogen/flint/macros/fmpz_poly_macros.pxd diff --git a/src/sage_setup/autogen/flint/macros/mag_macros.pxd b/tools/autogen/flint/macros/mag_macros.pxd similarity index 100% rename from src/sage_setup/autogen/flint/macros/mag_macros.pxd rename to tools/autogen/flint/macros/mag_macros.pxd diff --git a/src/sage_setup/autogen/flint/reader.py b/tools/autogen/flint/reader.py similarity index 100% rename from src/sage_setup/autogen/flint/reader.py rename to tools/autogen/flint/reader.py diff --git a/src/sage_setup/autogen/flint/templates/flint_sage.pyx.template b/tools/autogen/flint/templates/flint_sage.pyx.template similarity index 100% rename from src/sage_setup/autogen/flint/templates/flint_sage.pyx.template rename to tools/autogen/flint/templates/flint_sage.pyx.template diff --git a/src/sage_setup/autogen/flint/templates/flint_wrap.h.template b/tools/autogen/flint/templates/flint_wrap.h.template similarity index 100% rename from src/sage_setup/autogen/flint/templates/flint_wrap.h.template rename to tools/autogen/flint/templates/flint_wrap.h.template diff --git a/src/sage_setup/autogen/flint/templates/types.pxd.template b/tools/autogen/flint/templates/types.pxd.template similarity index 100% rename from src/sage_setup/autogen/flint/templates/types.pxd.template rename to tools/autogen/flint/templates/types.pxd.template diff --git a/src/sage_setup/autogen/flint/writer.py b/tools/autogen/flint/writer.py similarity index 100% rename from src/sage_setup/autogen/flint/writer.py rename to tools/autogen/flint/writer.py diff --git a/src/sage_setup/autogen/flint_autogen.py b/tools/autogen/flint_autogen.py similarity index 100% rename from src/sage_setup/autogen/flint_autogen.py rename to tools/autogen/flint_autogen.py diff --git a/src/sage_setup/autogen/interpreters/__main__.py b/tools/autogen/interpreters/__main__.py old mode 100755 new mode 100644 similarity index 100% rename from src/sage_setup/autogen/interpreters/__main__.py rename to tools/autogen/interpreters/__main__.py diff --git a/src/sage_setup/autogen/interpreters/internal/__init__.py b/tools/autogen/interpreters/internal/__init__.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/__init__.py rename to tools/autogen/interpreters/internal/__init__.py diff --git a/src/sage_setup/autogen/interpreters/internal/generator.py b/tools/autogen/interpreters/internal/generator.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/generator.py rename to tools/autogen/interpreters/internal/generator.py diff --git a/src/sage_setup/autogen/interpreters/internal/instructions.py b/tools/autogen/interpreters/internal/instructions.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/instructions.py rename to tools/autogen/interpreters/internal/instructions.py diff --git a/src/sage_setup/autogen/interpreters/internal/memory.py b/tools/autogen/interpreters/internal/memory.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/memory.py rename to tools/autogen/interpreters/internal/memory.py diff --git a/src/sage_setup/__init__.py b/tools/autogen/interpreters/internal/specs/__init__.py similarity index 100% rename from src/sage_setup/__init__.py rename to tools/autogen/interpreters/internal/specs/__init__.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/base.py b/tools/autogen/interpreters/internal/specs/base.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/base.py rename to tools/autogen/interpreters/internal/specs/base.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/cc.py b/tools/autogen/interpreters/internal/specs/cc.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/cc.py rename to tools/autogen/interpreters/internal/specs/cc.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/cdf.py b/tools/autogen/interpreters/internal/specs/cdf.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/cdf.py rename to tools/autogen/interpreters/internal/specs/cdf.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/element.py b/tools/autogen/interpreters/internal/specs/element.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/element.py rename to tools/autogen/interpreters/internal/specs/element.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/python.py b/tools/autogen/interpreters/internal/specs/python.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/python.py rename to tools/autogen/interpreters/internal/specs/python.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/rdf.py b/tools/autogen/interpreters/internal/specs/rdf.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/rdf.py rename to tools/autogen/interpreters/internal/specs/rdf.py diff --git a/src/sage_setup/autogen/interpreters/internal/specs/rr.py b/tools/autogen/interpreters/internal/specs/rr.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/specs/rr.py rename to tools/autogen/interpreters/internal/specs/rr.py diff --git a/src/sage_setup/autogen/interpreters/internal/storage.py b/tools/autogen/interpreters/internal/storage.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/storage.py rename to tools/autogen/interpreters/internal/storage.py diff --git a/src/sage_setup/autogen/interpreters/internal/utils.py b/tools/autogen/interpreters/internal/utils.py similarity index 100% rename from src/sage_setup/autogen/interpreters/internal/utils.py rename to tools/autogen/interpreters/internal/utils.py