diff --git a/.gitignore b/.gitignore index 91838a1627c..ff0ecbabc8e 100644 --- a/.gitignore +++ b/.gitignore @@ -158,6 +158,14 @@ build/bin/sage-build-env-config /pkgs/*/*.egg-info /pkgs/*/.tox +/pkgs/sagemath-objects/setup.cfg +/pkgs/sagemath-categories/setup.cfg +/pkgs/sagemath-objects/pyproject.toml +/pkgs/sagemath-categories/pyproject.toml +/pkgs/sagemath-objects/requirements.txt +/pkgs/sagemath-categories/requirements.txt +/pkgs/sagemath-categories/MANIFEST.in + # same for old locations - before Trac #31577 /build/pkgs/*/src/build /build/pkgs/*/src/dist diff --git a/Makefile b/Makefile index 444e4f9e4ad..a5c504bb6cb 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,17 @@ download: dist: build/make/Makefile ./sage --sdist +pypi-sdists: sage_setup + ./sage --sh build/pkgs/sage_conf/spkg-src + ./sage --sh build/pkgs/sage_setup/spkg-src + ./sage --sh build/pkgs/sage_sws2rst/spkg-src + ./sage --sh build/pkgs/sage_docbuild/spkg-src + ./sage --sh build/pkgs/sage_setup/spkg-src + ./sage --sh build/pkgs/sagelib/spkg-src + ./sage --sh build/pkgs/sagemath_objects/spkg-src + ./sage --sh build/pkgs/sagemath_categories/spkg-src + @echo "Built sdists are in upstream/" + # ssl: build Sage, and also install pyOpenSSL. This is necessary for # running the secure notebook. This make target requires internet # access. Note that this requires that your system have OpenSSL diff --git a/build/bin/write-dockerfile.sh b/build/bin/write-dockerfile.sh index bd709957ef1..29610be5491 100755 --- a/build/bin/write-dockerfile.sh +++ b/build/bin/write-dockerfile.sh @@ -187,7 +187,7 @@ FROM with-system-packages as bootstrapped #:bootstrapping: RUN mkdir -p /sage WORKDIR /sage -ADD Makefile VERSION.txt README.md bootstrap configure.ac sage ./ +ADD Makefile VERSION.txt COPYING.txt condarc.yml README.md bootstrap configure.ac sage .homebrew-build-env tox.ini Pipfile.m4 ./ ADD src/doc/bootstrap src/doc/bootstrap ADD src/bin src/bin ADD m4 ./m4 diff --git a/build/make/Makefile.in b/build/make/Makefile.in index 1972e1a14ce..cb15215d978 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -230,7 +230,6 @@ base-toolchain: _clean-broken-gcc base # All targets except for the base packages all-sage: \ - sagelib \ $(INSTALLED_PACKAGE_INSTS) \ $(UNINSTALLED_PACKAGES_CLEANS) diff --git a/build/pkgs/pplpy/dependencies b/build/pkgs/pplpy/dependencies index 16e271bb5f9..c61defdb7ed 100644 --- a/build/pkgs/pplpy/dependencies +++ b/build/pkgs/pplpy/dependencies @@ -1,4 +1,4 @@ -$(PYTHON) $(MP_LIBRARY) gmpy2 cysignals mpfr mpc ppl | $(PYTHON_TOOLCHAIN) sphinx +$(PYTHON) $(MP_LIBRARY) gmpy2 cysignals mpfr mpc ppl | $(PYTHON_TOOLCHAIN) $(if $(findstring no,$(SAGE_SPKG_INSTALL_DOCS)),,sphinx) ---------- All lines of this file are ignored except the first. diff --git a/build/pkgs/sage_conf/spkg-src b/build/pkgs/sage_conf/spkg-src index cad851bd9d5..af6e8b16342 100755 --- a/build/pkgs/sage_conf/spkg-src +++ b/build/pkgs/sage_conf/spkg-src @@ -15,7 +15,5 @@ fi # Exit on failure set -e -cd build/pkgs/sage_conf - -cd src +cd pkgs/sage-conf_pypi python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES" diff --git a/build/pkgs/sagelib/bootstrap b/build/pkgs/sagelib/bootstrap index db4ae487271..08f9002f8f5 100755 --- a/build/pkgs/sagelib/bootstrap +++ b/build/pkgs/sagelib/bootstrap @@ -4,7 +4,7 @@ for infile in src/*.m4; do if [ -f "$infile" ]; then outfile="src/$(basename $infile .m4)" if [ "${BOOTSTRAP_QUIET}" = "no" ]; then - echo "$0: installing build/pkgs/sagelib/$outfile" + echo "$0: installing $(pwd)/$outfile" fi m4 "$infile" > "$outfile" fi diff --git a/build/pkgs/sagemath_categories/SPKG.rst b/build/pkgs/sagemath_categories/SPKG.rst new file mode 120000 index 00000000000..b4545b4bda6 --- /dev/null +++ b/build/pkgs/sagemath_categories/SPKG.rst @@ -0,0 +1 @@ +src/README.rst \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/bootstrap b/build/pkgs/sagemath_categories/bootstrap new file mode 120000 index 00000000000..40542346a4e --- /dev/null +++ b/build/pkgs/sagemath_categories/bootstrap @@ -0,0 +1 @@ +../sagelib/bootstrap \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/dependencies b/build/pkgs/sagemath_categories/dependencies new file mode 120000 index 00000000000..55c209e6418 --- /dev/null +++ b/build/pkgs/sagemath_categories/dependencies @@ -0,0 +1 @@ +../sagemath_objects/dependencies \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/package-version.txt b/build/pkgs/sagemath_categories/package-version.txt new file mode 120000 index 00000000000..cf10fe4b4e4 --- /dev/null +++ b/build/pkgs/sagemath_categories/package-version.txt @@ -0,0 +1 @@ +../sagelib/package-version.txt \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/spkg-install b/build/pkgs/sagemath_categories/spkg-install new file mode 120000 index 00000000000..e60fac9ffa1 --- /dev/null +++ b/build/pkgs/sagemath_categories/spkg-install @@ -0,0 +1 @@ +../sagemath_objects/spkg-install \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/spkg-src b/build/pkgs/sagemath_categories/spkg-src new file mode 100755 index 00000000000..327d51651b9 --- /dev/null +++ b/build/pkgs/sagemath_categories/spkg-src @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Script to prepare an sdist tarball for sagemath-categories +# This script is not used during build. +# +# HOW TO MAKE THE TARBALL: +# ./sage --sh build/pkgs/sagemath_categories/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/sagemath_categories + +cd src +python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES" diff --git a/build/pkgs/sagemath_categories/src b/build/pkgs/sagemath_categories/src new file mode 120000 index 00000000000..5e64e8c2f9e --- /dev/null +++ b/build/pkgs/sagemath_categories/src @@ -0,0 +1 @@ +../../../pkgs/sagemath-categories \ No newline at end of file diff --git a/build/pkgs/sagemath_categories/type b/build/pkgs/sagemath_categories/type new file mode 100644 index 00000000000..9839eb20815 --- /dev/null +++ b/build/pkgs/sagemath_categories/type @@ -0,0 +1 @@ +experimental diff --git a/build/pkgs/sagemath_objects/SPKG.rst b/build/pkgs/sagemath_objects/SPKG.rst new file mode 120000 index 00000000000..b4545b4bda6 --- /dev/null +++ b/build/pkgs/sagemath_objects/SPKG.rst @@ -0,0 +1 @@ +src/README.rst \ No newline at end of file diff --git a/build/pkgs/sagemath_objects/bootstrap b/build/pkgs/sagemath_objects/bootstrap new file mode 120000 index 00000000000..40542346a4e --- /dev/null +++ b/build/pkgs/sagemath_objects/bootstrap @@ -0,0 +1 @@ +../sagelib/bootstrap \ No newline at end of file diff --git a/build/pkgs/sagemath_objects/dependencies b/build/pkgs/sagemath_objects/dependencies new file mode 100644 index 00000000000..fcacb179b57 --- /dev/null +++ b/build/pkgs/sagemath_objects/dependencies @@ -0,0 +1,4 @@ +FORCE $(PYTHON) cysignals gmpy2 ipython | $(PYTHON_TOOLCHAIN) cython pkgconfig $(and $(filter-out no,$(SAGE_CHECK)), tox) + +# FORCE: Always run the spkg-install script +# ipython - for the doctester diff --git a/build/pkgs/sagemath_objects/package-version.txt b/build/pkgs/sagemath_objects/package-version.txt new file mode 120000 index 00000000000..cf10fe4b4e4 --- /dev/null +++ b/build/pkgs/sagemath_objects/package-version.txt @@ -0,0 +1 @@ +../sagelib/package-version.txt \ No newline at end of file diff --git a/build/pkgs/sagemath_objects/spkg-install b/build/pkgs/sagemath_objects/spkg-install new file mode 100755 index 00000000000..59e83e7010f --- /dev/null +++ b/build/pkgs/sagemath_objects/spkg-install @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +cd src + +if [ "$SAGE_CHECK" != no ]; then + tox +fi +# We skip the install for now. +exit 0 diff --git a/build/pkgs/sagemath_objects/spkg-src b/build/pkgs/sagemath_objects/spkg-src new file mode 100755 index 00000000000..68719fae1b6 --- /dev/null +++ b/build/pkgs/sagemath_objects/spkg-src @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# +# Script to prepare an sdist tarball for sagemath-objects +# This script is not used during build. +# +# HOW TO MAKE THE TARBALL: +# 1) ./sage --sh build/pkgs/sagemath_objects/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/sagemath_objects + +cd src +python3 -u setup.py --no-user-cfg sdist --dist-dir "$SAGE_DISTFILES" diff --git a/build/pkgs/sagemath_objects/src b/build/pkgs/sagemath_objects/src new file mode 120000 index 00000000000..f9cb321d7b4 --- /dev/null +++ b/build/pkgs/sagemath_objects/src @@ -0,0 +1 @@ +../../../pkgs/sagemath-objects \ No newline at end of file diff --git a/build/pkgs/sagemath_objects/type b/build/pkgs/sagemath_objects/type new file mode 100644 index 00000000000..9839eb20815 --- /dev/null +++ b/build/pkgs/sagemath_objects/type @@ -0,0 +1 @@ +experimental diff --git a/configure.ac b/configure.ac index 699d2aaaaf1..09872eb6b4b 100644 --- a/configure.ac +++ b/configure.ac @@ -456,7 +456,13 @@ AC_ARG_ENABLE([cvxopt], AC_ARG_ENABLE([notebook], AS_HELP_STRING([--disable-notebook], [disable build of the Jupyter notebook and related packages]), [ - for pkg in notebook nbconvert sagenb_export nbformat terminado send2trash prometheus_client mistune pandocfilters bleach defusedxml jsonschema jupyter_jsmol; do + for pkg in notebook nbconvert sagenb_export nbformat terminado send2trash prometheus_client mistune pandocfilters bleach defusedxml jsonschema jupyter_jsmol argon2_cffi; do + AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval]) + done + ]) + +AS_IF([test "$SAGE_ENABLE_notebook" = no -a "$SAGE_ENABLE_sagelib" = no], [ + for pkg in jupyter_client ipykernel ipython zeromq pyzmq; do AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval]) done ]) @@ -469,6 +475,14 @@ AC_ARG_ENABLE([r], done ]) +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; do + AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval]) + done + ]) + dnl Packages that require a special override to use the SPKG dnl when the system package is not usable. AS_VAR_SET([sage_use_system_gcc], [force]) diff --git a/pkgs/sage-conf/.gitignore b/pkgs/sage-conf/.gitignore index c94082c9d9a..2975b16e54b 100644 --- a/pkgs/sage-conf/.gitignore +++ b/pkgs/sage-conf/.gitignore @@ -1,2 +1,4 @@ /sage_conf.py /setup.cfg +/build +/*.egg-info diff --git a/pkgs/sage-conf/README.rst b/pkgs/sage-conf/README.rst index 1c08375b03a..0e881fb9dc5 100644 --- a/pkgs/sage-conf/README.rst +++ b/pkgs/sage-conf/README.rst @@ -1,10 +1,10 @@ -sage_conf: Configuration module for the SageMath library -======================================================== +sage_conf: Configuration module for the SageMath library (distributable version) +================================================================================ Description ----------- -This package provides: +This distribution package provides: - a single Python module, ``sage_conf``, providing configuration information to the SageMath library at the time of its installation and at its runtime @@ -15,10 +15,79 @@ This package provides: - a sourcable shell script ``sage-env-config``, providing additional configuration information in the form of environment variables -This version of the package is generated by the Sage distribution's ``configure`` -script. Downstream packagers and advanced developers and users may want to provide -their own implementation of the package to support the intended deployment of -the SageMath library. +The ``sage_conf`` distribution package is polymorphic: It has several implementations. + + +sage_conf sdist on PyPI +----------------------- + +This implementation of the ``sage_conf`` distribution package comes from +https://trac.sagemath.org/ticket/29039, which adds the directory +``pkgs/sage-conf_pypi/``. + +To install, use ``pip install -v sage_conf``. Using ``-v`` ensures that diagnostic +messages are displayed. + +On installation (or building a wheel), it invokes ``sage_bootstrap`` to establish +a build tree (``SAGE_ROOT``) and installation tree (``SAGE_LOCAL``) for +the SageMath distribution. By default, it uses a subdirectory of ``$HOME/.sage`` +that is specific to the version of the distribution and the version of Python in +use. If several virtual environments over the same version of Python install +``sage_conf``, they will share these trees. + +After installation of ``sage_conf``, a wheelhouse containing wheels of +various libraries is available; type ``ls $(sage-config +SAGE_SPKG_WHEELS)`` to list them and ``pip install $(sage-config +SAGE_SPKG_WHEELS)/*.whl`` to install them. After this, you can install the Sage +library, for example, using ``pip install sagemath-standard``. + + +sage_conf wheels +---------------- + +Prebuilt binary wheels of the ``sage_conf`` distribution package are available +at https://github.com/sagemath/sage-wheels/releases/ + +This implementation of ``sage_conf`` comes from https://trac.sagemath.org/ticket/31396, +which adds the directory ``pkgs/sage-conf_relocatable/``. + +On building a wheel, it invokes ``sage_bootstrap`` to establish a +build and installation tree (``SAGE_ROOT``, ``SAGE_LOCAL``) in a +subdirectory of the directory ``/var/tmp/``, whose name is specific to +the version of the distribution and the version of Python in use. + +The wheel distributes a copy of the prebuilt ``SAGE_ROOT`` and +``SAGE_LOCAL``. Importing ``sage_conf`` (or using the installed +``sage-config`` script), makes sure that a symlink from the +``/var/tmp`` location to the actual persistent installation location +is created. As the relocated libraries and programs contain the +hardcoded path ``SAGE_LOCAL`` in various ways (including as rpaths), +this symlink is necessary for the prebuilt libraries and programs to +work. + +``/var/tmp`` is a sticky directory on all Linux distributions +following the Filesystem Hierarchy Standard, as well as on macOS and +on Cygwin. On multi-user systems, only one user can use a given +version of the distribution; other installation schemes are recommended +for systems with multiple Sage users. + + +sage_conf in the SageMath distribution +-------------------------------------- + +The original version of the distribution package ``sage_conf`` is used +internally in the SageMath distribution. It is provided in the directory +``pkgs/sage-conf/``. This version of the package is generated +by the Sage distribution's ``configure`` script. + + +sage_conf in downstream distributions +------------------------------------- + +Downstream packagers and advanced developers and users may want to provide +their own implementation of the distribution package to support the intended +deployment of the SageMath library. + License ------- @@ -31,4 +100,4 @@ Upstream Contact https://www.sagemath.org This package is included in the source code of the Sage distribution, -in ``/sage_conf``. +in ``pkgs/sage-conf*``. diff --git a/pkgs/sage-conf/pyproject.toml b/pkgs/sage-conf/pyproject.toml new file mode 100644 index 00000000000..9787c3bdf00 --- /dev/null +++ b/pkgs/sage-conf/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/pkgs/sage-conf/sage_conf.py.in b/pkgs/sage-conf/sage_conf.py.in index fbce6947de3..6a125ccfcb6 100644 --- a/pkgs/sage-conf/sage_conf.py.in +++ b/pkgs/sage-conf/sage_conf.py.in @@ -58,6 +58,11 @@ OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@" # The full absolute path to the main Singular library. LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL) +# Installation location of wheels. This is determined at configuration time +# and does not depend on the installation location of sage-conf. +SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels" + + # Entry point 'sage-config'. It does not depend on any packages. def _main(): diff --git a/pkgs/sage-conf_pypi/.gitignore b/pkgs/sage-conf_pypi/.gitignore new file mode 100644 index 00000000000..3bb4a6af5d1 --- /dev/null +++ b/pkgs/sage-conf_pypi/.gitignore @@ -0,0 +1,5 @@ +/sage_conf.py +/build +/dist +/*.egg-info +/.tox diff --git a/pkgs/sage-conf_pypi/MANIFEST.in b/pkgs/sage-conf_pypi/MANIFEST.in new file mode 100644 index 00000000000..be45d90781d --- /dev/null +++ b/pkgs/sage-conf_pypi/MANIFEST.in @@ -0,0 +1,21 @@ +prune .tox +include VERSION.txt +graft bin +graft sage_root +# These sources are not needed because individual distributions of these are made. +prune sage_root/build/pkgs/*/src* +prune sage_root/pkgs +# Except for this one because config.status writes there +graft sage_root/pkgs/sage-conf +prune sage_root/pkgs/sage-conf/build +# And this one because of declared dependencies on source files in Makefile.in +graft sage_root/pkgs/sage-docbuild +prune sage_root/pkgs/sage-docbuild/build +prune sage_root/pkgs/sage-docbuild/*.egg-info +# +global-exclude .tox +global-exclude *~* +global-exclude *.bak +global-exclude __pycache__ +global-exclude *.py[co] +global-exclude *.so diff --git a/pkgs/sage-conf_pypi/README.rst b/pkgs/sage-conf_pypi/README.rst new file mode 120000 index 00000000000..feda886cd36 --- /dev/null +++ b/pkgs/sage-conf_pypi/README.rst @@ -0,0 +1 @@ +../sage-conf/README.rst \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt new file mode 120000 index 00000000000..43f4773d7de --- /dev/null +++ b/pkgs/sage-conf_pypi/VERSION.txt @@ -0,0 +1 @@ +../../src/VERSION.txt \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/bin/sage-env-config.in b/pkgs/sage-conf_pypi/bin/sage-env-config.in new file mode 120000 index 00000000000..59e39e7e944 --- /dev/null +++ b/pkgs/sage-conf_pypi/bin/sage-env-config.in @@ -0,0 +1 @@ +../../sage-conf/bin/sage-env-config.in \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/pyproject.toml b/pkgs/sage-conf_pypi/pyproject.toml new file mode 100644 index 00000000000..9787c3bdf00 --- /dev/null +++ b/pkgs/sage-conf_pypi/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/pkgs/sage-conf_pypi/sage_conf.py.in b/pkgs/sage-conf_pypi/sage_conf.py.in new file mode 120000 index 00000000000..ed20b4df7fd --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_conf.py.in @@ -0,0 +1 @@ +../sage-conf/sage_conf.py.in \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/.homebrew-build-env b/pkgs/sage-conf_pypi/sage_root/.homebrew-build-env new file mode 120000 index 00000000000..18573e75488 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/.homebrew-build-env @@ -0,0 +1 @@ +../../../.homebrew-build-env \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/Makefile b/pkgs/sage-conf_pypi/sage_root/Makefile new file mode 120000 index 00000000000..62a7b627cbc --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/Makefile @@ -0,0 +1 @@ +../../../Makefile \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/README.md b/pkgs/sage-conf_pypi/sage_root/README.md new file mode 120000 index 00000000000..8a33348c7d8 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/README.md @@ -0,0 +1 @@ +../../../README.md \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/VERSION.txt b/pkgs/sage-conf_pypi/sage_root/VERSION.txt new file mode 120000 index 00000000000..c4fcb84c1a7 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/VERSION.txt @@ -0,0 +1 @@ +../../../VERSION.txt \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/bootstrap b/pkgs/sage-conf_pypi/sage_root/bootstrap new file mode 100755 index 00000000000..38df9dbea8a --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/bootstrap @@ -0,0 +1,3 @@ +#! /usr/bin/env bash +# This version of the bootstrap script does nothing. +exit 0 diff --git a/pkgs/sage-conf_pypi/sage_root/build b/pkgs/sage-conf_pypi/sage_root/build new file mode 120000 index 00000000000..44735d58664 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/build @@ -0,0 +1 @@ +../../../build \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/config b/pkgs/sage-conf_pypi/sage_root/config new file mode 120000 index 00000000000..101d543820c --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/config @@ -0,0 +1 @@ +../../../config \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/configure b/pkgs/sage-conf_pypi/sage_root/configure new file mode 120000 index 00000000000..5cc41f0cbb4 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/configure @@ -0,0 +1 @@ +../../../configure \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/configure.ac b/pkgs/sage-conf_pypi/sage_root/configure.ac new file mode 120000 index 00000000000..663513d0394 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/configure.ac @@ -0,0 +1 @@ +../../../configure.ac \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/m4 b/pkgs/sage-conf_pypi/sage_root/m4 new file mode 120000 index 00000000000..af1ea766194 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/m4 @@ -0,0 +1 @@ +../../../m4 \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/pkgs/sage-conf b/pkgs/sage-conf_pypi/sage_root/pkgs/sage-conf new file mode 120000 index 00000000000..a5beefae37f --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/pkgs/sage-conf @@ -0,0 +1 @@ +../../../sage-conf \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/src/bin b/pkgs/sage-conf_pypi/sage_root/src/bin new file mode 120000 index 00000000000..459186de7e0 --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/src/bin @@ -0,0 +1 @@ +../../../../src/bin \ No newline at end of file diff --git a/pkgs/sage-conf_pypi/sage_root/src/doc/bootstrap b/pkgs/sage-conf_pypi/sage_root/src/doc/bootstrap new file mode 100755 index 00000000000..2a2bb398b9a --- /dev/null +++ b/pkgs/sage-conf_pypi/sage_root/src/doc/bootstrap @@ -0,0 +1,3 @@ +#! /usr/bin/env bash +# This version of the src/doc/bootstrap script does nothing. +exit 0 diff --git a/pkgs/sage-conf_pypi/setup.cfg b/pkgs/sage-conf_pypi/setup.cfg new file mode 100644 index 00000000000..a024eb955a0 --- /dev/null +++ b/pkgs/sage-conf_pypi/setup.cfg @@ -0,0 +1,16 @@ +[metadata] +name = sage-conf +version = file: VERSION.txt +description = Sage: Open Source Mathematics Software: Configuration module for the SageMath library +long_description = file: README.rst +license = GNU General Public License (GPL) v3 or later +author = The Sage Developers +author_email = sage-support@googlegroups.com +url = https://www.sagemath.org + +[options] +py_modules = + sage_conf + +scripts = + bin/sage-env-config diff --git a/pkgs/sage-conf_pypi/setup.py b/pkgs/sage-conf_pypi/setup.py new file mode 100644 index 00000000000..f4e76a5e4ff --- /dev/null +++ b/pkgs/sage-conf_pypi/setup.py @@ -0,0 +1,85 @@ +import os +import sys +import shutil +import sysconfig +import platform + +from setuptools import setup +from distutils.command.build_scripts import build_scripts as distutils_build_scripts +from setuptools.command.build_py import build_py as setuptools_build_py +from setuptools.command.egg_info import egg_info as setuptools_egg_info +from distutils.errors import (DistutilsSetupError, DistutilsModuleError, + DistutilsOptionError) + +class build_py(setuptools_build_py): + + def run(self): + DOT_SAGE = os.environ.get('DOT_SAGE', os.path.join(os.environ.get('HOME'), '.sage')) + HERE = os.path.dirname(__file__) + with open(os.path.join(HERE, 'VERSION.txt')) as f: + sage_version = f.read().strip() + # For convenience, set up the homebrew env automatically. This is a no-op if homebrew is not present. + SETENV = '(. ./.homebrew-build-env 2> /dev/null || :)' + # After #30534, SAGE_LOCAL no longer contains any Python. So we key the SAGE_ROOT only to Sage version + # and architecture. + system = platform.system() + machine = platform.machine() + arch_tag = f'{system}-{machine}' + # TODO: These two should be user-configurable with options passed to "setup.py install" + SAGE_ROOT = os.path.join(DOT_SAGE, f'sage-{sage_version}-{arch_tag}') + SAGE_LOCAL = os.path.join(SAGE_ROOT, 'local') + if os.path.exists(os.path.join(SAGE_ROOT, 'config.status')): + print(f'Reusing SAGE_ROOT={SAGE_ROOT}') + else: + # config.status and other configure output has to be writable. + # So (until the Sage distribution supports VPATH builds - #21469), we have to make a copy of sage_root. + try: + shutil.copytree('sage_root', SAGE_ROOT) # will fail if already exists + except Exception: + raise DistutilsSetupError(f"the directory SAGE_ROOT={SAGE_ROOT} already exists but it is not configured. Please remove it and try again.") + cmd = f"cd {SAGE_ROOT} && {SETENV} && ./configure --prefix={SAGE_LOCAL} --with-python={sys.executable} --enable-build-as-root --enable-download-from-upstream-url --with-system-python3=force --with-sage-venv --disable-notebook --disable-sagelib" + print(f"Running {cmd}") + sys.stdout.flush() + if os.system(cmd) != 0: + print(f"configure failed; this may be caused by missing build prerequisites.") + sys.stdout.flush() + PREREQ_SPKG = "_prereq bzip2 xz libffi" # includes python3 SPKG_DEPCHECK packages + os.system(f'cd {SAGE_ROOT} && export SYSTEM=$(build/bin/sage-guess-package-system 2>/dev/null) && export PACKAGES="$(build/bin/sage-get-system-packages $SYSTEM {PREREQ_SPKG})" && [ -n "$PACKAGES" ] && echo "You can install the required build prerequisites using the following shell command" && echo "" && build/bin/sage-print-system-package-command $SYSTEM --verbose --sudo install $PACKAGES && echo ""') + raise DistutilsSetupError("configure failed") + # Here we run "make build" -- which builds everything except for sagelib because we + # used configure --disable-sagelib + # Alternative: + # "make build-local" only builds the non-Python packages of the Sage distribution. + # It still makes an (empty) venv in SAGE_VENV, which is unused by default; + # but then a user could use "make build-venv" to build compatible wheels for all Python packages. + # TODO: A target to only build wheels of tricky packages + # (that use native libraries shared with other packages). + SETMAKE = 'if [ -z "$MAKE" ]; then export MAKE="make -j$(PATH=build/bin:$PATH build/bin/sage-build-num-threads | cut -d" " -f 2)"; fi' + cmd = f'cd {SAGE_ROOT} && {SETENV} && {SETMAKE} && $MAKE V=0 build-local' + if os.system(cmd) != 0: + raise DistutilsSetupError("make build-local failed") + + # Install configuration + shutil.copyfile(os.path.join(SAGE_ROOT, 'pkgs', 'sage-conf', 'sage_conf.py'), + os.path.join(HERE, 'sage_conf.py')) + if not self.distribution.py_modules: + self.py_modules = self.distribution.py_modules = [] + self.distribution.py_modules.append('sage_conf') + shutil.copyfile(os.path.join(SAGE_ROOT, 'src', 'bin', 'sage-env-config'), + os.path.join(HERE, 'bin', 'sage-env-config')) + setuptools_build_py.run(self) + +class build_scripts(distutils_build_scripts): + + def run(self): + self.distribution.scripts.append(os.path.join('bin', 'sage-env-config')) + if not self.distribution.entry_points: + self.entry_points = self.distribution.entry_points = dict() + if 'console_scripts' not in self.distribution.entry_points: + self.distribution.entry_points['console_scripts'] = [] + self.distribution.entry_points['console_scripts'].append('sage-config=sage_conf:_main') + distutils_build_scripts.run(self) + +setup( + cmdclass=dict(build_py=build_py, build_scripts=build_scripts) +) diff --git a/pkgs/sage-conf_pypi/tox.ini b/pkgs/sage-conf_pypi/tox.ini new file mode 100644 index 00000000000..b530bd10554 --- /dev/null +++ b/pkgs/sage-conf_pypi/tox.ini @@ -0,0 +1,12 @@ +[tox] +envlist = python + +[testenv] +passenv = + MAKE + +setenv = + HOME={envdir} + +commands = + sage-config diff --git a/pkgs/sagemath-categories/MANIFEST.in.m4 b/pkgs/sagemath-categories/MANIFEST.in.m4 new file mode 100644 index 00000000000..1b5dcf3078c --- /dev/null +++ b/pkgs/sagemath-categories/MANIFEST.in.m4 @@ -0,0 +1,15 @@ +dnl MANIFEST.in is generated from this file by SAGE_ROOT/bootstrap via m4. + +dnl Include all from sagemath-objects (via m4 include) +include(`../sagemath_objects/src/MANIFEST.in') + +# Extra in sagemath-categories: +global-include all__sagemath_categories.py +graft sage/categories +include sage/misc/prandom.* # dep of sage/rings/ring +include sage/rings/ideal.* +include sage/rings/ring.* +graft sage/typeset # dep of sage.categories.tensor +# include sage/rings/integer*.* # depends on cypari, flint - https://trac.sagemath.org/ticket/30022 +# include sage/rings/rational*.* +# include sage/rings/infinity.* diff --git a/pkgs/sagemath-categories/README.rst b/pkgs/sagemath-categories/README.rst new file mode 100644 index 00000000000..cbfab7ea2df --- /dev/null +++ b/pkgs/sagemath-categories/README.rst @@ -0,0 +1,35 @@ +========================================================================= + Sage: Open Source Mathematics Software: Sage categories and basic rings +========================================================================= + +About SageMath +-------------- + + "Creating a Viable Open Source Alternative to + Magma, Maple, Mathematica, and MATLAB" + + Copyright (C) 2005-2020 The Sage Development Team + + https://www.sagemath.org + +SageMath fully supports all major Linux distributions, recent versions of macOS, and Windows (using Cygwin or Windows Subsystem for Linux). + +The traditional and recommended way to install SageMath is from source via Sage-the-distribution (https://www.sagemath.org/download-source.html). Sage-the-distribution first builds a large number of open source packages from source (unless it finds suitable versions installed in the system) and then installs the Sage Library (sagelib, implemented in Python and Cython). + + +About this experimental pip-installable source distribution +----------------------------------------------------------- + +This pip-installable source distribution `sagemath-categories` is an experimental distribution of a small part of the Sage Library. Use at your own risk. It provides a small subset of the modules of the Sage library ("sagelib", `sagemath-standard`). It is a superset of the `sagemath-objects` (providing Sage objects, the element/parent framework, categories, the coercion system and the related metaclasses), making various additional categories available without introducing dependencies on additional mathematical libraries. + + +Documentation +------------- + +* `Categories `_ + +* `Structure `_ + +* `Coercion `_ + +* `Classes, Metaclasses `_ diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt new file mode 120000 index 00000000000..43f4773d7de --- /dev/null +++ b/pkgs/sagemath-categories/VERSION.txt @@ -0,0 +1 @@ +../../src/VERSION.txt \ No newline at end of file diff --git a/pkgs/sagemath-categories/bin b/pkgs/sagemath-categories/bin new file mode 120000 index 00000000000..2f8b9b30ee7 --- /dev/null +++ b/pkgs/sagemath-categories/bin @@ -0,0 +1 @@ +../../src/bin \ No newline at end of file diff --git a/pkgs/sagemath-categories/pyproject.toml.m4 b/pkgs/sagemath-categories/pyproject.toml.m4 new file mode 120000 index 00000000000..b65c0df8a46 --- /dev/null +++ b/pkgs/sagemath-categories/pyproject.toml.m4 @@ -0,0 +1 @@ +../sagemath-objects/pyproject.toml.m4 \ No newline at end of file diff --git a/pkgs/sagemath-categories/requirements.txt.m4 b/pkgs/sagemath-categories/requirements.txt.m4 new file mode 120000 index 00000000000..f8fa4ba0e42 --- /dev/null +++ b/pkgs/sagemath-categories/requirements.txt.m4 @@ -0,0 +1 @@ +../sagemath-objects/requirements.txt.m4 \ No newline at end of file diff --git a/pkgs/sagemath-categories/sage b/pkgs/sagemath-categories/sage new file mode 120000 index 00000000000..e0da5daa6f2 --- /dev/null +++ b/pkgs/sagemath-categories/sage @@ -0,0 +1 @@ +../../src/sage \ No newline at end of file diff --git a/pkgs/sagemath-categories/sage_setup b/pkgs/sagemath-categories/sage_setup new file mode 120000 index 00000000000..88b8133df49 --- /dev/null +++ b/pkgs/sagemath-categories/sage_setup @@ -0,0 +1 @@ +../../src/sage_setup \ No newline at end of file diff --git a/pkgs/sagemath-categories/setup.cfg.m4 b/pkgs/sagemath-categories/setup.cfg.m4 new file mode 100644 index 00000000000..70a7f204ef4 --- /dev/null +++ b/pkgs/sagemath-categories/setup.cfg.m4 @@ -0,0 +1,35 @@ +# -*- conf-unix -*- +[metadata] +name = sagemath-categories +version = file: VERSION.txt +description = Sage: Open Source Mathematics Software: Sage categories and basic rings +long_description = file: README.rst +long_description_content_type = text/x-rst +license = GNU General Public License (GPL) v2 or later +author = The Sage Developers +author_email = sage-support@googlegroups.com +url = https://www.sagemath.org + +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.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: Implementation :: CPython + Topic :: Scientific/Engineering :: Mathematics + +[options] +python_requires = >=3.7, <3.10 +install_requires = + esyscmd(`sage-get-system-packages install-requires \ + cython \ + pkgconfig \ + gmpy2 \ + cysignals \ + | sed "2,\$s/^/ /;"')dnl diff --git a/pkgs/sagemath-categories/setup.py b/pkgs/sagemath-categories/setup.py new file mode 120000 index 00000000000..144436eac59 --- /dev/null +++ b/pkgs/sagemath-categories/setup.py @@ -0,0 +1 @@ +../sagemath-objects/setup.py \ No newline at end of file diff --git a/pkgs/sagemath-categories/tox.ini b/pkgs/sagemath-categories/tox.ini new file mode 100644 index 00000000000..831b361256a --- /dev/null +++ b/pkgs/sagemath-categories/tox.ini @@ -0,0 +1,33 @@ +# To build and test in the tox environment: +# +# ./sage -sh -c '(cd pkgs/sagemath-categories/src && tox -v -v -v)' +# +# To test interactively: +# +# pkgs/sagemath-categories/.tox/python/bin/python +# +[tox] + +[testenv] +deps = -rrequirements.txt + +setenv = + # Sage scripts such as sage-runtests like to use $HOME/.sage + HOME={envdir} + +passenv = + SAGE_NUM_THREADS + SAGE_NUM_THREADS_PARALLEL + +whitelist_externals = + bash + + +commands = + # Beware of the treacherous non-src layout. "./sage/" shadows the install sage package. + python -c 'import sys; "" in sys.path and sys.path.remove(""); import sage.cpython.builtin_types, sage.cpython.cython_metaclass, sage.cpython.debug, sage.structure.all, sage.categories.all' + + # Test that importing sage.categories.all initializes categories + python -c 'import sys; "" in sys.path and sys.path.remove(""); from sage.categories.all import *; SimplicialComplexes(); FunctionFields()' + + bash -c 'cd bin && SAGE_SRC=$(python -c "from sage.env import SAGE_SRC; print(SAGE_SRC)") && sage-runtests --environment=sage.all__sagemath_categories --optional=sage $SAGE_SRC/sage/structure || echo "(lots of doctest failures are expected)"' diff --git a/pkgs/sagemath-objects/MANIFEST.in b/pkgs/sagemath-objects/MANIFEST.in new file mode 100644 index 00000000000..1e11d51d901 --- /dev/null +++ b/pkgs/sagemath-objects/MANIFEST.in @@ -0,0 +1,105 @@ +prune sage +graft sage/cpython + +include sage/__init__.py # FIXME: Needs to become a namespace package +include sage/env.py # FIXME: sage_setup must be changed so it does not depend on it +include sage/version.py # FIXME: likewise +include VERSION.txt + +global-include all__sagemath_objects.py + +graft sage/features +graft sage/structure +include sage/categories/__init__.py # FIXME: Needs to become a namespace package +include sage/categories/action.* +include sage/categories/algebra_functor.* +include sage/categories/basic.* +include sage/categories/cartesian_product.* +include sage/categories/category*.* +include sage/categories/covariant_functorial_construction.* +include sage/categories/functor.* +include sage/categories/homset.* +include sage/categories/homsets.* +include sage/categories/map.* +include sage/categories/morphism.* +include sage/categories/isomorphic_objects.* +include sage/categories/objects.* +include sage/categories/primer.* +include sage/categories/pushout.* +include sage/categories/quotients.* +include sage/categories/realizations.* +include sage/categories/sets_cat.* +include sage/categories/sets_with_partial_maps.* +include sage/categories/subobjects.* +include sage/categories/subquotients.* +include sage/categories/with_realizations.* + +include sage/misc/__init__.py # FIXME: Needs to become a namespace package +include sage/misc/classcall_metaclass.* +include sage/misc/inherit_comparison*.* +include sage/misc/weak_dict.* +include sage/misc/nested_class*.* +include sage/misc/abstract_method.* +include sage/misc/cachefunc.* +include sage/misc/decorators.* +include sage/misc/c3_controlled.* +include sage/misc/lazy_attribute.* +include sage/misc/function_mangling.* +include sage/misc/lazy_string.* +include sage/misc/lazy_format.* +include sage/misc/unknown.* +include sage/misc/fast_methods.* +include sage/misc/constant_function.* +include sage/misc/call.* +include sage/misc/bindable_class.* + +include sage/misc/verbose.* +include sage/misc/repr.* +include sage/misc/superseded.* +include sage/misc/misc_c.* # prod +include sage/misc/flatten.* # dep of sage/categories/coxeter_groups.py + +include sage/misc/lazy_import*.* +include sage/misc/sageinspect.* # dep of sage/misc/lazy_import +graft sage/docs # dep of sage/misc/lazy_import + +include sage/misc/persist.* +include sage/misc/sage_unittest.* # dep of sage/misc/persist + +include sage/ext/__init__.py +include sage/ext/stdsage.pxd +include sage/sets/__init__.py +include sage/sets/pythonclass.* +include sage/arith/__init__.py +include sage/arith/power.* +include sage/arith/numerical_approx.* +# integers... +include sage/arith/long.* +include sage/rings/__init__.py +include sage/rings/integer_fake.* +include sage/libs/__init__.py +graft sage/libs/gmp + + + +## What we do not want: +# sage/misc/latex -- this should really go to another package + + +## For doctesting +include bin/sage +include bin/sage-env +include bin/sage-env-config +include bin/sage-python +include bin/sage-runtests +graft sage/doctest +include sage/misc/temporary_file.* +include sage/misc/randstate.* +include sage/misc/misc.* # walltime, cputime +# graft sage/features +include sage/misc/package.* + +graft sage/repl +graft sage/server + +global-exclude *.py[co] diff --git a/pkgs/sagemath-objects/README.rst b/pkgs/sagemath-objects/README.rst new file mode 100644 index 00000000000..8e707fcd489 --- /dev/null +++ b/pkgs/sagemath-objects/README.rst @@ -0,0 +1,35 @@ +============================================================================================================ + Sage: Open Source Mathematics Software: Sage objects, elements, parents, categories, coercion, metaclasses +============================================================================================================ + +About SageMath +-------------- + + "Creating a Viable Open Source Alternative to + Magma, Maple, Mathematica, and MATLAB" + + Copyright (C) 2005-2020 The Sage Development Team + + https://www.sagemath.org + +SageMath fully supports all major Linux distributions, recent versions of macOS, and Windows (using Cygwin or Windows Subsystem for Linux). + +The traditional and recommended way to install SageMath is from source via Sage-the-distribution (https://www.sagemath.org/download-source.html). Sage-the-distribution first builds a large number of open source packages from source (unless it finds suitable versions installed in the system) and then installs the Sage Library (sagelib, implemented in Python and Cython). + + +About this experimental pip-installable source distribution +----------------------------------------------------------- + +This pip-installable source distribution `sagemath-objects` is an experimental distribution of a small part of the Sage Library. Use at your own risk. It provides a small, fundamental subset of the modules of the Sage library ("sagelib", `sagemath-standard`), making Sage objects, the element/parent framework, categories, the coercion system and the related metaclasses available. + + +Documentation +------------- + +* `Categories `_ + +* `Structure `_ + +* `Coercion `_ + +* `Classes, Metaclasses `_ diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt new file mode 120000 index 00000000000..43f4773d7de --- /dev/null +++ b/pkgs/sagemath-objects/VERSION.txt @@ -0,0 +1 @@ +../../src/VERSION.txt \ No newline at end of file diff --git a/pkgs/sagemath-objects/bin b/pkgs/sagemath-objects/bin new file mode 120000 index 00000000000..2f8b9b30ee7 --- /dev/null +++ b/pkgs/sagemath-objects/bin @@ -0,0 +1 @@ +../../src/bin \ No newline at end of file diff --git a/pkgs/sagemath-objects/pyproject.toml.m4 b/pkgs/sagemath-objects/pyproject.toml.m4 new file mode 100644 index 00000000000..0a0149b9e45 --- /dev/null +++ b/pkgs/sagemath-objects/pyproject.toml.m4 @@ -0,0 +1,12 @@ +[build-system] +# Minimum requirements for the build system to execute. +requires = [ + esyscmd(`sage-get-system-packages install-requires-toml \ + setuptools \ + wheel \ + sage_setup \ + cython \ + gmpy2 \ + cysignals \ + ')] +build-backend = "setuptools.build_meta" diff --git a/pkgs/sagemath-objects/requirements.txt.m4 b/pkgs/sagemath-objects/requirements.txt.m4 new file mode 100644 index 00000000000..562b53896b6 --- /dev/null +++ b/pkgs/sagemath-objects/requirements.txt.m4 @@ -0,0 +1,4 @@ +cysignals==esyscmd(`printf $(sed "s/[.]p.*//;" ../cysignals/package-version.txt)') +Cython==esyscmd(`printf $(sed "s/[.]p.*//;" ../cython/package-version.txt)') +gmpy2==esyscmd(`printf $(sed "s/[.]p.*//;" ../gmpy2/package-version.txt)') +ipython==esyscmd(`printf $(sed "s/[.]p.*//;" ../ipython/package-version.txt)') diff --git a/pkgs/sagemath-objects/sage b/pkgs/sagemath-objects/sage new file mode 120000 index 00000000000..e0da5daa6f2 --- /dev/null +++ b/pkgs/sagemath-objects/sage @@ -0,0 +1 @@ +../../src/sage \ No newline at end of file diff --git a/pkgs/sagemath-objects/sage_setup b/pkgs/sagemath-objects/sage_setup new file mode 120000 index 00000000000..88b8133df49 --- /dev/null +++ b/pkgs/sagemath-objects/sage_setup @@ -0,0 +1 @@ +../../src/sage_setup \ No newline at end of file diff --git a/pkgs/sagemath-objects/setup.cfg.m4 b/pkgs/sagemath-objects/setup.cfg.m4 new file mode 100644 index 00000000000..ed1d60e1192 --- /dev/null +++ b/pkgs/sagemath-objects/setup.cfg.m4 @@ -0,0 +1,35 @@ +# -*- conf-unix -*- +[metadata] +name = sagemath-objects +version = file: VERSION.txt +description = Sage: Open Source Mathematics Software: Sage objects, elements, parents, categories, coercion, metaclasses +long_description = file: README.rst +long_description_content_type = text/x-rst +license = GNU General Public License (GPL) v2 or later +author = The Sage Developers +author_email = sage-support@googlegroups.com +url = https://www.sagemath.org + +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.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: Implementation :: CPython + Topic :: Scientific/Engineering :: Mathematics + +[options] +python_requires = >=3.7, <3.10 +install_requires = + esyscmd(`sage-get-system-packages install-requires \ + cython \ + pkgconfig \ + gmpy2 \ + cysignals \ + | sed "2,\$s/^/ /;"')dnl diff --git a/pkgs/sagemath-objects/setup.py b/pkgs/sagemath-objects/setup.py new file mode 100644 index 00000000000..b988cbeaac1 --- /dev/null +++ b/pkgs/sagemath-objects/setup.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +from distutils import log +from setuptools import setup + +# Work around a Cython problem in Python 3.8.x on macOS +# https://github.com/cython/cython/issues/3262 +import os +if os.uname().sysname == 'Darwin': + import multiprocessing + multiprocessing.set_start_method('fork', force=True) + +# PEP 517 builds do not have . in sys.path +import sys +sys.path.insert(0, os.path.dirname(__file__)) + +if len(sys.argv) > 1 and (sys.argv[1] == "sdist" or sys.argv[1] == "egg_info"): + sdist = True +else: + sdist = False + +import sage.env +sage.env.default_required_modules = sage.env.default_optional_modules = () + +from sage_setup.command.sage_build_cython import sage_build_cython +from sage_setup.command.sage_build_ext import sage_build_ext + +if sdist: + python_packages = [] + python_modules = [] + cython_modules = [] +else: + from sage_setup.find import find_python_sources + python_packages, python_modules, cython_modules = find_python_sources( + '.', ['sage']) # for now, we do the filtering using MANIFEST + + log.warn('python_packages = {0}'.format(python_packages)) + log.warn('python_modules = {0}'.format(python_modules)) + log.warn('cython_modules = {0}'.format(cython_modules)) + +setup( + cmdclass = dict(build_cython=sage_build_cython, + build_ext=sage_build_ext), + packages = python_packages, + py_modules = python_modules, + ext_modules = cython_modules, + scripts = [## The sage script + 'bin/sage', + 'bin/sage-env', + 'bin/sage-env-config', + 'bin/sage-runtests', + ], +) diff --git a/pkgs/sagemath-objects/tox.ini b/pkgs/sagemath-objects/tox.ini new file mode 100644 index 00000000000..a1244f7aa8c --- /dev/null +++ b/pkgs/sagemath-objects/tox.ini @@ -0,0 +1,31 @@ +# To build and test in the tox environment: +# +# ./sage -sh -c '(cd pkgs/sagemath-objects && tox -v -v)' +# +# To test interactively: +# +# pkgs/sagemath-objects/.tox/python/bin/python +# +[tox] + +[testenv] +deps = -rrequirements.txt + +setenv = + # Sage scripts such as sage-runtests like to use $HOME/.sage + HOME={envdir} + +passenv = + SAGE_NUM_THREADS + SAGE_NUM_THREADS_PARALLEL + +whitelist_externals = + bash + +commands = + # Beware of the treacherous non-src layout. "./sage/" shadows the installed sage package. + python -c 'import sys; "" in sys.path and sys.path.remove(""); import sage.structure.all, sage.categories.sets_cat' + + python -c 'import sys; "" in sys.path and sys.path.remove(""); from sage.all__sagemath_objects import *' + + bash -c 'cd bin && SAGE_SRC=$(python -c "from sage.env import SAGE_SRC; print(SAGE_SRC)") && sage-runtests --environment=sage.all__sagemath_objects --optional=sage $SAGE_SRC/sage/structure || echo "(lots of doctest failures are expected)"' diff --git a/pkgs/sagemath-standard/README.rst b/pkgs/sagemath-standard/README.rst index 52e0533c8c2..5709c22249b 100644 --- a/pkgs/sagemath-standard/README.rst +++ b/pkgs/sagemath-standard/README.rst @@ -22,7 +22,10 @@ About this experimental pip-installable source distribution This pip-installable source distribution `sagemath-standard` is an experimental distribution of the Sage Library. Use at your own risk. -Building `sagemath-standard` has a large number of system packages as prerequisites. See https://doc.sagemath.org/html/en/installation/source.html#linux-recommended-installation +Building `sagemath-standard` has a large number of system packages as prerequisites. +See https://doc.sagemath.org/html/en/installation/source.html#linux-recommended-installation for partial lists for various systems. +The connection to the system environment is facilitated through the https://pypi.org/project/sage-conf/ distribution package. + A modularization effort is in progress with the goal of making it possible to install parts of the Sage Library with fewer prerequisites. https://trac.sagemath.org/ticket/29705 diff --git a/src/sage/all__sagemath_categories.py b/src/sage/all__sagemath_categories.py new file mode 100644 index 00000000000..4f438a77cbe --- /dev/null +++ b/src/sage/all__sagemath_categories.py @@ -0,0 +1,5 @@ +from .all__sagemath_objects import * + +from sage.categories.all import * + +from sage.rings.all__sagemath_categories import * diff --git a/src/sage/all__sagemath_objects.py b/src/sage/all__sagemath_objects.py new file mode 100644 index 00000000000..9bca14eab0e --- /dev/null +++ b/src/sage/all__sagemath_objects.py @@ -0,0 +1,9 @@ +# TODO: More to be moved from all.py + +# This import also sets up the interrupt handler +from cysignals.signals import (AlarmInterrupt, SignalError, + sig_on_reset as sig_on_count) + +from sage.misc.all__sagemath_objects import * +from sage.structure.all import * +from sage.categories.all__sagemath_objects import * diff --git a/src/sage/categories/all.py b/src/sage/categories/all.py index 053fd577d24..a92fc4e09cd 100644 --- a/src/sage/categories/all.py +++ b/src/sage/categories/all.py @@ -1,8 +1,8 @@ from sage.misc.lazy_import import lazy_import -from .category import Category +from .all__sagemath_objects import * -from .category_types import Elements +from .basic import * from .chain_complexes import ChainComplexes, HomologyFunctor @@ -10,25 +10,10 @@ from .tensor import tensor from .signed_tensor import tensor_signed -from .cartesian_product import cartesian_product - -from .functor import (ForgetfulFunctor, - IdentityFunctor) - -from .homset import (Hom, hom, - End, end, - Homset, HomsetWithBase) - -from .morphism import Morphism - -from .basic import * - -from .realizations import Realizations from .g_sets import GSets from .pointed_sets import PointedSets -from .sets_with_partial_maps import SetsWithPartialMaps from .sets_with_grading import SetsWithGrading from .groupoid import Groupoid diff --git a/src/sage/categories/all__sagemath_objects.py b/src/sage/categories/all__sagemath_objects.py new file mode 100644 index 00000000000..dee0881d787 --- /dev/null +++ b/src/sage/categories/all__sagemath_objects.py @@ -0,0 +1,31 @@ +# Subset of sage.categories.all that is made available by the sage-objects distribution + +from sage.misc.lazy_import import lazy_import + +# Resolve a circular import so that "import sage.categories.all" can succeed +# in initializing the category system. +import sage.structure.category_object # imports sage.categories.category + +# Small part of "from .basic import *": +from .objects import Objects +from .sets_cat import Sets, EmptySetError + + +from .category import Category + +from .category_types import Elements + +from .cartesian_product import cartesian_product + +from .functor import (ForgetfulFunctor, + IdentityFunctor) + +from .homset import (Hom, hom, + End, end, + Homset, HomsetWithBase) + +from .morphism import Morphism + +from .realizations import Realizations + +from .sets_with_partial_maps import SetsWithPartialMaps diff --git a/src/sage/misc/all.py b/src/sage/misc/all.py index ca8374da85e..56d66f0f5f0 100644 --- a/src/sage/misc/all.py +++ b/src/sage/misc/all.py @@ -1,6 +1,8 @@ from .lazy_attribute import lazy_attribute, lazy_class_attribute from .lazy_import import lazy_import +from .all__sagemath_objects import * + from .misc import (BackslashOperator, cputime, union, uniq, powerset, subsets, @@ -13,34 +15,20 @@ lazy_import('sage.misc.misc', 'union', deprecation=32096) -from .verbose import (set_verbose, set_verbose_files, - get_verbose_files, unset_verbose_files, get_verbose) -lazy_import('sage.misc.verbose', 'verbose', - deprecation=17815) -from .call import attrcall - from .banner import version, banner from .temporary_file import tmp_dir, tmp_filename -from .misc_c import prod, running_total, balanced_sum -mul = prod -add = sum - from .dev_tools import runsnake, import_statements from .html import html, pretty_print_default -from .repr import repr_lincomb - from .table import table from .sage_timeit_class import timeit from .edit_module import edit, set_edit_template -from .flatten import flatten - from .map_threaded import map_threaded from .session import load_session, save_session, show_identifiers @@ -83,8 +71,6 @@ lazy_import("sage.misc.cython", "cython_lambda") lazy_import("sage.misc.cython", "cython_compile", "cython") -from .persist import save, load, dumps, loads, db, db_save - from .func_persist import func_persist from .functional import (additive_order, @@ -150,24 +136,12 @@ from .trace import trace -from .constant_function import ConstantFunction - -from .cachefunc import CachedFunction, cached_function, cached_method, cached_in_parent_method, disk_cached_function - -from .abstract_method import abstract_method - from .randstate import seed, set_random_seed, initial_seed, current_randstate from .prandom import * -from .sage_unittest import TestSuite - from .explain_pickle import explain_pickle, unpickle_newobj, unpickle_global, unpickle_build, unpickle_instantiate, unpickle_persistent, unpickle_extension, unpickle_appends -from .decorators import specialize, sage_wraps, infix_operator - -from .unknown import Unknown, UnknownError - lazy_import('sage.misc.inline_fortran', 'fortran') diff --git a/src/sage/misc/all__sagemath_objects.py b/src/sage/misc/all__sagemath_objects.py new file mode 100644 index 00000000000..3090b5a8913 --- /dev/null +++ b/src/sage/misc/all__sagemath_objects.py @@ -0,0 +1,34 @@ +# Subset of sage.misc.all that is made available by the sage-objects distribution + +import sage.structure.all # to break a cyclic import + +from .lazy_attribute import lazy_attribute, lazy_class_attribute +from .lazy_import import lazy_import + +from .verbose import (set_verbose, set_verbose_files, + get_verbose_files, unset_verbose_files, get_verbose) +lazy_import('sage.misc.verbose', 'verbose', + deprecation=17815) +from .call import attrcall + +from .misc_c import prod, running_total, balanced_sum +mul = prod +add = sum + +from .repr import repr_lincomb + +from .flatten import flatten + +from .persist import save, load, dumps, loads, db, db_save + +from .constant_function import ConstantFunction + +from .sage_unittest import TestSuite + +from .decorators import specialize, sage_wraps, infix_operator + +from .unknown import Unknown, UnknownError + +from .cachefunc import CachedFunction, cached_function, cached_method, cached_in_parent_method, disk_cached_function + +from .abstract_method import abstract_method diff --git a/src/sage/misc/misc.py b/src/sage/misc/misc.py index fbebd99b3a3..65a2b2ae586 100644 --- a/src/sage/misc/misc.py +++ b/src/sage/misc/misc.py @@ -44,9 +44,7 @@ import pdb import warnings -import sage.misc.prandom as random from .lazy_string import lazy_string -from sage.interfaces.quit import expect_objects from sage.env import DOT_SAGE, HOSTNAME from sage.misc.lazy_import import lazy_import @@ -342,6 +340,7 @@ def cputime(t=0, subprocesses=False): u, s = resource.getrusage(resource.RUSAGE_SELF)[:2] return u + s - t else: + from sage.interfaces.quit import expect_objects if t == 0: ret = GlobalCputime(cputime()) for s in expect_objects: @@ -920,6 +919,7 @@ def random_sublist(X, s): sage: is_sublist(sublist, S) True """ + import sage.misc.prandom as random return [a for a in X if random.random() <= s] @@ -1026,6 +1026,7 @@ def _some_tuples_sampling(elements, repeat, max_samples, n): True """ from sage.rings.integer import Integer + import sage.misc.prandom as random N = n if repeat is None else n**repeat # We sample on range(N) and create tuples manually since we don't want to create the list of all possible tuples in memory for a in random.sample(range(N), max_samples): diff --git a/src/sage/rings/all.py b/src/sage/rings/all.py index a8a1da9ff3d..9b73f1974a1 100644 --- a/src/sage/rings/all.py +++ b/src/sage/rings/all.py @@ -12,6 +12,8 @@ # **************************************************************************** from sage.misc.lazy_import import lazy_import +from .all__sagemath_categories import * + # Ring base classes from .ring import (Ring, Field, CommutativeRing, IntegralDomain, DedekindDomain, PrincipalIdealDomain, EuclideanDomain) diff --git a/src/sage/rings/all__sagemath_categories.py b/src/sage/rings/all__sagemath_categories.py new file mode 100644 index 00000000000..8d14e7afcda --- /dev/null +++ b/src/sage/rings/all__sagemath_categories.py @@ -0,0 +1,6 @@ +# Ring base classes +from .ring import Ring + +# Ideals +from .ideal import Ideal +ideal = Ideal diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py index 3a135b8f982..31d8aa9c424 100644 --- a/src/sage/rings/ideal.py +++ b/src/sage/rings/ideal.py @@ -28,11 +28,9 @@ from types import GeneratorType -import sage.misc.latex as latex import sage.rings.ring from sage.structure.element import MonoidElement from sage.structure.richcmp import rich_to_bool, richcmp -import sage.rings.infinity from sage.structure.sequence import Sequence def Ideal(*args, **kwds): @@ -536,6 +534,7 @@ def _latex_(self): sage: latex(3*ZZ) # indirect doctest \left(3\right)\Bold{Z} """ + import sage.misc.latex as latex return '\\left(%s\\right)%s' % (", ".join(latex.latex(g) for g in self.gens()), latex.latex(self.ring())) @@ -1803,6 +1802,7 @@ def FieldIdeal(R): q = R.base_ring().order() + import sage.rings.infinity if q is sage.rings.infinity.infinity: raise TypeError("Cannot construct field ideal for R.base_ring().order()==infinity") diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py index c60b20b461b..311bf869ef2 100644 --- a/src/sage/structure/all.py +++ b/src/sage/structure/all.py @@ -20,7 +20,9 @@ from .proof import all as proof -from .formal_sum import FormalSums, FormalSum +from sage.misc.lazy_import import lazy_import +lazy_import('sage.structure.formal_sum', ['FormalSums', 'FormalSum']) +del lazy_import from .mutability import Mutability