diff --git a/.github/workflows/ci-conda.yml b/.github/workflows/ci-conda.yml index 2240c224a52..2a8adcb7149 100644 --- a/.github/workflows/ci-conda.yml +++ b/.github/workflows/ci-conda.yml @@ -66,21 +66,20 @@ jobs: conda info conda list - - name: Configure + - name: Bootstrap shell: bash -l {0} - continue-on-error: true - run: | - ./bootstrap - echo "::add-matcher::.github/workflows/configure-systempackage-problem-matcher.json" - ./configure --enable-build-as-root --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREFIX --enable-system-site-packages $(for pkg in $(./sage -package list :standard: --has-file spkg-configure.m4 --has-file distros/conda.txt --exclude rpy2); do echo --with-system-$pkg=force; done) - echo "::remove-matcher owner=configure-system-package-warning::" - echo "::remove-matcher owner=configure-system-package-error::" + run: ./bootstrap - name: Build shell: bash -l {0} run: | # Use --no-deps and pip check below to verify that all necessary dependencies are installed via conda. - pip install --no-build-isolation --no-deps -v -v -e ./pkgs/sage-conf ./pkgs/sage-setup + echo "::group::sage-setup" + pip install --no-build-isolation --no-deps -v -v -e ./pkgs/sage-setup + echo "::endgroup::" + echo "::group::sage-conf" + pip install --no-build-isolation --no-deps -v -v -e ./pkgs/sage-conf_meson + echo "::endgroup::" pip install --no-build-isolation --no-deps --config-settings editable_mode=compat -v -v -e ./src env: SAGE_NUM_THREADS: 2 @@ -95,6 +94,12 @@ jobs: shell: bash -l {0} run: ./sage -t --all -p0 + # We keep this step for now to make sure that the configure-based setup still works. + - name: Test configure + shell: bash -l {0} + run: | + ./configure --enable-build-as-root --with-python=$CONDA_PREFIX/bin/python --prefix=$CONDA_PREFIX --enable-system-site-packages $(for pkg in $(./sage -package list :standard: --has-file spkg-configure.m4 --has-file distros/conda.txt --exclude rpy2); do echo --with-system-$pkg=force; done) || true + - name: Print logs if: always() run: | diff --git a/.gitignore b/.gitignore index 43f58abcafe..aa04337d12a 100644 --- a/.gitignore +++ b/.gitignore @@ -284,3 +284,6 @@ src/.coverage/ # git worktree worktree* **/worktree* + +# meson build directory +builddir diff --git a/.vscode/settings.json b/.vscode/settings.json index 050be4ca5e5..86885e6ea4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -35,5 +35,6 @@ "sagemath", "Cython" ], - "editor.formatOnType": true + "editor.formatOnType": true, + "esbonio.sphinx.confDir": "" } diff --git a/bootstrap-conda b/bootstrap-conda index faa29513db4..d50e39499cc 100755 --- a/bootstrap-conda +++ b/bootstrap-conda @@ -98,6 +98,7 @@ echo >&2 $0:$LINENO: generate conda environment files ) > environment-template.yml ( sed 's/name: sage-build/name: sage/' environment-template.yml + echo " - meson" echo " # Additional packages providing all dependencies for the Sage library" for pkg in $SAGELIB_SYSTEM_PACKAGES; do echo " - $pkg" diff --git a/meson.build b/meson.build new file mode 100644 index 00000000000..ffd4348aa4c --- /dev/null +++ b/meson.build @@ -0,0 +1,10 @@ +project('sage', 'c') +cc = meson.get_compiler('c') + +maxima = find_program('maxima', required: true) +ecl_config = find_program('ecl-config', required: true) +openmp = dependency('openmp', required : false) +#ntl = dependency('ntl', required: true) doesn't work, so ask the compiler directly: +ntl = cc.find_library('ntl', required: true) + +subdir('pkgs/sage-conf_meson') diff --git a/pkgs/sage-conf/pyproject.toml b/pkgs/sage-conf/pyproject.toml index 9787c3bdf00..9b39d5d8816 100644 --- a/pkgs/sage-conf/pyproject.toml +++ b/pkgs/sage-conf/pyproject.toml @@ -1,3 +1,10 @@ [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" + +[project] +name = "sage-conf" +dynamic = ["version"] + +[tool.setuptools.dynamic] +version = {file = ["VERSION.txt"]} diff --git a/pkgs/sage-conf/setup.cfg b/pkgs/sage-conf/setup.cfg index dac401c303d..06f36099bd5 100644 --- a/pkgs/sage-conf/setup.cfg +++ b/pkgs/sage-conf/setup.cfg @@ -1,6 +1,5 @@ [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 diff --git a/pkgs/sage-conf_meson/.gitignore b/pkgs/sage-conf_meson/.gitignore new file mode 100644 index 00000000000..c345b916765 --- /dev/null +++ b/pkgs/sage-conf_meson/.gitignore @@ -0,0 +1,6 @@ +/sage_conf/builddir +/build +/dist +/*.egg-info +/.tox +/bin/sage-env-config diff --git a/pkgs/sage-conf_meson/README.rst b/pkgs/sage-conf_meson/README.rst new file mode 120000 index 00000000000..feda886cd36 --- /dev/null +++ b/pkgs/sage-conf_meson/README.rst @@ -0,0 +1 @@ +../sage-conf/README.rst \ No newline at end of file diff --git a/pkgs/sage-conf_meson/VERSION.txt b/pkgs/sage-conf_meson/VERSION.txt new file mode 100644 index 00000000000..66f8b2a93e1 --- /dev/null +++ b/pkgs/sage-conf_meson/VERSION.txt @@ -0,0 +1 @@ +10.2.beta8 diff --git a/pkgs/sage-conf_meson/meson.build b/pkgs/sage-conf_meson/meson.build new file mode 100644 index 00000000000..852eb4c0607 --- /dev/null +++ b/pkgs/sage-conf_meson/meson.build @@ -0,0 +1,32 @@ +conf_data = configuration_data() + +conf_data.set('PACKAGE_VERSION', '1.2.3') + +conf_data.set('SAGE_MAXIMA', maxima.path()) +# Conda's ecl does not have any problems with Maxima, so nothing needs to be set here: +conf_data.set('SAGE_MAXIMA_FAS', '') + +# Kenzo cannot yet be provided by the system, so we always use the SAGE_LOCAL path for now. +conf_data.set('SAGE_KENZO_FAS', '\'${prefix}\'/lib/ecl/kenzo.fas') + +conf_data.set('SAGE_ARB_LIBRARY', 'arb') + +# It can be found, so we don't have to set anything here: +conf_data.set('NTL_INCDIR', '') +conf_data.set('NTL_LIBDIR', '') + +conf_data.set('SAGE_ECL_CONFIG', ecl_config.path()) + +conf_data.set('SAGE_ARCHFLAGS', 'unset') + +# not needed when using conda, as we then don't build any pc files +conf_data.set('SAGE_PKG_CONFIG_PATH', '') + +if openmp.found() + conf_data.set('OPENMP_CFLAGS', '-fopenmp') + conf_data.set('OPENMP_CXXFLAGS', '-fopenmp') +endif + +configure_file(input : '../sage-conf_conda/_sage_conf/_conf.py.in', + output : '_conf.py', + configuration : conf_data) diff --git a/pkgs/sage-conf_meson/pyproject.toml b/pkgs/sage-conf_meson/pyproject.toml new file mode 120000 index 00000000000..52c93c824e2 --- /dev/null +++ b/pkgs/sage-conf_meson/pyproject.toml @@ -0,0 +1 @@ +../sage-conf/pyproject.toml \ No newline at end of file diff --git a/pkgs/sage-conf_meson/sage_conf/__init__.py b/pkgs/sage-conf_meson/sage_conf/__init__.py new file mode 100644 index 00000000000..ab98a51f0c6 --- /dev/null +++ b/pkgs/sage-conf_meson/sage_conf/__init__.py @@ -0,0 +1,9 @@ +import importlib + +from .builddir.build_info import CONDA_PREFIX + +conf = importlib.import_module('.builddir.pkgs.sage-conf_meson._conf', 'sage_conf') +conf_options = [x for x in conf.__dict__ if not x.startswith("_")] +globals().update({k: getattr(conf, k) for k in conf_options}) + +SAGE_LOCAL = CONDA_PREFIX diff --git a/pkgs/sage-conf_meson/setup.py b/pkgs/sage-conf_meson/setup.py new file mode 100644 index 00000000000..5af1f5bae4e --- /dev/null +++ b/pkgs/sage-conf_meson/setup.py @@ -0,0 +1,53 @@ +import os +import sys +from pathlib import Path + +from setuptools import setup +from setuptools.command.build_py import build_py as setuptools_build_py +from setuptools.command.editable_wheel import ( + editable_wheel as setuptools_editable_wheel, +) +from setuptools.errors import SetupError + + +class build_py(setuptools_build_py): + def run(self): + here = Path(__file__).parent + if self.editable_mode: + root = here.parent.parent + else: + raise SetupError('Not supported') + + conda_prefix = os.environ.get('CONDA_PREFIX', '') + if not conda_prefix: + raise SetupError( + 'No conda environment is active. ' + 'See https://doc.sagemath.org/html/en/installation/conda.html on how to get started.' + ) + + builddir = here / "sage_conf" / "builddir" + cmd = f"cd {root} && meson setup {builddir} --wipe" + print(f"Running {cmd}") + sys.stdout.flush() + if os.system(cmd) != 0: + raise SetupError("configure failed") + + # Write build info + with open(builddir / 'build_info.py', 'w', encoding="utf-8") as build_info: + build_info.write(f'SAGE_ROOT = "{root}"\n') + build_info.write(f'CONDA_PREFIX = "{conda_prefix}"\n') + + +class editable_wheel(setuptools_editable_wheel): + r""" + Customized so that exceptions raised by our build_py + do not lead to the "Customization incompatible with editable install" message + """ + _safely_run = setuptools_editable_wheel.run_command + + +setup( + cmdclass=dict( + build_py=build_py, editable_wheel=editable_wheel + ) +) diff --git a/src/doc/en/installation/conda.rst b/src/doc/en/installation/conda.rst index 9456deff2b0..8f1712ffa33 100644 --- a/src/doc/en/installation/conda.rst +++ b/src/doc/en/installation/conda.rst @@ -139,9 +139,12 @@ Here we assume that you are using a git checkout. - Bootstrap the source tree and install the build prerequisites and the Sage library:: $ ./bootstrap - $ pip install --no-build-isolation -v -v --editable ./pkgs/sage-conf_conda ./pkgs/sage-setup + $ pip install --no-build-isolation -v -v --editable ./pkgs/sage-conf_meson ./pkgs/sage-setup $ pip install --no-build-isolation --config-settings editable_mode=compat -v -v --editable ./src + In case of errors, try to use ``sage-conf_conda`` instead of ``sage-conf_meson``, + and please report the problem by opening an issue on GitHub. + - Verify that Sage has been installed:: $ sage -c 'print(version())'