diff --git a/.github/workflows/ci-meson.yml b/.github/workflows/ci-meson.yml new file mode 100644 index 00000000000..3ecccb4c16c --- /dev/null +++ b/.github/workflows/ci-meson.yml @@ -0,0 +1,79 @@ +name: Build & Test using Meson + +on: + push: + branches: + - master + - develop + pull_request: + workflow_dispatch: + # Allow to run manually + +concurrency: + # Cancel previous runs of this workflow for the same branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: Conda (${{ matrix.os }}, Python ${{ matrix.python }}) + runs-on: ${{ matrix.os }}-latest + + strategy: + fail-fast: false + matrix: + os: [ubuntu] + python: ['3.9', '3.10', '3.11'] + + steps: + - uses: actions/checkout@v4 + + - name: Merge CI fixes from sagemath/sage + run: | + .ci/merge-fixes.sh + env: + GH_TOKEN: ${{ github.token }} + + - name: Cache conda packages + uses: actions/cache@v4 + with: + path: ~/conda_pkgs_dir + key: + ${{ runner.os }}-conda-${{ hashFiles('src/environment-3.11-linux.yml') }} + + - name: Compiler cache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ runner.os }}-meson-${{ matrix.python }} + + - name: Setup Conda environment + uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python }} + miniforge-version: latest + use-mamba: true + channels: conda-forge + channel-priority: true + activate-environment: sage + environment-file: src/environment-${{ matrix.python }}-${{ startsWith(matrix.os, 'macos') && (startsWith(runner.arch, 'ARM') && 'macos' || 'macos-x86_64') || 'linux' }}.yml + + - name: Print Conda environment + shell: bash -l {0} + run: | + conda info + conda list + + - name: Build + shell: bash -l {0} + run: | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + export CC="ccache $CC" + export CXX="ccache $CXX" + pip install --no-build-isolation --config-settings=builddir=builddir . -v + + - name: Test + shell: bash -l {0} + run: | + # We don't install sage_setup, so don't try to test it + rm -R ./src/sage_setup/ + ./sage -t --all -p4 diff --git a/.gitignore b/.gitignore index 70a6739c33b..7d8c2f0adc4 100644 --- a/.gitignore +++ b/.gitignore @@ -146,10 +146,12 @@ __pycache__/ # Generated by sage_setup.autogen /src/sage/ext/interpreters +!/src/sage/ext/interpreters/meson.build # Generated Cython files *.so **/*.so +**/*.so.old /src/cython_debug # Most C and C++ files are generated by Cython and should not # be included in the sdist. @@ -299,3 +301,171 @@ src/.coverage/ # git worktree worktree* **/worktree* + +# Meson build directory +builddir +builddir-* +build-install +build/cp* + +# Meson temporary files +src/sage/interfaces/__init__.py +src/sage/crypto/block_cipher/__init__.py +src/sage/crypto/public_key/__init__.py +src/sage/logic/__init__.py +src/sage/parallel/__init__.py +src/sage/dynamics/cellular_automata/__init__.py +src/sage/dynamics/arithmetic_dynamics/__init__.py +src/sage/dynamics/__init__.py +src/sage/dynamics/complex_dynamics/__init__.py +src/sage/knots/__init__.py +src/sage/topology/__init__.py +src/sage/functions/__init__.py +src/sage/manifolds/subsets/__init__.py +src/sage/manifolds/__init__.py +src/sage/manifolds/differentiable/examples/__init__.py +src/sage/manifolds/differentiable/__init__.py +src/sage/coding/source_coding/__init__.py +src/sage/coding/guruswami_sudan/__init__.py +src/sage/coding/__init__.py +src/sage/coding/codecan/__init__.py +src/sage/games/__init__.py +src/sage/quivers/__init__.py +src/sage/schemes/cyclic_covers/__init__.py +src/sage/schemes/plane_conics/__init__.py +src/sage/schemes/curves/__init__.py +src/sage/schemes/plane_quartics/__init__.py +src/sage/schemes/jacobians/__init__.py +src/sage/schemes/toric/sheaf/__init__.py +src/sage/schemes/toric/__init__.py +src/sage/schemes/product_projective/__init__.py +src/sage/schemes/elliptic_curves/__init__.py +src/sage/schemes/riemann_surfaces/__init__.py +src/sage/schemes/hyperelliptic_curves/__init__.py +src/sage/schemes/berkovich/__init__.py +src/sage/schemes/generic/__init__.py +src/sage/schemes/projective/__init__.py +src/sage/schemes/__init__.py +src/sage/schemes/affine/__init__.py +src/sage/modular/hecke/__init__.py +src/sage/modular/pollack_stevens/__init__.py +src/sage/modular/overconvergent/__init__.py +src/sage/modular/modform/__init__.py +src/sage/modular/quasimodform/__init__.py +src/sage/modular/modsym/__init__.py +src/sage/modular/local_comp/__init__.py +src/sage/modular/quatalg/__init__.py +src/sage/modular/ssmod/__init__.py +src/sage/modular/abvar/__init__.py +src/sage/modular/__init__.py +src/sage/modular/btquotients/__init__.py +src/sage/modular/arithgroup/__init__.py +src/sage/modular/modform_hecketriangle/__init__.py +src/sage/combinat/cluster_algebra_quiver/__init__.py +src/sage/combinat/root_system/__init__.py +src/sage/combinat/species/__init__.py +src/sage/combinat/designs/__init__.py +src/sage/combinat/posets/__init__.py +src/sage/combinat/matrices/__init__.py +src/sage/combinat/rigged_configurations/__init__.py +src/sage/combinat/ncsf_qsym/__init__.py +src/sage/combinat/path_tableaux/__init__.py +src/sage/combinat/sf/__init__.py +src/sage/combinat/__init__.py +src/sage/combinat/chas/__init__.py +src/sage/combinat/ncsym/__init__.py +src/sage/combinat/words/__init__.py +src/sage/combinat/crystals/__init__.py +src/sage/tensor/modules/__init__.py +src/sage/tensor/__init__.py +src/sage/groups/matrix_gps/__init__.py +src/sage/groups/semimonomial_transformations/__init__.py +src/sage/groups/perm_gps/partn_ref2/__init__.py +src/sage/groups/perm_gps/partn_ref/__init__.py +src/sage/groups/perm_gps/__init__.py +src/sage/groups/__init__.py +src/sage/groups/affine_gps/__init__.py +src/sage/groups/abelian_gps/__init__.py +src/sage/groups/additive_abelian/__init__.py +src/sage/groups/lie_gps/__init__.py +src/sage/groups/misc_gps/__init__.py +src/sage/symbolic/__init__.py +src/sage/symbolic/integration/__init__.py +src/sage/lfunctions/__init__.py +src/sage/arith/__init__.py +src/sage/ext/__init__.py +src/sage/categories/examples/__init__.py +src/sage/categories/__init__.py +src/sage/modules/fg_pid/__init__.py +src/sage/modules/__init__.py +src/sage/modules/with_basis/__init__.py +src/sage/modules/fp_graded/steenrod/__init__.py +src/sage/modules/fp_graded/__init__.py +src/sage/misc/__init__.py +src/sage/rings/convert/__init__.py +src/sage/rings/invariants/__init__.py +src/sage/rings/finite_rings/__init__.py +src/sage/rings/function_field/__init__.py +src/sage/rings/function_field/drinfeld_modules/__init__.py +src/sage/rings/semirings/__init__.py +src/sage/rings/number_field/__init__.py +src/sage/rings/__init__.py +src/sage/rings/padics/__init__.py +src/sage/rings/valuation/__init__.py +src/sage/rings/asymptotic/__init__.py +src/sage/rings/polynomial/weil/__init__.py +src/sage/rings/polynomial/__init__.py +src/sage/rings/polynomial/padics/__init__.py +src/sage/monoids/__init__.py +src/sage/matrix/__init__.py +src/sage/matroids/__init__.py +src/sage/interacts/__init__.py +src/sage/__init__.py +src/sage/plot/__init__.py +src/sage/plot/plot3d/__init__.py +src/sage/typeset/__init__.py +src/sage/algebras/lie_conformal_algebras/__init__.py +src/sage/algebras/fusion_rings/__init__.py +src/sage/algebras/letterplace/__init__.py +src/sage/algebras/quatalg/__init__.py +src/sage/algebras/steenrod/__init__.py +src/sage/algebras/finite_dimensional_algebras/__init__.py +src/sage/algebras/__init__.py +src/sage/algebras/hecke_algebras/__init__.py +src/sage/algebras/lie_algebras/__init__.py +src/sage/algebras/quantum_groups/__init__.py +src/sage/quadratic_forms/genera/__init__.py +src/sage/quadratic_forms/__init__.py +src/sage/game_theory/__init__.py +src/sage/sandpiles/__init__.py +src/sage/sat/__init__.py +src/sage/homology/__init__.py +src/sage/geometry/riemannian_manifolds/__init__.py +src/sage/geometry/hyperplane_arrangement/__init__.py +src/sage/geometry/triangulation/__init__.py +src/sage/geometry/polyhedron/modules/__init__.py +src/sage/geometry/polyhedron/__init__.py +src/sage/geometry/polyhedron/combinatorial_polyhedron/__init__.py +src/sage/geometry/__init__.py +src/sage/geometry/hyperbolic_space/__init__.py +src/sage/sets/__init__.py +src/sage/probability/__init__.py +src/sage/numerical/backends/__init__.py +src/sage/numerical/__init__.py +src/sage/data_structures/__init__.py +src/sage/graphs/graph_decompositions/__init__.py +src/sage/graphs/generators/__init__.py +src/sage/graphs/__init__.py +src/sage/graphs/base/__init__.py +src/sage/databases/__init__.py +src/sage/stats/hmm/__init__.py +src/sage/stats/__init__.py +src/sage/stats/distributions/__init__.py +src/sage/libs/gap/__init__.py +src/sage/libs/mpfi/__init__.py +src/sage/libs/__init__.py +src/sage/libs/polybori/__init__.py +src/sage/libs/mpfr/__init__.py +src/sage/libs/mpc/__init__.py +src/sage/calculus/transforms/__init__.py +src/sage/calculus/__init__.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 86eac03ffe9..052b55fe189 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,7 +15,8 @@ "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": true, + "pkgs/sagemath-*/sage_setup": true }, "python.testing.pytestEnabled": true, "python.testing.pytestArgs": [ diff --git a/bootstrap-conda b/bootstrap-conda index c64e2a72b6c..27e657281f9 100755 --- a/bootstrap-conda +++ b/bootstrap-conda @@ -99,6 +99,9 @@ echo >&2 $0:$LINENO: generate conda environment files ) > environment-template.yml ( sed 's/name: sage-build/name: sage/' environment-template.yml + echo " - meson" + echo " - meson-python" + echo " - pytest" echo " # Additional packages providing all dependencies for the Sage library" for pkg in $SAGELIB_SYSTEM_PACKAGES; do echo " - $pkg" diff --git a/build/pkgs/sage_setup/dependencies b/build/pkgs/sage_setup/dependencies index cae3faf9049..497a8118c28 100644 --- a/build/pkgs/sage_setup/dependencies +++ b/build/pkgs/sage_setup/dependencies @@ -1,4 +1,4 @@ - cython pkgconfig jinja2 $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/autogen/interpreters/specs/*.py $(SAGE_ROOT)/pkgs/sage-setup/sage_setup/command/*.py | $(PYTHON_TOOLCHAIN) $(PYTHON) + 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/meson.build b/meson.build new file mode 100644 index 00000000000..8bf73d23d55 --- /dev/null +++ b/meson.build @@ -0,0 +1,215 @@ +project( + 'SageMath', + ['c', 'cpp', 'cython'], + version: files('src/VERSION.txt'), + license: 'GPL v3', + default_options: ['c_std=c17', 'cpp_std=c++17'], +) + +# Python module +# https://mesonbuild.com/Python-module.html +py_module = import('python') +py = py_module.find_installation(pure: false) +py_dep = py.dependency() + +# Additional targets +py_with_pytest = py_module.find_installation( + required: false, + modules: ['pytest'], +) +if py_with_pytest.found() + test( + 'pytest', + py_with_pytest, + args: [ + '-m', + 'pytest', + '-c', + meson.current_source_dir() / 'tox.ini', + '--doctest', + meson.current_source_dir() / 'src' / 'sage' / 'categories', + ], + timeout: 0, + ) +endif + +# Workaround for missing init files (Cython doesn't handle namespace packages well) +create_files_command = [ + 'python3', + '-c', + ''' +import os +content = "# Here so that cython creates the correct module name" +file_paths = [ + 'src/sage/interfaces/__init__.py', + 'src/sage/crypto/block_cipher/__init__.py', + 'src/sage/crypto/public_key/__init__.py', + 'src/sage/logic/__init__.py', + 'src/sage/parallel/__init__.py', + 'src/sage/dynamics/cellular_automata/__init__.py', + 'src/sage/dynamics/arithmetic_dynamics/__init__.py', + 'src/sage/dynamics/__init__.py', + 'src/sage/dynamics/complex_dynamics/__init__.py', + 'src/sage/knots/__init__.py', + 'src/sage/topology/__init__.py', + 'src/sage/functions/__init__.py', + 'src/sage/manifolds/subsets/__init__.py', + 'src/sage/manifolds/__init__.py', + 'src/sage/manifolds/differentiable/examples/__init__.py', + 'src/sage/manifolds/differentiable/__init__.py', + 'src/sage/coding/source_coding/__init__.py', + 'src/sage/coding/guruswami_sudan/__init__.py', + 'src/sage/coding/__init__.py', + 'src/sage/coding/codecan/__init__.py', + 'src/sage/games/__init__.py', + 'src/sage/quivers/__init__.py', + 'src/sage/schemes/cyclic_covers/__init__.py', + 'src/sage/schemes/plane_conics/__init__.py', + 'src/sage/schemes/curves/__init__.py', + 'src/sage/schemes/plane_quartics/__init__.py', + 'src/sage/schemes/jacobians/__init__.py', + 'src/sage/schemes/toric/sheaf/__init__.py', + 'src/sage/schemes/toric/__init__.py', + 'src/sage/schemes/product_projective/__init__.py', + 'src/sage/schemes/elliptic_curves/__init__.py', + 'src/sage/schemes/riemann_surfaces/__init__.py', + 'src/sage/schemes/hyperelliptic_curves/__init__.py', + 'src/sage/schemes/berkovich/__init__.py', + 'src/sage/schemes/generic/__init__.py', + 'src/sage/schemes/projective/__init__.py', + 'src/sage/schemes/__init__.py', + 'src/sage/schemes/affine/__init__.py', + 'src/sage/modular/hecke/__init__.py', + 'src/sage/modular/pollack_stevens/__init__.py', + 'src/sage/modular/overconvergent/__init__.py', + 'src/sage/modular/modform/__init__.py', + 'src/sage/modular/quasimodform/__init__.py', + 'src/sage/modular/modsym/__init__.py', + 'src/sage/modular/local_comp/__init__.py', + 'src/sage/modular/quatalg/__init__.py', + 'src/sage/modular/ssmod/__init__.py', + 'src/sage/modular/abvar/__init__.py', + 'src/sage/modular/__init__.py', + 'src/sage/modular/btquotients/__init__.py', + 'src/sage/modular/arithgroup/__init__.py', + 'src/sage/modular/modform_hecketriangle/__init__.py', + 'src/sage/combinat/cluster_algebra_quiver/__init__.py', + 'src/sage/combinat/root_system/__init__.py', + 'src/sage/combinat/species/__init__.py', + 'src/sage/combinat/designs/__init__.py', + 'src/sage/combinat/posets/__init__.py', + 'src/sage/combinat/matrices/__init__.py', + 'src/sage/combinat/rigged_configurations/__init__.py', + 'src/sage/combinat/ncsf_qsym/__init__.py', + 'src/sage/combinat/path_tableaux/__init__.py', + 'src/sage/combinat/sf/__init__.py', + 'src/sage/combinat/__init__.py', + 'src/sage/combinat/chas/__init__.py', + 'src/sage/combinat/ncsym/__init__.py', + 'src/sage/combinat/words/__init__.py', + 'src/sage/combinat/crystals/__init__.py', + 'src/sage/tensor/modules/__init__.py', + 'src/sage/tensor/__init__.py', + 'src/sage/groups/matrix_gps/__init__.py', + 'src/sage/groups/semimonomial_transformations/__init__.py', + 'src/sage/groups/perm_gps/partn_ref2/__init__.py', + 'src/sage/groups/perm_gps/partn_ref/__init__.py', + 'src/sage/groups/perm_gps/__init__.py', + 'src/sage/groups/__init__.py', + 'src/sage/groups/affine_gps/__init__.py', + 'src/sage/groups/abelian_gps/__init__.py', + 'src/sage/groups/additive_abelian/__init__.py', + 'src/sage/groups/lie_gps/__init__.py', + 'src/sage/groups/misc_gps/__init__.py', + 'src/sage/symbolic/__init__.py', + 'src/sage/symbolic/integration/__init__.py', + 'src/sage/lfunctions/__init__.py', + 'src/sage/arith/__init__.py', + 'src/sage/ext/__init__.py', + 'src/sage/ext/interpreters/__init__.py', + 'src/sage/categories/examples/__init__.py', + 'src/sage/categories/__init__.py', + 'src/sage/modules/fg_pid/__init__.py', + 'src/sage/modules/__init__.py', + 'src/sage/modules/with_basis/__init__.py', + 'src/sage/modules/fp_graded/steenrod/__init__.py', + 'src/sage/modules/fp_graded/__init__.py', + 'src/sage/misc/__init__.py', + 'src/sage/rings/convert/__init__.py', + 'src/sage/rings/invariants/__init__.py', + 'src/sage/rings/finite_rings/__init__.py', + 'src/sage/rings/function_field/__init__.py', + 'src/sage/rings/function_field/drinfeld_modules/__init__.py', + 'src/sage/rings/semirings/__init__.py', + 'src/sage/rings/number_field/__init__.py', + 'src/sage/rings/__init__.py', + 'src/sage/rings/padics/__init__.py', + 'src/sage/rings/valuation/__init__.py', + 'src/sage/rings/asymptotic/__init__.py', + 'src/sage/rings/polynomial/weil/__init__.py', + 'src/sage/rings/polynomial/__init__.py', + 'src/sage/rings/polynomial/padics/__init__.py', + 'src/sage/monoids/__init__.py', + 'src/sage/matrix/__init__.py', + 'src/sage/matroids/__init__.py', + 'src/sage/interacts/__init__.py', + 'src/sage/__init__.py', + 'src/sage/plot/__init__.py', + 'src/sage/plot/plot3d/__init__.py', + 'src/sage/typeset/__init__.py', + 'src/sage/algebras/lie_conformal_algebras/__init__.py', + 'src/sage/algebras/fusion_rings/__init__.py', + 'src/sage/algebras/letterplace/__init__.py', + 'src/sage/algebras/quatalg/__init__.py', + 'src/sage/algebras/steenrod/__init__.py', + 'src/sage/algebras/finite_dimensional_algebras/__init__.py', + 'src/sage/algebras/__init__.py', + 'src/sage/algebras/hecke_algebras/__init__.py', + 'src/sage/algebras/lie_algebras/__init__.py', + 'src/sage/algebras/quantum_groups/__init__.py', + 'src/sage/quadratic_forms/genera/__init__.py', + 'src/sage/quadratic_forms/__init__.py', + 'src/sage/game_theory/__init__.py', + 'src/sage/sandpiles/__init__.py', + 'src/sage/sat/__init__.py', + 'src/sage/homology/__init__.py', + 'src/sage/geometry/riemannian_manifolds/__init__.py', + 'src/sage/geometry/hyperplane_arrangement/__init__.py', + 'src/sage/geometry/triangulation/__init__.py', + 'src/sage/geometry/polyhedron/modules/__init__.py', + 'src/sage/geometry/polyhedron/__init__.py', + 'src/sage/geometry/polyhedron/combinatorial_polyhedron/__init__.py', + 'src/sage/geometry/__init__.py', + 'src/sage/geometry/hyperbolic_space/__init__.py', + 'src/sage/sets/__init__.py', + 'src/sage/probability/__init__.py', + 'src/sage/numerical/backends/__init__.py', + 'src/sage/numerical/__init__.py', + 'src/sage/data_structures/__init__.py', + 'src/sage/graphs/graph_decompositions/__init__.py', + 'src/sage/graphs/generators/__init__.py', + 'src/sage/graphs/__init__.py', + 'src/sage/graphs/base/__init__.py', + 'src/sage/databases/__init__.py', + 'src/sage/stats/hmm/__init__.py', + 'src/sage/stats/__init__.py', + 'src/sage/stats/distributions/__init__.py', + 'src/sage/libs/gap/__init__.py', + 'src/sage/libs/mpfi/__init__.py', + 'src/sage/libs/__init__.py', + 'src/sage/libs/polybori/__init__.py', + 'src/sage/libs/mpfr/__init__.py', + 'src/sage/libs/mpc/__init__.py', + 'src/sage/calculus/transforms/__init__.py', + 'src/sage/calculus/__init__.py', +] +for path in file_paths: + path = "''' + meson.current_source_dir() + '''/" + path + os.makedirs(os.path.dirname(path), exist_ok=True) + with open(path, 'w') as f: + f.write(content) + ''', +] +run_command(create_files_command, check: true) + +subdir('src') diff --git a/meson.format b/meson.format new file mode 100644 index 00000000000..f56718e583f --- /dev/null +++ b/meson.format @@ -0,0 +1 @@ +indent_by: ' ' diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in index 54a59fdbacf..e5386cf89cf 100644 --- a/pkgs/sage-conf/_sage_conf/_conf.py.in +++ b/pkgs/sage-conf/_sage_conf/_conf.py.in @@ -8,6 +8,7 @@ VERSION = "@PACKAGE_VERSION@" # to it. SAGE_LOCAL = "@prefix@" SAGE_ROOT = "@SAGE_ROOT@" +SAGE_SHARE = "@SAGE_SHARE@" # The semicolon-separated list of GAP root paths. This is the list of # locations that are searched for GAP packages. This is passed directly diff --git a/pkgs/sage-setup/pyproject.toml b/pkgs/sage-setup/pyproject.toml index 96b079cec62..a8cac2c6a64 100644 --- a/pkgs/sage-setup/pyproject.toml +++ b/pkgs/sage-setup/pyproject.toml @@ -39,7 +39,8 @@ packages = [ "sage_setup", "sage_setup.autogen", "sage_setup.autogen.interpreters", - "sage_setup.autogen.interpreters.specs", + "sage_setup.autogen.interpreters.internal", + "sage_setup.autogen.interpreters.internal.specs", "sage_setup.command", ] include-package-data = false diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..47c125c4e26 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,155 @@ +[build-system] +build-backend = 'mesonpy' +# Minimum requirements for the build system to execute. +requires = [ + 'meson-python', + 'cypari2 >=2.1.1', + 'cysignals >=1.11.4', + # Exclude 3.0.3 because of https://github.com/cython/cython/issues/5748 + 'cython >=3.0, != 3.0.3', + 'gmpy2 ~=2.1.b999', + 'memory_allocator', + 'numpy >=1.19', + 'jinja2' +] +[project] +name = "sagemath" +description = "Sage: Open Source Mathematics Software: Standard Python Library" +dependencies = [ + 'six >=1.15.0', + 'conway-polynomials >=0.8', + 'cypari2 >=2.1.1', + 'cysignals >=1.10.2', + 'cython >=3.0, != 3.0.3', + 'gmpy2 ~=2.1.b999', + 'lrcalc ~=2.1', + 'memory_allocator', + 'numpy >=1.19', + # Issue #30922: pplpy 0.8.4 and earlier do not declare dependencies correctly + 'pplpy >=0.8.6', + 'primecountpy', + 'requests >=2.13.0', + # According to https://github.com/python/typing_extensions/blob/main/CHANGELOG.md, + # version 4.4.0 adds another Python 3.11 typing backport + 'typing_extensions >= 4.4.0; python_version<"3.11"', + 'ipython >=7.13.0', + 'pexpect >=4.8.0', + 'sphinx >=5.2, <9', + 'networkx >=2.4', + # 1.8 is known good version. + # Per https://docs.scipy.org/doc/scipy/dev/core-dev/index.html#version-numbering + # and https://docs.scipy.org/doc/scipy/dev/core-dev/index.html#deprecations, + # deprecations cannot be introduced in micro releases. + # SciPy devs wait "at least 6 months", "in practice two (minor) releases" + # from deprecation to removal of a feature. + 'scipy >=1.5', + 'sympy >=1.6, <2.0', + # Issue #33642: Set lower bound for use of matplotlib color maps introduced in #33491, + # and to suppress deprecation warnings (https://github.com/matplotlib/matplotlib/pull/21073) + 'matplotlib >=3.5.1', + 'pillow >=7.2.0', + 'mpmath >=1.1.0', + 'ipykernel >=5.2.1', + 'jupyter-client', + 'ipywidgets >=7.5.1', + 'fpylll >=0.5.9', + 'ptyprocess > 0.5', +] +dynamic = ["version"] +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.13" + +[project.optional-dependencies] +R = [ + 'rpy2 >=3.3', +] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[tool.conda-lock] +platforms = [ + 'osx-64', 'linux-64', 'linux-aarch64', 'osx-arm64' +] + +[external] +# External dependencies in the format proposed by https://peps.python.org/pep-0725 +build-requires = [ + "virtual:compiler/c", + "virtual:compiler/cpp", + "pkg:generic/pkg-config" +] + +host-requires = [ + "virtual:interface/blas", + "pkg:generic/boost", + "pkg:generic/brial", + "pkg:generic/cddlib", + "pkg:generic/cliquer", + "pkg:generic/ecl", + "pkg:generic/eclib", + "pkg:generic/ecm", + "pkg:generic/fflas-ffpack", + "pkg:generic/fplll", + "pkg:generic/flint", + "pkg:generic/libgd", + "pkg:generic/gap", + "pkg:generic/gfan", + "pkg:generic/giac", + "pkg:generic/givaro", + "pkg:generic/glpk", + "pkg:generic/gmp", + "pkg:generic/gsl", + "pkg:generic/iml", + "pkg:generic/lcalc", + "pkg:generic/libbraiding", + "pkg:generic/libhomfly", + "pkg:generic/linbox", + "pkg:generic/lrcalc", + "pkg:generic/m4ri", + "pkg:generic/m4rie", + "pkg:generic/maxima", + "pkg:generic/mpc", + "pkg:generic/mpfi", + "pkg:generic/mpfr", + "pkg:generic/nauty", + "pkg:generic/ntl", + "pkg:generic/palp", + "pkg:generic/pari", + "pkg:generic/pari-elldata", + "pkg:generic/pari-galdata", + "pkg:generic/pari-seadata", + "pkg:generic/planarity", + "pkg:generic/ppl", + "pkg:generic/primesieve", + "pkg:generic/primecount", + "pkg:generic/qhull", + "pkg:generic/rw", + "pkg:generic/singular", + "pkg:generic/symmetrica", + "pkg:generic/sympow", +] + +dependencies = [ + "pkg:generic/tachyon", + "pkg:generic/sagemath-polytopes-db", + "pkg:generic/sagemath-elliptic-curves", +] diff --git a/src/doc/en/installation/index.rst b/src/doc/en/installation/index.rst index 918d8fe9359..5e60d65ebb0 100644 --- a/src/doc/en/installation/index.rst +++ b/src/doc/en/installation/index.rst @@ -217,6 +217,7 @@ More information: binary conda source + meson launching troubles diff --git a/src/doc/en/installation/meson.rst b/src/doc/en/installation/meson.rst new file mode 100644 index 00000000000..b8e44bc12fc --- /dev/null +++ b/src/doc/en/installation/meson.rst @@ -0,0 +1,122 @@ +.. _build-source-meson: + +================================ +Building from source using Meson +================================ + +This is a short guide on how to build the Sage from source using Meson. + +Walkthrough +=========== + +Assume we're starting from a clean repo and a fully set up conda environment: + +.. CODE-BLOCK:: shell-session + + $ ./bootstrap-conda + $ mamba env create --file src/environment-dev-3.11.yml --name sage-dev + $ conda activate sage-dev + +Alternatively, install all build requirements as described in section +:ref:`section-prereqs`. In the likely case that you have to install some +dependencies manually, set the correct environment variables to point +to the installed libraries: + +.. CODE-BLOCK:: shell-session + + $ export C_INCLUDE_PATH=$C_INCLUDE_PATH:/your/path/to/include + $ export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/your/path/to/include + $ export LIBRARY_PATH=$LIBRARY_PATH:/your/path/to/lib + +.. NOTE:: + + If you have previously build Sage in-place, you first have to delete the + already compiled files, e.g. with ``shopt -s globstar`` followed by + ``rm src/**/*.so`` or ``for f in src/**/*.so ; do mv "$f" "$f.old"; done``. + Moreover, remove the old generated files with + ``find src/sage/ext/interpreters -type f ! -name 'meson.build' -delete``. + Also uninstall the 'old' sage packages with ``pip uninstall sage-conf sage-setup sagemath-standard``. + +To compile and install the project in editable install, just use: + +.. CODE-BLOCK:: shell-session + + $ pip install --no-build-isolation --editable . + +This will install Sage in the current Python environment. +In a Conda environment, the ``--no-build-isolation`` flag is necessary to +allow the build system to reuse the already installed build dependencies. +If you don't use Conda, you can omit this flag. + +You can then start Sage from the command line with ``./sage`` +or run the tests with ``./sage -t``. + +.. NOTE:: + + By using ``pip install --editable`` in the above steps, the Sage library + is installed in editable mode. This means that when you only edit source + files, there is no need to rebuild the library; it suffices to restart Sage. + Note that this even works when you edit Cython files, so you no longer need + to manually compile after editing Cython files. + +.. NOTE:: + + Note that ``make`` is not used at all, nor is ``configure``. + This means that any Sage-the-distribution commands such as ``sage -i`` + will not work. + +Background information +====================== + +Under the hood, pip invokes meson to configure and build the project. +We can also use meson directly as follows. + +To configure the project, we need to run the following command: + +.. CODE-BLOCK:: shell-session + + $ meson setup builddir --prefix=$PWD/build-install + +This will create a build directory ``builddir`` that will hold the build artifacts. +The ``--prefix`` option specifies the directory where the Sage will be installed. +To compile the project, run the following command: + +.. CODE-BLOCK:: shell-session + + $ meson compile -C builddir + +Installing is done with the following command: + +.. CODE-BLOCK:: shell-session + + $ meson install -C builddir + +This will then install in the directory specified by ``--prefix``, e.g. +``build-install/lib/python3.11/site-packages/sage``. +Usually, this directory is not on your Python path, so you have to use: + +.. CODE-BLOCK:: shell-session + + $ PYTHONPATH=build-install/lib/python3.11/site-packages ./sage + +Alternatively, we can still use pip to install: + +.. CODE-BLOCK:: shell-session + + $ pip install --no-build-isolation --config-settings=builddir=builddir --editable . + +.. tip:: + + Package maintainers may want to specify further build options or need + to install to a different directory than the install prefix. + Both are supported naturally by Meson: + + .. CODE-BLOCK:: shell-session + + $ meson setup builddir --prefix=/usr --libdir=... -Dcpp_args=... + $ meson compile -C builddir + $ DESTDIR=/path/to/staging/root meson install -C builddir + + See `Meson's quick guide `_ + and `Meson's install guide `_ + for more information. diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst index f2e40ed3982..12b1483dfa2 100644 --- a/src/doc/en/installation/source.rst +++ b/src/doc/en/installation/source.rst @@ -370,6 +370,12 @@ does not raise an :class:`ImportError`, then it worked. Installation steps ------------------ +.. hint:: + + The following steps use the classical ``./configure && make`` build + process. The modern Meson build system is also supported, see + :ref:`build-source-meson`. + #. Follow the procedure in the file `README.md `_ in ``SAGE_ROOT``. diff --git a/src/environment-3.10-linux.yml b/src/environment-3.10-linux.yml index f2667c2307e..929b40139c5 100644 --- a/src/environment-3.10-linux.yml +++ b/src/environment-3.10-linux.yml @@ -272,6 +272,8 @@ dependencies: - matplotlib-inline=0.1.7=pyhd8ed1ab_0 - maxima=5.47.0=hed6455c_2 - memory-allocator=0.1.3=py310h2372a71_0 + - meson=1.5.2=pyhd8ed1ab_0 + - meson-python=0.15.0=pyh0c530f3_0 - metis=5.1.0=h59595ed_1007 - mistune=3.0.2=pyhd8ed1ab_0 - mpc=1.3.1=hfe3b2da_0 diff --git a/src/environment-3.10-macos.yml b/src/environment-3.10-macos.yml index 9110653e86c..87692b1e2ee 100644 --- a/src/environment-3.10-macos.yml +++ b/src/environment-3.10-macos.yml @@ -244,6 +244,8 @@ dependencies: - matplotlib-inline=0.1.7=pyhd8ed1ab_0 - maxima=5.47.0=h2bbcd85_2 - memory-allocator=0.1.3=py310h2aa6e3c_0 + - meson=1.5.2=pyhd8ed1ab_0 + - meson-python=0.15.0=pyh0c530f3_0 - metis=5.1.0=h13dd4ca_1007 - mistune=3.0.2=pyhd8ed1ab_0 - mpc=1.3.1=h91ba8db_0 diff --git a/src/environment-3.11-linux.yml b/src/environment-3.11-linux.yml index 6716e043193..7fee7689a28 100644 --- a/src/environment-3.11-linux.yml +++ b/src/environment-3.11-linux.yml @@ -272,6 +272,8 @@ dependencies: - matplotlib-inline=0.1.7=pyhd8ed1ab_0 - maxima=5.47.0=hed6455c_2 - memory-allocator=0.1.3=py311h459d7ec_0 + - meson=1.5.2=pyhd8ed1ab_0 + - meson-python=0.15.0=pyh0c530f3_0 - metis=5.1.0=h59595ed_1007 - mistune=3.0.2=pyhd8ed1ab_0 - mpc=1.3.1=hfe3b2da_0 diff --git a/src/environment-3.11-macos.yml b/src/environment-3.11-macos.yml index 192cc3a5f33..4111aa010f2 100644 --- a/src/environment-3.11-macos.yml +++ b/src/environment-3.11-macos.yml @@ -244,6 +244,8 @@ dependencies: - matplotlib-inline=0.1.7=pyhd8ed1ab_0 - maxima=5.47.0=h2bbcd85_2 - memory-allocator=0.1.3=py311heffc1b2_0 + - meson=1.5.2=pyhd8ed1ab_0 + - meson-python=0.15.0=pyh0c530f3_0 - metis=5.1.0=h13dd4ca_1007 - mistune=3.0.2=pyhd8ed1ab_0 - mpc=1.3.1=h91ba8db_0 diff --git a/src/environment-3.9-linux.yml b/src/environment-3.9-linux.yml index c1cae4f27db..83a922eb4f4 100644 --- a/src/environment-3.9-linux.yml +++ b/src/environment-3.9-linux.yml @@ -272,6 +272,8 @@ dependencies: - matplotlib-inline=0.1.7=pyhd8ed1ab_0 - maxima=5.47.0=hed6455c_2 - memory-allocator=0.1.3=py39hd1e30aa_0 + - meson=1.5.2=pyhd8ed1ab_0 + - meson-python=0.15.0=pyh0c530f3_0 - metis=5.1.0=h59595ed_1007 - mistune=3.0.2=pyhd8ed1ab_0 - mpc=1.3.1=hfe3b2da_0 diff --git a/src/environment-3.9-macos.yml b/src/environment-3.9-macos.yml index 5137c9298af..906b3b79f22 100644 --- a/src/environment-3.9-macos.yml +++ b/src/environment-3.9-macos.yml @@ -244,6 +244,8 @@ dependencies: - matplotlib-inline=0.1.7=pyhd8ed1ab_0 - maxima=5.47.0=h2bbcd85_2 - memory-allocator=0.1.3=py39h0f82c59_0 + - meson=1.5.2=pyhd8ed1ab_0 + - meson-python=0.15.0=pyh0c530f3_0 - metis=5.1.0=h13dd4ca_1007 - mistune=3.0.2=pyhd8ed1ab_0 - mpc=1.3.1=h91ba8db_0 diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000000..12d82fa91c3 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,154 @@ +# Compilers +cc = meson.get_compiler('c') +cpp = meson.get_compiler('cpp') +cython = meson.get_compiler('cython') + +# Setup dependencies that are needed by many modules +inc_numpy = run_command( + py, + [ + '-c', + ''' +import numpy +print(numpy.get_include()) + '''.strip(), + ], + check: true, +).stdout().strip() +numpy = declare_dependency(include_directories: inc_numpy) + +inc_cysignals = run_command( + py, + [ + '-c', + ''' +import cysignals +print(cysignals.__file__.replace('__init__.py', '')) + '''.strip(), + ], + check: true, +).stdout().strip() +cysignals = declare_dependency(include_directories: inc_cysignals) + +inc_gmpy2 = run_command( + py, + [ + '-c', + ''' +import gmpy2 +print(gmpy2.__file__.replace('__init__.py', '')) + '''.strip(), + ], + check: true, +).stdout().strip() +gmpy2 = declare_dependency(include_directories: inc_gmpy2) +gmp = dependency('gmp') + +inc_cypari2 = run_command( + py, + [ + '-c', + ''' +import cypari2 +print(cypari2.__file__.replace('__init__.py', '')) + '''.strip(), + ], + check: true, +).stdout().strip() +cypari2 = declare_dependency(include_directories: inc_cypari2) +pari = cc.find_library('pari') + +mpfr = cc.find_library('mpfr') + +flint = dependency('flint', version: '>=3.0.0') +if flint.version().version_compare('<3.1') + # In older versions of flint, pkg-config file is broken, so we manually use find_library + # This has been fixed in flint v3.1: https://github.com/flintlib/flint/pull/1647 + flint = cc.find_library('flint') +endif + +blas_order = [] +if host_machine.system() == 'darwin' + blas_order += 'accelerate' +endif +if host_machine.cpu_family() == 'x86_64' + blas_order += 'mkl' +endif +# pkg-config uses a lower-case name while CMake uses a capitalized name, so try +# that too to make the fallback detection with CMake work +blas_order += ['cblas', 'openblas', 'OpenBLAS', 'flexiblas', 'blis', 'blas'] +blas = dependency(blas_order) +gsl = dependency( + 'gsl', + fallback: ['gsl', 'gsl_dep'], + version: '>=2.5', + required: true, +) +gd = cc.find_library('gd') +m = cc.find_library('m') +m4ri = cc.find_library('m4ri') +m4rie = cc.find_library('m4rie') +mtx = cc.find_library('mtx', required: false, disabler: true) +png = cc.find_library('png') +zlib = cc.find_library('z') +# Cannot be found via pkg-config +ec = cc.find_library('ec') +ecm = cc.find_library('ecm') +ppl = cc.find_library('ppl') +gmpxx = cc.find_library('gmpxx') +fflas = dependency('fflas-ffpack') +fplll = dependency('fplll') +givaro = cc.find_library('givaro') +linbox = dependency('linbox', required: false) +if not linbox.found() + linbox = cc.find_library('linbox') +endif +mpc = cc.find_library('mpc') +mpfi = cc.find_library('mpfi') +# Cannot be found via pkg-config (pkg-config file will be added in 4.13) +# Test for common.h header that was added in 4.12 as a indirect version check +gap = cc.find_library('gap', has_headers: ['gap/common.h']) +singular = dependency('Singular') +maxima = find_program('maxima', required: true) +# Cannot be found via pkg-config +ntl = cc.find_library('ntl') +# Cannot be found via pkg-config +meataxe = cc.find_library('meataxe', required: false, disabler: true) + +# Meson currently ignores include_directories for Cython modules, so we +# have to add them manually. +# https://github.com/mesonbuild/meson/issues/9562 +add_project_arguments('-I', meson.current_source_dir(), language: 'cython') +add_project_arguments('-I', meson.current_build_dir(), language: 'cython') + +# Add global compiler flags +add_project_arguments('-X auto_pickle=False', language: 'cython') +add_project_arguments('-X autotestdict=False', language: 'cython') +add_project_arguments('-X binding=False', language: 'cython') +add_project_arguments('-X c_api_binop_methods=True', language: 'cython') +add_project_arguments('-X cdivision=True', language: 'cython') +add_project_arguments('-X cpow=True', language: 'cython') +add_project_arguments('-X embedsignature=True', language: 'cython') +add_project_arguments('--embed-positions', language: 'cython') +add_project_arguments('-X fast_getattr=True', language: 'cython') +#add_project_arguments('-X language_level="3"', language : 'cython') +add_project_arguments('-X legacy_implicit_noexcept=True', language: 'cython') +add_project_arguments( + '-X preliminary_late_includes_cy28=True', + language: 'cython', +) + +inc_cpython = include_directories('sage/cpython') +inc_rings = include_directories('sage/rings') +inc_rings_finite = include_directories('sage/rings/finite_rings') +inc_flint = include_directories('sage/libs/flint') +inc_gsl = include_directories('sage/libs/gsl') +inc_ntl = include_directories('sage/libs/ntl') +inc_arb = include_directories('sage/libs/arb') +inc_data_structures = include_directories('sage/data_structures') +inc_ext = include_directories('sage/ext') +inc_partn_ref2 = include_directories('sage/groups/perm_gps/partn_ref2') +inc_src = include_directories('.') + +# Submodules +subdir('sage') diff --git a/src/sage/algebras/finite_dimensional_algebras/meson.build b/src/sage/algebras/finite_dimensional_algebras/meson.build new file mode 100644 index 00000000000..075f0b8cebd --- /dev/null +++ b/src/sage/algebras/finite_dimensional_algebras/meson.build @@ -0,0 +1,26 @@ +py.install_sources( + 'all.py', + 'finite_dimensional_algebra.py', + 'finite_dimensional_algebra_element.pxd', + 'finite_dimensional_algebra_ideal.py', + 'finite_dimensional_algebra_morphism.py', + subdir: 'sage/algebras/finite_dimensional_algebras', +) + +extension_data = { + 'finite_dimensional_algebra_element' : files( + 'finite_dimensional_algebra_element.pyx', + ), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras/finite_dimensional_algebras', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/algebras/fusion_rings/meson.build b/src/sage/algebras/fusion_rings/meson.build new file mode 100644 index 00000000000..281460a066a --- /dev/null +++ b/src/sage/algebras/fusion_rings/meson.build @@ -0,0 +1,47 @@ +py.install_sources( + 'all.py', + 'f_matrix.py', + 'fast_parallel_fmats_methods.pxd', + 'fast_parallel_fusion_ring_braid_repn.pxd', + 'fusion_double.py', + 'fusion_ring.py', + 'poly_tup_engine.pxd', + 'shm_managers.pxd', + subdir: 'sage/algebras/fusion_rings', +) + +extension_data = { + 'fast_parallel_fusion_ring_braid_repn' : files( + 'fast_parallel_fusion_ring_braid_repn.pyx', + ), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras/fusion_rings', + install: true, + include_directories: [inc_cpython, inc_ntl, inc_numpy, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +extension_data_cpp = { + 'fast_parallel_fmats_methods': files('fast_parallel_fmats_methods.pyx'), + 'poly_tup_engine': files('poly_tup_engine.pyx'), + 'shm_managers': files('shm_managers.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras/fusion_rings', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ntl, inc_numpy, inc_rings], + dependencies: [py_dep, cysignals, gmp, singular], + ) +endforeach + diff --git a/src/sage/algebras/letterplace/meson.build b/src/sage/algebras/letterplace/meson.build new file mode 100644 index 00000000000..1ada90927a7 --- /dev/null +++ b/src/sage/algebras/letterplace/meson.build @@ -0,0 +1,27 @@ +py.install_sources( + 'all.py', + 'free_algebra_element_letterplace.pxd', + 'free_algebra_letterplace.pxd', + subdir: 'sage/algebras/letterplace', +) + +extension_data_cpp = { + 'free_algebra_element_letterplace': files( + 'free_algebra_element_letterplace.pyx', + ), + 'free_algebra_letterplace': files('free_algebra_letterplace.pyx'), + 'letterplace_ideal': files('letterplace_ideal.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras/letterplace', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp, singular], + ) +endforeach + diff --git a/src/sage/algebras/lie_algebras/meson.build b/src/sage/algebras/lie_algebras/meson.build new file mode 100644 index 00000000000..f50959cb44b --- /dev/null +++ b/src/sage/algebras/lie_algebras/meson.build @@ -0,0 +1,42 @@ +py.install_sources( + 'abelian.py', + 'affine_lie_algebra.py', + 'all.py', + 'bch.py', + 'bgg_dual_module.py', + 'bgg_resolution.py', + 'center_uea.py', + 'classical_lie_algebra.py', + 'examples.py', + 'free_lie_algebra.py', + 'heisenberg.py', + 'lie_algebra.py', + 'lie_algebra_element.pxd', + 'morphism.py', + 'nilpotent_lie_algebra.py', + 'onsager.py', + 'poincare_birkhoff_witt.py', + 'quotient.py', + 'rank_two_heisenberg_virasoro.py', + 'representation.py', + 'structure_coefficients.py', + 'subalgebra.py', + 'symplectic_derivation.py', + 'verma_module.py', + 'virasoro.py', + subdir: 'sage/algebras/lie_algebras', +) + +extension_data = {'lie_algebra_element' : files('lie_algebra_element.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras/lie_algebras', + install: true, + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/algebras/meson.build b/src/sage/algebras/meson.build new file mode 100644 index 00000000000..a7e74474c6b --- /dev/null +++ b/src/sage/algebras/meson.build @@ -0,0 +1,75 @@ +py.install_sources( + 'affine_nil_temperley_lieb.py', + 'algebra.py', + 'all.py', + 'askey_wilson.py', + 'associated_graded.py', + 'catalog.py', + 'cellular_basis.py', + 'clifford_algebra.py', + 'clifford_algebra_element.pxd', + 'cluster_algebra.py', + 'commutative_dga.py', + 'down_up_algebra.py', + 'exterior_algebra_groebner.pxd', + 'finite_gca.py', + 'free_algebra.py', + 'free_algebra_element.py', + 'free_algebra_quotient.py', + 'free_algebra_quotient_element.py', + 'free_zinbiel_algebra.py', + 'group_algebra.py', + 'hall_algebra.py', + 'iwahori_hecke_algebra.py', + 'jordan_algebra.py', + 'nil_coxeter_algebra.py', + 'octonion_algebra.pxd', + 'orlik_solomon.py', + 'orlik_terao.py', + 'q_commuting_polynomials.py', + 'q_system.py', + 'quantum_clifford.py', + 'quantum_matrix_coordinate_algebra.py', + 'quantum_oscillator.py', + 'quaternion_algebra.py', + 'quaternion_algebra_element.py', + 'rational_cherednik_algebra.py', + 'schur_algebra.py', + 'shuffle_algebra.py', + 'splitting_algebra.py', + 'tensor_algebra.py', + 'weyl_algebra.py', + 'yangian.py', + 'yokonuma_hecke_algebra.py', + subdir: 'sage/algebras', +) + +extension_data = { + 'clifford_algebra_element' : files('clifford_algebra_element.pyx'), + 'exterior_algebra_groebner' : files('exterior_algebra_groebner.pyx'), + 'octonion_algebra' : files('octonion_algebra.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +subdir('finite_dimensional_algebras') +subdir('fusion_rings') +install_subdir('hecke_algebras', install_dir: sage_install_dir / 'algebras') +subdir('letterplace') +subdir('lie_algebras') +install_subdir( + 'lie_conformal_algebras', + install_dir: sage_install_dir / 'algebras', +) +install_subdir('quantum_groups', install_dir: sage_install_dir / 'algebras') +subdir('quatalg') +install_subdir('steenrod', install_dir: sage_install_dir / 'algebras') diff --git a/src/sage/algebras/quatalg/meson.build b/src/sage/algebras/quatalg/meson.build new file mode 100644 index 00000000000..2ec5cd31f22 --- /dev/null +++ b/src/sage/algebras/quatalg/meson.build @@ -0,0 +1,24 @@ +py.install_sources( + 'all.py', + 'quaternion_algebra.py', + 'quaternion_algebra_element.pxd', + subdir: 'sage/algebras/quatalg', +) + +extension_data_cpp = { + 'quaternion_algebra_cython': files('quaternion_algebra_cython.pyx'), + 'quaternion_algebra_element': files('quaternion_algebra_element.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/algebras/quatalg', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ext, inc_flint, inc_ntl, inc_rings], + dependencies: [py_dep, flint, gmp, m, ntl], + ) +endforeach + diff --git a/src/sage/arith/meson.build b/src/sage/arith/meson.build new file mode 100644 index 00000000000..3c3656c5738 --- /dev/null +++ b/src/sage/arith/meson.build @@ -0,0 +1,34 @@ +py.install_sources( + 'all.py', + 'all__sagemath_objects.py', + 'constants.pxd', + 'functions.pxd', + 'long.pxd', + 'misc.py', + 'multi_modular.pxd', + 'numerical_approx.pxd', + 'power.pxd', + 'rational_reconstruction.pxd', + subdir: 'sage/arith', +) + +extension_data = { + 'functions' : files('functions.pyx'), + 'multi_modular' : files('multi_modular.pyx'), + 'numerical_approx' : files('numerical_approx.pyx'), + 'power' : files('power.pyx'), + 'rational_reconstruction' : files('rational_reconstruction.pyx'), + 'srange' : files('srange.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/arith', + install: true, + include_directories: [inc_cpython, inc_ext, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/calculus/meson.build b/src/sage/calculus/meson.build new file mode 100644 index 00000000000..541d7d86d75 --- /dev/null +++ b/src/sage/calculus/meson.build @@ -0,0 +1,37 @@ +py.install_sources( + 'all.py', + 'calculus.py', + 'desolvers.py', + 'expr.py', + 'functional.py', + 'functions.py', + 'interpolation.pxd', + 'ode.pxd', + 'predefined.py', + 'test_sympy.py', + 'tests.py', + 'wester.py', + subdir: 'sage/calculus', +) + +extension_data = { + 'integration' : files('integration.pyx'), + 'interpolation' : files('interpolation.pyx'), + 'interpolators' : files('interpolators.pyx'), + 'ode' : files('ode.pyx'), + 'riemann' : files('riemann.pyx'), + 'var' : files('var.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/calculus', + install: true, + include_directories: [inc_numpy], + dependencies: [py_dep, cysignals, gmp, gsl, interpreters_dep], + ) +endforeach + +subdir('transforms') diff --git a/src/sage/calculus/transforms/meson.build b/src/sage/calculus/transforms/meson.build new file mode 100644 index 00000000000..05d3fb59637 --- /dev/null +++ b/src/sage/calculus/transforms/meson.build @@ -0,0 +1,21 @@ +py.install_sources( + 'all.py', + 'dft.py', + 'dwt.pxd', + 'fft.pxd', + subdir: 'sage/calculus/transforms', +) + +extension_data = {'dwt' : files('dwt.pyx'), 'fft' : files('fft.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/calculus/transforms', + install: true, + include_directories: [inc_gsl], + dependencies: [py_dep, cysignals, gmp, gsl], + ) +endforeach + diff --git a/src/sage/categories/category_singleton.pyx b/src/sage/categories/category_singleton.pyx index c606428486c..0423ab9d83a 100644 --- a/src/sage/categories/category_singleton.pyx +++ b/src/sage/categories/category_singleton.pyx @@ -16,6 +16,8 @@ from sage.categories.category import Category from sage.structure.category_object cimport CategoryObject from sage.structure.dynamic_class import DynamicMetaclass +# I have no idea why this is necessary, but otherwise the type import fails (maybe because its shadowed by sage's cpython module?) +from cpython.method cimport PyMethod_Check from cpython.type cimport PyType_IsSubtype # This helper class is used to implement Category_singleton.__contains__ diff --git a/src/sage/categories/examples/meson.build b/src/sage/categories/examples/meson.build new file mode 100644 index 00000000000..ecb63c913ba --- /dev/null +++ b/src/sage/categories/examples/meson.build @@ -0,0 +1,49 @@ +py.install_sources( + 'algebras_with_basis.py', + 'all.py', + 'commutative_additive_monoids.py', + 'commutative_additive_semigroups.py', + 'coxeter_groups.py', + 'crystals.py', + 'cw_complexes.py', + 'facade_sets.py', + 'filtered_algebras_with_basis.py', + 'filtered_modules_with_basis.py', + 'finite_coxeter_groups.py', + 'finite_dimensional_algebras_with_basis.py', + 'finite_dimensional_lie_algebras_with_basis.py', + 'finite_enumerated_sets.py', + 'finite_monoids.py', + 'finite_semigroups.py', + 'finite_weyl_groups.py', + 'graded_connected_hopf_algebras_with_basis.py', + 'graded_modules_with_basis.py', + 'graphs.py', + 'hopf_algebras_with_basis.py', + 'infinite_enumerated_sets.py', + 'lie_algebras.py', + 'lie_algebras_with_basis.py', + 'magmas.py', + 'manifolds.py', + 'monoids.py', + 'posets.py', + 'semigroups.py', + 'sets_cat.py', + 'sets_with_grading.py', + 'with_realizations.py', + subdir: 'sage/categories/examples', +) + +extension_data = {'semigroups_cython' : files('semigroups_cython.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/categories/examples', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/categories/meson.build b/src/sage/categories/meson.build new file mode 100644 index 00000000000..132037fe7fd --- /dev/null +++ b/src/sage/categories/meson.build @@ -0,0 +1,224 @@ +py.install_sources( + 'action.pxd', + 'additive_groups.py', + 'additive_magmas.py', + 'additive_monoids.py', + 'additive_semigroups.py', + 'affine_weyl_groups.py', + 'algebra_functor.py', + 'algebra_ideals.py', + 'algebra_modules.py', + 'algebras.py', + 'algebras_with_basis.py', + 'all.py', + 'all__sagemath_objects.py', + 'aperiodic_semigroups.py', + 'associative_algebras.py', + 'basic.py', + 'bialgebras.py', + 'bialgebras_with_basis.py', + 'bimodules.py', + 'cartesian_product.py', + 'category.py', + 'category_cy_helper.pxd', + 'category_singleton.pxd', + 'category_types.py', + 'category_with_axiom.py', + 'chain_complexes.py', + 'classical_crystals.py', + 'coalgebras.py', + 'coalgebras_with_basis.py', + 'commutative_additive_groups.py', + 'commutative_additive_monoids.py', + 'commutative_additive_semigroups.py', + 'commutative_algebra_ideals.py', + 'commutative_algebras.py', + 'commutative_ring_ideals.py', + 'commutative_rings.py', + 'complete_discrete_valuation.py', + 'complex_reflection_groups.py', + 'complex_reflection_or_generalized_coxeter_groups.py', + 'covariant_functorial_construction.py', + 'coxeter_group_algebras.py', + 'coxeter_groups.py', + 'crystals.py', + 'cw_complexes.py', + 'dedekind_domains.py', + 'discrete_valuation.py', + 'distributive_magmas_and_additive_magmas.py', + 'division_rings.py', + 'domains.py', + 'drinfeld_modules.py', + 'dual.py', + 'enumerated_sets.py', + 'euclidean_domains.py', + 'facade_sets.py', + 'fields.py', + 'filtered_algebras.py', + 'filtered_algebras_with_basis.py', + 'filtered_hopf_algebras_with_basis.py', + 'filtered_modules.py', + 'filtered_modules_with_basis.py', + 'finite_complex_reflection_groups.py', + 'finite_coxeter_groups.py', + 'finite_crystals.py', + 'finite_dimensional_algebras_with_basis.py', + 'finite_dimensional_bialgebras_with_basis.py', + 'finite_dimensional_coalgebras_with_basis.py', + 'finite_dimensional_graded_lie_algebras_with_basis.py', + 'finite_dimensional_hopf_algebras_with_basis.py', + 'finite_dimensional_lie_algebras_with_basis.py', + 'finite_dimensional_modules_with_basis.py', + 'finite_dimensional_nilpotent_lie_algebras_with_basis.py', + 'finite_dimensional_semisimple_algebras_with_basis.py', + 'finite_enumerated_sets.py', + 'finite_fields.py', + 'finite_groups.py', + 'finite_lattice_posets.py', + 'finite_monoids.py', + 'finite_permutation_groups.py', + 'finite_posets.py', + 'finite_semigroups.py', + 'finite_sets.py', + 'finite_weyl_groups.py', + 'finitely_generated_lambda_bracket_algebras.py', + 'finitely_generated_lie_conformal_algebras.py', + 'finitely_generated_magmas.py', + 'finitely_generated_semigroups.py', + 'function_fields.py', + 'functor.pxd', + 'g_sets.py', + 'gcd_domains.py', + 'generalized_coxeter_groups.py', + 'graded_algebras.py', + 'graded_algebras_with_basis.py', + 'graded_bialgebras.py', + 'graded_bialgebras_with_basis.py', + 'graded_coalgebras.py', + 'graded_coalgebras_with_basis.py', + 'graded_hopf_algebras.py', + 'graded_hopf_algebras_with_basis.py', + 'graded_lie_algebras.py', + 'graded_lie_algebras_with_basis.py', + 'graded_lie_conformal_algebras.py', + 'graded_modules.py', + 'graded_modules_with_basis.py', + 'graphs.py', + 'group_algebras.py', + 'groupoid.py', + 'groups.py', + 'h_trivial_semigroups.py', + 'hecke_modules.py', + 'highest_weight_crystals.py', + 'homset.py', + 'homsets.py', + 'hopf_algebras.py', + 'hopf_algebras_with_basis.py', + 'infinite_enumerated_sets.py', + 'integral_domains.py', + 'isomorphic_objects.py', + 'j_trivial_semigroups.py', + 'kac_moody_algebras.py', + 'l_trivial_semigroups.py', + 'lambda_bracket_algebras.py', + 'lambda_bracket_algebras_with_basis.py', + 'lattice_posets.py', + 'left_modules.py', + 'lie_algebras.py', + 'lie_algebras_with_basis.py', + 'lie_conformal_algebras.py', + 'lie_conformal_algebras_with_basis.py', + 'lie_groups.py', + 'loop_crystals.py', + 'magmas.py', + 'magmas_and_additive_magmas.py', + 'magmatic_algebras.py', + 'manifolds.py', + 'map.pxd', + 'matrix_algebras.py', + 'metric_spaces.py', + 'modular_abelian_varieties.py', + 'modules.py', + 'modules_with_basis.py', + 'monoid_algebras.py', + 'monoids.py', + 'morphism.pxd', + 'noetherian_rings.py', + 'number_fields.py', + 'objects.py', + 'partially_ordered_monoids.py', + 'permutation_groups.py', + 'pointed_sets.py', + 'polyhedra.py', + 'poor_man_map.py', + 'posets.py', + 'primer.py', + 'principal_ideal_domains.py', + 'pushout.py', + 'quantum_group_representations.py', + 'quotient_fields.py', + 'quotients.py', + 'r_trivial_semigroups.py', + 'realizations.py', + 'regular_crystals.py', + 'regular_supercrystals.py', + 'right_modules.py', + 'ring_ideals.py', + 'rings.py', + 'rngs.py', + 'schemes.py', + 'semigroups.py', + 'semirings.py', + 'semisimple_algebras.py', + 'sets_cat.py', + 'sets_with_grading.py', + 'sets_with_partial_maps.py', + 'shephard_groups.py', + 'signed_tensor.py', + 'simplicial_complexes.py', + 'simplicial_sets.py', + 'subobjects.py', + 'subquotients.py', + 'super_algebras.py', + 'super_algebras_with_basis.py', + 'super_hopf_algebras_with_basis.py', + 'super_lie_conformal_algebras.py', + 'super_modules.py', + 'super_modules_with_basis.py', + 'supercommutative_algebras.py', + 'supercrystals.py', + 'tensor.py', + 'topological_spaces.py', + 'triangular_kac_moody_algebras.py', + 'tutorial.py', + 'unique_factorization_domains.py', + 'unital_algebras.py', + 'vector_bundles.py', + 'vector_spaces.py', + 'weyl_groups.py', + 'with_realizations.py', + subdir: 'sage/categories', +) + +extension_data = { + 'action' : files('action.pyx'), + 'category_cy_helper' : files('category_cy_helper.pyx'), + 'category_singleton' : files('category_singleton.pyx'), + 'coercion_methods' : files('coercion_methods.pyx'), + 'functor' : files('functor.pyx'), + 'map' : files('map.pyx'), + 'morphism' : files('morphism.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/categories', + install: true, + include_directories: [inc_cpython, inc_ext], + dependencies: [py_dep, gmp], + ) +endforeach + +subdir('examples') diff --git a/src/sage/coding/codecan/meson.build b/src/sage/coding/codecan/meson.build new file mode 100644 index 00000000000..ac3a94a1edd --- /dev/null +++ b/src/sage/coding/codecan/meson.build @@ -0,0 +1,23 @@ +py.install_sources('all.py', 'codecan.pxd', subdir: 'sage/coding/codecan') + +extension_data = { + 'autgroup_can_label' : files('autgroup_can_label.pyx'), + 'codecan' : files('codecan.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/coding/codecan', + install: true, + include_directories: [ + inc_cpython, + inc_data_structures, + inc_partn_ref2, + inc_rings, + ], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/coding/meson.build b/src/sage/coding/meson.build new file mode 100644 index 00000000000..65b2e0d8eb1 --- /dev/null +++ b/src/sage/coding/meson.build @@ -0,0 +1,59 @@ +py.install_sources( + 'abstract_code.py', + 'ag_code.py', + 'all.py', + 'bch_code.py', + 'binary_code.pxd', + 'bounds_catalog.py', + 'channel.py', + 'channels_catalog.py', + 'code_bounds.py', + 'code_constructions.py', + 'codes_catalog.py', + 'cyclic_code.py', + 'databases.py', + 'decoder.py', + 'decoders_catalog.py', + 'delsarte_bounds.py', + 'encoder.py', + 'encoders_catalog.py', + 'extended_code.py', + 'gabidulin_code.py', + 'golay_code.py', + 'goppa_code.py', + 'grs_code.py', + 'guava.py', + 'hamming_code.py', + 'information_set_decoder.py', + 'linear_code.py', + 'linear_code_no_metric.py', + 'linear_rank_metric.py', + 'parity_check_code.py', + 'punctured_code.py', + 'reed_muller_code.py', + 'self_dual_codes.py', + 'subfield_subcode.py', + 'two_weight_db.py', + subdir: 'sage/coding', +) + +extension_data = { + 'ag_code_decoders' : files('ag_code_decoders.pyx'), + 'binary_code' : files('binary_code.pyx'), + 'kasami_codes' : files('kasami_codes.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/coding', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +subdir('codecan') +install_subdir('guruswami_sudan', install_dir: sage_install_dir / 'coding') +install_subdir('source_coding', install_dir: sage_install_dir / 'coding') diff --git a/src/sage/combinat/crystals/meson.build b/src/sage/combinat/crystals/meson.build new file mode 100644 index 00000000000..96ff9f4e19e --- /dev/null +++ b/src/sage/combinat/crystals/meson.build @@ -0,0 +1,58 @@ +py.install_sources( + 'affine.py', + 'affine_factorization.py', + 'affinization.py', + 'alcove_path.py', + 'all.py', + 'bkk_crystals.py', + 'catalog.py', + 'catalog_elementary_crystals.py', + 'catalog_infinity_crystals.py', + 'catalog_kirillov_reshetikhin.py', + 'crystals.py', + 'direct_sum.py', + 'elementary_crystals.py', + 'fast_crystals.py', + 'fully_commutative_stable_grothendieck.py', + 'generalized_young_walls.py', + 'highest_weight_crystals.py', + 'induced_structure.py', + 'infinity_crystals.py', + 'kac_modules.py', + 'kirillov_reshetikhin.py', + 'kyoto_path_model.py', + 'letters.pxd', + 'littelmann_path.py', + 'monomial_crystals.py', + 'multisegments.py', + 'mv_polytopes.py', + 'pbw_crystal.py', + 'pbw_datum.pxd', + 'polyhedral_realization.py', + 'spins.pxd', + 'star_crystal.py', + 'subcrystal.py', + 'tensor_product.py', + 'tensor_product_element.pxd', + 'virtual_crystal.py', + subdir: 'sage/combinat/crystals', +) + +extension_data = { + 'letters' : files('letters.pyx'), + 'pbw_datum' : files('pbw_datum.pyx'), + 'spins' : files('spins.pyx'), + 'tensor_product_element' : files('tensor_product_element.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/crystals', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/combinat/designs/meson.build b/src/sage/combinat/designs/meson.build new file mode 100644 index 00000000000..fd3a8896bb3 --- /dev/null +++ b/src/sage/combinat/designs/meson.build @@ -0,0 +1,45 @@ +py.install_sources( + 'MOLS_handbook_data.py', + 'all.py', + 'bibd.py', + 'block_design.py', + 'covering_array.py', + 'covering_design.py', + 'database.py', + 'design_catalog.py', + 'designs_pyx.pxd', + 'difference_family.py', + 'difference_matrices.py', + 'ext_rep.py', + 'group_divisible_designs.py', + 'incidence_structures.py', + 'latin_squares.py', + 'orthogonal_arrays.py', + 'orthogonal_arrays_build_recursive.py', + 'resolvable_bibd.py', + 'steiner_quadruple_systems.py', + 'twographs.py', + subdir: 'sage/combinat/designs', +) + +extension_data = { + 'designs_pyx' : files('designs_pyx.pyx'), + 'evenly_distributed_sets' : files('evenly_distributed_sets.pyx'), + 'gen_quadrangles_with_spread' : files('gen_quadrangles_with_spread.pyx'), + 'orthogonal_arrays_find_recursive' : files( + 'orthogonal_arrays_find_recursive.pyx', + ), + 'subhypergraph_search' : files('subhypergraph_search.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/designs', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/combinat/integer_lists/meson.build b/src/sage/combinat/integer_lists/meson.build new file mode 100644 index 00000000000..ac9aab23386 --- /dev/null +++ b/src/sage/combinat/integer_lists/meson.build @@ -0,0 +1,22 @@ +py.install_sources( + '__init__.py', + 'base.pxd', + 'invlex.pxd', + 'lists.py', + 'nn.py', + subdir: 'sage/combinat/integer_lists', +) + +extension_data = {'base' : files('base.pyx'), 'invlex' : files('invlex.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/integer_lists', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/combinat/matrices/meson.build b/src/sage/combinat/matrices/meson.build new file mode 100644 index 00000000000..86021f8d376 --- /dev/null +++ b/src/sage/combinat/matrices/meson.build @@ -0,0 +1,22 @@ +py.install_sources( + 'all.py', + 'dlxcpp.py', + 'hadamard_matrix.py', + 'latin.py', + subdir: 'sage/combinat/matrices', +) + +extension_data_cpp = {'dancing_links': files('dancing_links.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/matrices', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/combinat/meson.build b/src/sage/combinat/meson.build new file mode 100644 index 00000000000..c0e9fe15d8b --- /dev/null +++ b/src/sage/combinat/meson.build @@ -0,0 +1,175 @@ +py.install_sources( + 'SJT.py', + 'abstract_tree.py', + 'affine_permutation.py', + 'algebraic_combinatorics.py', + 'all.py', + 'alternating_sign_matrix.py', + 'backtrack.py', + 'baxter_permutations.py', + 'bijectionist.py', + 'binary_recurrence_sequences.py', + 'binary_tree.py', + 'blob_algebra.py', + 'cartesian_product.py', + 'catalog_partitions.py', + 'cluster_complex.py', + 'colored_permutations.py', + 'combinat.py', + 'combinat_cython.pxd', + 'combination.py', + 'combinatorial_map.py', + 'composition.py', + 'composition_signed.py', + 'composition_tableau.py', + 'constellation.py', + 'core.py', + 'counting.py', + 'cyclic_sieving_phenomenon.py', + 'decorated_permutation.py', + 'derangements.py', + 'descent_algebra.py', + 'diagram.py', + 'diagram_algebras.py', + 'dlx.py', + 'dyck_word.py', + 'e_one_star.py', + 'enumerated_sets.py', + 'enumeration_mod_permgroup.pxd', + 'family.py', + 'finite_state_machine.py', + 'finite_state_machine_generators.py', + 'fqsym.py', + 'free_dendriform_algebra.py', + 'free_module.py', + 'free_prelie_algebra.py', + 'fully_commutative_elements.py', + 'fully_packed_loop.py', + 'gelfand_tsetlin_patterns.py', + 'graph_path.py', + 'gray_codes.py', + 'grossman_larson_algebras.py', + 'growth.py', + 'hall_polynomial.py', + 'hillman_grassl.py', + 'integer_matrices.py', + 'integer_vector.py', + 'integer_vector_weighted.py', + 'integer_vectors_mod_permgroup.py', + 'interval_posets.py', + 'k_tableau.py', + 'kazhdan_lusztig.py', + 'key_polynomial.py', + 'knutson_tao_puzzles.py', + 'lr_tableau.py', + 'misc.py', + 'multiset_partition_into_sets_ordered.py', + 'necklace.py', + 'non_decreasing_parking_function.py', + 'nu_dyck_word.py', + 'nu_tamari_lattice.py', + 'ordered_tree.py', + 'output.py', + 'parallelogram_polyomino.py', + 'parking_functions.py', + 'partition.py', + 'partition_algebra.py', + 'partition_kleshchev.py', + 'partition_shifting_algebras.py', + 'partition_tuple.py', + 'perfect_matching.py', + 'permutation.py', + 'permutation_cython.pxd', + 'plane_partition.py', + 'q_analogues.py', + 'quickref.py', + 'ranker.py', + 'recognizable_series.py', + 'regular_sequence.py', + 'restricted_growth.py', + 'ribbon.py', + 'ribbon_shaped_tableau.py', + 'ribbon_tableau.py', + 'rooted_tree.py', + 'rsk.py', + 'schubert_polynomial.py', + 'set_partition.py', + 'set_partition_ordered.py', + 'shard_order.py', + 'shifted_primed_tableau.py', + 'shuffle.py', + 'sidon_sets.py', + 'similarity_class_type.py', + 'sine_gordon.py', + 'six_vertex_model.py', + 'skew_partition.py', + 'skew_tableau.py', + 'sloane_functions.py', + 'specht_module.py', + 'subset.py', + 'subsets_hereditary.py', + 'subsets_pairwise.py', + 'subword.py', + 'subword_complex.py', + 'super_tableau.py', + 'superpartition.py', + 'symmetric_group_algebra.py', + 'symmetric_group_representations.py', + 't_sequences.py', + 'tableau.py', + 'tableau_residues.py', + 'tableau_tuple.py', + 'tamari_lattices.py', + 'tiling.py', + 'tools.py', + 'triangles_FHM.py', + 'tuple.py', + 'tutorial.py', + 'vector_partition.py', + 'yang_baxter_graph.py', + subdir: 'sage/combinat', +) + +extension_data = { + 'combinat_cython' : files('combinat_cython.pyx'), + 'debruijn_sequence' : files('debruijn_sequence.pyx'), + 'degree_sequences' : files('degree_sequences.pyx'), + 'enumeration_mod_permgroup' : files('enumeration_mod_permgroup.pyx'), + 'expnums' : files('expnums.pyx'), + 'fast_vector_partitions' : files('fast_vector_partitions.pyx'), + 'partitions' : files('partitions.pyx'), + 'permutation_cython' : files('permutation_cython.pyx'), + 'q_bernoulli' : files('q_bernoulli.pyx'), + 'set_partition_iterator' : files('set_partition_iterator.pyx'), + 'subword_complex_c' : files('subword_complex_c.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +install_subdir('chas', install_dir: sage_install_dir / 'combinat') +install_subdir( + 'cluster_algebra_quiver', + install_dir: sage_install_dir / 'combinat', +) +subdir('crystals') +subdir('designs') +subdir('integer_lists') +subdir('matrices') +install_subdir('ncsf_qsym', install_dir: sage_install_dir / 'combinat') +install_subdir('ncsym', install_dir: sage_install_dir / 'combinat') +install_subdir('path_tableaux', install_dir: sage_install_dir / 'combinat') +subdir('posets') +subdir('rigged_configurations') +subdir('root_system') +install_subdir('sf', install_dir: sage_install_dir / 'combinat') +install_subdir('species', install_dir: sage_install_dir / 'combinat') +subdir('words') diff --git a/src/sage/combinat/posets/meson.build b/src/sage/combinat/posets/meson.build new file mode 100644 index 00000000000..07837832519 --- /dev/null +++ b/src/sage/combinat/posets/meson.build @@ -0,0 +1,34 @@ +py.install_sources( + 'all.py', + 'cartesian_product.py', + 'd_complete.py', + 'elements.py', + 'forest.py', + 'hasse_diagram.py', + 'incidence_algebras.py', + 'lattices.py', + 'linear_extensions.py', + 'mobile.py', + 'moebius_algebra.py', + 'poset_examples.py', + 'posets.py', + subdir: 'sage/combinat/posets', +) + +extension_data = { + 'hasse_cython' : files('hasse_cython.pyx'), + 'hasse_cython_flint' : files('hasse_cython_flint.pyx'), + 'linear_extension_iterator' : files('linear_extension_iterator.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/posets', + install: true, + include_directories: [inc_cpython, inc_ext, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + diff --git a/src/sage/combinat/rigged_configurations/meson.build b/src/sage/combinat/rigged_configurations/meson.build new file mode 100644 index 00000000000..6b12159dfda --- /dev/null +++ b/src/sage/combinat/rigged_configurations/meson.build @@ -0,0 +1,40 @@ +py.install_sources( + 'all.py', + 'bij_abstract_class.py', + 'bij_infinity.py', + 'bij_type_A.py', + 'bij_type_A2_dual.py', + 'bij_type_A2_even.py', + 'bij_type_A2_odd.py', + 'bij_type_B.py', + 'bij_type_C.py', + 'bij_type_D.py', + 'bij_type_D_tri.py', + 'bij_type_D_twisted.py', + 'bij_type_E67.py', + 'bijection.py', + 'kleber_tree.py', + 'kr_tableaux.py', + 'rc_crystal.py', + 'rc_infinity.py', + 'rigged_configuration_element.py', + 'rigged_configurations.py', + 'rigged_partition.pxd', + 'tensor_product_kr_tableaux.py', + 'tensor_product_kr_tableaux_element.py', + subdir: 'sage/combinat/rigged_configurations', +) + +extension_data = {'rigged_partition' : files('rigged_partition.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/rigged_configurations', + install: true, + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/combinat/root_system/meson.build b/src/sage/combinat/root_system/meson.build new file mode 100644 index 00000000000..a8827403c7e --- /dev/null +++ b/src/sage/combinat/root_system/meson.build @@ -0,0 +1,76 @@ +py.install_sources( + 'all.py', + 'ambient_space.py', + 'associahedron.py', + 'braid_move_calculator.py', + 'branching_rules.py', + 'cartan_matrix.py', + 'cartan_type.py', + 'coxeter_group.py', + 'coxeter_matrix.py', + 'coxeter_type.py', + 'dynkin_diagram.py', + 'extended_affine_weyl_group.py', + 'fundamental_group.py', + 'hecke_algebra_representation.py', + 'integrable_representations.py', + 'non_symmetric_macdonald_polynomials.py', + 'pieri_factors.py', + 'plot.py', + 'reflection_group_complex.py', + 'reflection_group_element.pxd', + 'reflection_group_real.py', + 'root_lattice_realization_algebras.py', + 'root_lattice_realizations.py', + 'root_space.py', + 'root_system.py', + 'type_A.py', + 'type_A_affine.py', + 'type_A_infinity.py', + 'type_B.py', + 'type_BC_affine.py', + 'type_B_affine.py', + 'type_C.py', + 'type_C_affine.py', + 'type_D.py', + 'type_D_affine.py', + 'type_E.py', + 'type_E_affine.py', + 'type_F.py', + 'type_F_affine.py', + 'type_G.py', + 'type_G_affine.py', + 'type_H.py', + 'type_I.py', + 'type_Q.py', + 'type_affine.py', + 'type_dual.py', + 'type_folded.py', + 'type_marked.py', + 'type_reducible.py', + 'type_relabel.py', + 'type_super_A.py', + 'weight_lattice_realizations.py', + 'weight_space.py', + 'weyl_characters.py', + 'weyl_group.py', + subdir: 'sage/combinat/root_system', +) + +extension_data = { + 'braid_orbit' : files('braid_orbit.pyx'), + 'reflection_group_c' : files('reflection_group_c.pyx'), + 'reflection_group_element' : files('reflection_group_element.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/root_system', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/combinat/words/meson.build b/src/sage/combinat/words/meson.build new file mode 100644 index 00000000000..bb12f65d28f --- /dev/null +++ b/src/sage/combinat/words/meson.build @@ -0,0 +1,37 @@ +py.install_sources( + 'abstract_word.py', + 'all.py', + 'alphabet.py', + 'finite_word.py', + 'infinite_word.py', + 'lyndon_word.py', + 'morphic.py', + 'morphism.py', + 'paths.py', + 'shuffle_product.py', + 'suffix_trees.py', + 'word.py', + 'word_datatypes.pxd', + 'word_generators.py', + 'word_infinite_datatypes.py', + 'word_options.py', + 'words.py', + subdir: 'sage/combinat/words', +) + +extension_data = { + 'word_char' : files('word_char.pyx'), + 'word_datatypes' : files('word_datatypes.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/combinat/words', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/cpython/meson.build b/src/sage/cpython/meson.build new file mode 100644 index 00000000000..fdd99770782 --- /dev/null +++ b/src/sage/cpython/meson.build @@ -0,0 +1,44 @@ +py.install_sources( + '__init__.py', + '_py2_random.py', + 'all.py', + 'cython_metaclass.h', + 'cython_metaclass.pxd', + 'dict_del_by_value.pxd', + 'dict_internal.h', + 'getattr.pxd', + 'pycore_long.h', + 'pycore_long.pxd', + 'python_debug.h', + 'python_debug.pxd', + 'pyx_visit.h', + 'string.pxd', + 'string_impl.h', + 'type.pxd', + 'wrapperdescr.pxd', + subdir: 'sage/cpython', +) + +extension_data = { + 'atexit' : files('atexit.pyx'), + 'builtin_types' : files('builtin_types.pyx'), + 'cython_metaclass' : files('cython_metaclass.pyx'), + 'debug' : files('debug.pyx'), + 'dict_del_by_value' : files('dict_del_by_value.pyx'), + 'getattr' : files('getattr.pyx'), + 'string' : files('string.pyx'), + 'type' : files('type.pyx'), + 'wrapperdescr' : files('wrapperdescr.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/cpython', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/crypto/meson.build b/src/sage/crypto/meson.build new file mode 100644 index 00000000000..633c048a59c --- /dev/null +++ b/src/sage/crypto/meson.build @@ -0,0 +1,38 @@ +py.install_sources( + '__init__.py', + 'all.py', + 'boolean_function.pxd', + 'cipher.py', + 'classical.py', + 'classical_cipher.py', + 'cryptosystem.py', + 'lattice.py', + 'lfsr.py', + 'lwe.py', + 'sboxes.py', + 'stream.py', + 'stream_cipher.py', + 'util.py', + subdir: 'sage/crypto', +) + +extension_data = { + 'boolean_function' : files('boolean_function.pyx'), + 'sbox' : files('sbox.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/crypto', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +install_subdir('block_cipher', install_dir: sage_install_dir / 'crypto') +install_subdir('key_exchange', install_dir: sage_install_dir / 'crypto') +install_subdir('mq', install_dir: sage_install_dir / 'crypto') +install_subdir('public_key', install_dir: sage_install_dir / 'crypto') diff --git a/src/sage/data_structures/meson.build b/src/sage/data_structures/meson.build new file mode 100644 index 00000000000..8a94548917b --- /dev/null +++ b/src/sage/data_structures/meson.build @@ -0,0 +1,41 @@ +py.install_sources( + 'all.py', + 'binary_matrix.pxd', + 'binary_search.pxd', + 'bitset.pxd', + 'bitset_base.pxd', + 'bitset_intrinsics.h', + 'blas_dict.pxd', + 'bounded_integer_sequences.pxd', + 'list_of_pairs.pxd', + 'mutable_poset.py', + 'sparse_bitset.pxd', + 'stream.py', + subdir: 'sage/data_structures', +) + +extension_data = { + 'binary_search' : files('binary_search.pyx'), + 'bitset' : files('bitset.pyx'), + 'bitset_base' : files('bitset_base.pyx'), + 'blas_dict' : files('blas_dict.pyx'), + 'bounded_integer_sequences' : files('bounded_integer_sequences.pyx'), + 'list_of_pairs' : files('list_of_pairs.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/data_structures', + install: true, + include_directories: [ + inc_cpython, + inc_data_structures, + inc_flint, + inc_rings, + ], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py index e6fcc29a61b..4ed45e0d3e6 100644 --- a/src/sage/doctest/control.py +++ b/src/sage/doctest/control.py @@ -284,8 +284,11 @@ def skipfile(filename, tested_optional_tags=False, *, """ if filename.endswith('.rst.txt'): ext = '.rst.txt' - else: - base, ext = os.path.splitext(filename) + if filename.endswith('__main__.py'): + if log: + log(f"Skipping '{filename}' because it is a __main__.py file") + return True + _ , ext = os.path.splitext(filename) # .rst.txt appear in the installed documentation in subdirectories named "_sources" if ext not in ('.py', '.pyx', '.pxd', '.pxi', '.sage', '.spyx', '.rst', '.tex', '.rst.txt'): if log: @@ -985,7 +988,7 @@ def expand_files_into_sources(self): sage: DC = DocTestController(DD, [dirname]) sage: DC.expand_files_into_sources() sage: len(DC.sources) - 16 + 15 sage: DC.sources[0].options.optional True @@ -1097,7 +1100,6 @@ def sort_sources(self): sage.doctest.control sage.doctest.check_tolerance sage.doctest.all - sage.doctest.__main__ sage.doctest """ if self.options.nthreads > 1 and len(self.sources) > self.options.nthreads: diff --git a/src/sage/dynamics/arithmetic_dynamics/meson.build b/src/sage/dynamics/arithmetic_dynamics/meson.build new file mode 100644 index 00000000000..9e26a72c874 --- /dev/null +++ b/src/sage/dynamics/arithmetic_dynamics/meson.build @@ -0,0 +1,27 @@ +py.install_sources( + 'affine_ds.py', + 'all.py', + 'berkovich_ds.py', + 'dynamical_semigroup.py', + 'endPN_automorphism_group.py', + 'endPN_minimal_model.py', + 'generic_ds.py', + 'product_projective_ds.py', + 'projective_ds.py', + 'wehlerK3.py', + subdir: 'sage/dynamics/arithmetic_dynamics', +) + +extension_data = {'projective_ds_helper' : files('projective_ds_helper.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/dynamics/arithmetic_dynamics', + install: true, + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/dynamics/complex_dynamics/meson.build b/src/sage/dynamics/complex_dynamics/meson.build new file mode 100644 index 00000000000..d3961275d3e --- /dev/null +++ b/src/sage/dynamics/complex_dynamics/meson.build @@ -0,0 +1,19 @@ +py.install_sources( + 'all.py', + 'mandel_julia.py', + subdir: 'sage/dynamics/complex_dynamics', +) + +extension_data = {'mandel_julia_helper' : files('mandel_julia_helper.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/dynamics/complex_dynamics', + install: true, + include_directories: [], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/dynamics/meson.build b/src/sage/dynamics/meson.build new file mode 100644 index 00000000000..134cfd1a296 --- /dev/null +++ b/src/sage/dynamics/meson.build @@ -0,0 +1,11 @@ +py.install_sources( + 'all.py', + 'finite_dynamical_system.py', + 'finite_dynamical_system_catalog.py', + 'surface_dynamics_deprecation.py', + subdir: 'sage/dynamics', +) + +subdir('arithmetic_dynamics') +install_subdir('cellular_automata', install_dir: sage_install_dir / 'dynamics') +subdir('complex_dynamics') diff --git a/src/sage/env.py b/src/sage/env.py index 0f287145814..da0db8e2be7 100644 --- a/src/sage/env.py +++ b/src/sage/env.py @@ -144,7 +144,12 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st import sage_conf value = getattr(sage_conf, key, None) except ImportError: - pass + try: + import sage.config + value = getattr(sage.config, key, None) + except ImportError: + pass + # Try all fallbacks in order as long as we don't have a value for f in fallbacks: if value is not None: diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx index c7b4664ff1a..89c34b1f0fc 100644 --- a/src/sage/ext/fast_callable.pyx +++ b/src/sage/ext/fast_callable.pyx @@ -512,10 +512,10 @@ def _builder_and_stream(vars, domain): sage: from sage.ext.fast_callable import _builder_and_stream sage: _builder_and_stream(["x", "y"], ZZ) - (, + (, ) sage: _builder_and_stream(["x", "y"], RR) # needs sage.rings.real_mpfr - (, + (, ) Modularized test with sagemath-categories after :issue:`35095`, which has @@ -526,7 +526,7 @@ def _builder_and_stream(vars, domain): sage: domain = RDF sage: from sage.structure.element import Element as domain sage: _builder_and_stream(["x", "y"], domain) - (, + (, ) """ if isinstance(domain, sage.rings.abc.RealField): @@ -1804,7 +1804,7 @@ cpdef generate_code(Expression expr, InstructionStream stream): sage: instr_stream.instr('return') sage: v = Wrapper_py(instr_stream.get_current()) sage: type(v) - + sage: v(7) 8*pi + 56 diff --git a/src/sage/ext/interpreters/meson.build b/src/sage/ext/interpreters/meson.build new file mode 100644 index 00000000000..f965ce83da0 --- /dev/null +++ b/src/sage/ext/interpreters/meson.build @@ -0,0 +1,72 @@ + +interpreters = custom_target( + 'sage.ext.interpreters', + output: [ + 'all.py', + 'wrapper_cc.pxd', + 'wrapper_cdf.pxd', + 'wrapper_el.pxd', + 'wrapper_py.pxd', + 'wrapper_rdf.pxd', + 'wrapper_rr.pxd', + 'wrapper_cc.pyx', + 'interp_cc.c', + 'wrapper_cdf.pyx', + 'interp_cdf.c', + 'wrapper_el.pyx', + 'interp_el.c', + 'wrapper_py.pyx', + 'interp_py.c', + 'wrapper_rdf.pyx', + 'interp_rdf.c', + 'wrapper_rr.pyx', + 'interp_rr.c', + '__init__.py', + ], + input: '../../../sage_setup/autogen/interpreters/internal/__init__.py', + command: ['../../../sage_setup/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, + install_dir: py.get_install_dir() / 'sage/ext/interpreters', + install_tag: 'python-runtime', +) + +# Use this once https://github.com/mesonbuild/meson/issues/7372 is fixed +#foreach file : interpreters.to_list() +# py.install_sources( +# file.full_path(), +# subdir : 'sage/ext/interpreters' +# ) +#endforeach + +extension_data = { + 'wrapper_cc' : interpreters[7], + 'wrapper_cdf' : interpreters[9], + 'wrapper_el' : interpreters[11], + 'wrapper_py' : interpreters[13], + 'wrapper_rdf' : interpreters[15], + 'wrapper_rr' : interpreters[17], +} + +interpreters_dep = declare_dependency( + include_directories: include_directories('.'), + sources: [ + interpreters[1], + interpreters[2], + interpreters[3], + interpreters[4], + interpreters[5], + ], +) + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/ext/interpreters', + install: true, + include_directories: [inc_cpython, inc_ext, inc_rings, inc_src], + dependencies: [py_dep, cypari2, cysignals, gmp, gsl, mpc, mpfr, pari], + ) +endforeach diff --git a/src/sage/ext/meson.build b/src/sage/ext/meson.build new file mode 100644 index 00000000000..73d0e85101d --- /dev/null +++ b/src/sage/ext/meson.build @@ -0,0 +1,30 @@ +py.install_sources( + 'all__sagemath_objects.py', + 'ccobject.h', + 'cplusplus.pxd', + 'fast_callable.pxd', + 'fast_eval.pxd', + 'mod_int.h', + 'mod_int.pxd', + 'stdsage.pxd', + subdir: 'sage/ext', +) + +extension_data = { + 'fast_callable' : files('fast_callable.pyx'), + 'fast_eval' : files('fast_eval.pyx'), + 'memory' : files('memory.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/ext', + install: true, + include_directories: [inc_cpython, inc_ext], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +subdir('interpreters') diff --git a/src/sage/functions/meson.build b/src/sage/functions/meson.build new file mode 100644 index 00000000000..c2a77f0e238 --- /dev/null +++ b/src/sage/functions/meson.build @@ -0,0 +1,37 @@ +py.install_sources( + 'airy.py', + 'all.py', + 'bessel.py', + 'error.py', + 'exp_integral.py', + 'gamma.py', + 'generalized.py', + 'hyperbolic.py', + 'hypergeometric.py', + 'jacobi.py', + 'log.py', + 'min_max.py', + 'orthogonal_polys.py', + 'other.py', + 'piecewise.py', + 'special.py', + 'spike_function.py', + 'transcendental.py', + 'trig.py', + 'wigner.py', + subdir: 'sage/functions', +) + +extension_data = {'prime_pi' : files('prime_pi.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/functions', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/games/meson.build b/src/sage/games/meson.build new file mode 100644 index 00000000000..d0776c0c71a --- /dev/null +++ b/src/sage/games/meson.build @@ -0,0 +1,21 @@ +py.install_sources( + 'all.py', + 'hexad.py', + 'quantumino.py', + 'sudoku.py', + subdir: 'sage/games', +) + +extension_data = {'sudoku_backtrack' : files('sudoku_backtrack.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/games', + install: true, + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/geometry/meson.build b/src/sage/geometry/meson.build new file mode 100644 index 00000000000..826ca9ef1db --- /dev/null +++ b/src/sage/geometry/meson.build @@ -0,0 +1,55 @@ +py.install_sources( + 'all.py', + 'cone.py', + 'cone_catalog.py', + 'cone_critical_angles.py', + 'convex_set.py', + 'fan.py', + 'fan_isomorphism.py', + 'fan_morphism.py', + 'hasse_diagram.py', + 'integral_points.py', + 'lattice_polytope.py', + 'linear_expression.py', + 'newton_polygon.py', + 'polyhedral_complex.py', + 'pseudolines.py', + 'relative_interior.py', + 'ribbon_graph.py', + 'toric_lattice.py', + 'toric_plotter.py', + 'voronoi_diagram.py', + subdir: 'sage/geometry', +) + +extension_data = { + 'abc' : files('abc.pyx'), + 'integral_points_generic_dense' : files('integral_points_generic_dense.pyx'), + 'integral_points_integer_dense' : files('integral_points_integer_dense.pyx'), + 'palp_normal_form' : files('palp_normal_form.pyx'), + 'point_collection' : files('point_collection.pyx'), + 'toric_lattice_element' : files('toric_lattice_element.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/geometry', + install: true, + include_directories: [inc_cpython, inc_ext, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + +install_subdir('hyperbolic_space', install_dir: sage_install_dir / 'geometry') +install_subdir( + 'hyperplane_arrangement', + install_dir: sage_install_dir / 'geometry', +) +subdir('polyhedron') +install_subdir( + 'riemannian_manifolds', + install_dir: sage_install_dir / 'geometry', +) +subdir('triangulation') diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build b/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build new file mode 100644 index 00000000000..4b4ea8df4e7 --- /dev/null +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build @@ -0,0 +1,34 @@ +py.install_sources( + 'all.py', + 'base.pxd', + 'combinatorial_face.pxd', + 'conversions.pxd', + 'face_data_structure.pxd', + 'face_iterator.pxd', + 'face_list_data_structure.pxd', + 'list_of_faces.pxd', + 'polyhedron_face_lattice.pxd', + subdir: 'sage/geometry/polyhedron/combinatorial_polyhedron', +) + +extension_data = { + 'base' : files('base.pyx'), + 'combinatorial_face' : files('combinatorial_face.pyx'), + 'conversions' : files('conversions.pyx'), + 'face_iterator' : files('face_iterator.pyx'), + 'face_list_data_structure' : files('face_list_data_structure.pyx'), + 'list_of_faces' : files('list_of_faces.pyx'), + 'polyhedron_face_lattice' : files('polyhedron_face_lattice.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/geometry/polyhedron/combinatorial_polyhedron', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/geometry/polyhedron/meson.build b/src/sage/geometry/polyhedron/meson.build new file mode 100644 index 00000000000..3b07bbdd9a5 --- /dev/null +++ b/src/sage/geometry/polyhedron/meson.build @@ -0,0 +1,43 @@ +py.install_sources( + 'all.py', + 'backend_cdd.py', + 'backend_cdd_rdf.py', + 'backend_field.py', + 'backend_normaliz.py', + 'backend_number_field.py', + 'backend_polymake.py', + 'backend_ppl.py', + 'base.py', + 'base0.py', + 'base1.py', + 'base2.py', + 'base3.py', + 'base4.py', + 'base5.py', + 'base6.py', + 'base7.py', + 'base_QQ.py', + 'base_RDF.py', + 'base_ZZ.py', + 'base_mutable.py', + 'base_number_field.py', + 'cdd_file_format.py', + 'constructor.py', + 'double_description.py', + 'double_description_inhomogeneous.py', + 'face.py', + 'generating_function.py', + 'lattice_euclidean_group_element.py', + 'library.py', + 'misc.py', + 'palp_database.py', + 'parent.py', + 'plot.py', + 'ppl_lattice_polygon.py', + 'ppl_lattice_polytope.py', + 'representation.py', + subdir: 'sage/geometry/polyhedron', +) + +subdir('combinatorial_polyhedron') +install_subdir('modules', install_dir: sage_install_dir / 'geometry/polyhedron') diff --git a/src/sage/geometry/triangulation/meson.build b/src/sage/geometry/triangulation/meson.build new file mode 100644 index 00000000000..dec407d83d5 --- /dev/null +++ b/src/sage/geometry/triangulation/meson.build @@ -0,0 +1,26 @@ +py.install_sources( + 'all.py', + 'data.pxd', + 'element.py', + 'functions.pxd', + 'point_configuration.py', + 'triangulations.pxd', + subdir: 'sage/geometry/triangulation', +) + +extension_data_cpp = { + 'base': files('base.pyx', 'data.cc', 'functions.cc', 'triangulations.cc'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/geometry/triangulation', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/graphs/base/meson.build b/src/sage/graphs/base/meson.build new file mode 100644 index 00000000000..92e205ceb81 --- /dev/null +++ b/src/sage/graphs/base/meson.build @@ -0,0 +1,51 @@ +py.install_sources( + 'all.py', + 'boost_graph.pxd', + 'c_graph.pxd', + 'dense_graph.pxd', + 'graph_backends.pxd', + 'overview.py', + 'sparse_graph.pxd', + 'static_dense_graph.pxd', + 'static_sparse_backend.pxd', + 'static_sparse_graph.pxd', + subdir: 'sage/graphs/base', +) + +extension_data = { + 'dense_graph' : files('dense_graph.pyx'), + 'graph_backends' : files('graph_backends.pyx'), + 'sparse_graph' : files('sparse_graph.pyx'), + 'static_dense_graph' : files('static_dense_graph.pyx'), + 'static_sparse_backend' : files('static_sparse_backend.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs/base', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +extension_data_cpp = { + 'boost_graph': files('boost_graph.pyx'), + 'c_graph': files('c_graph.pyx'), + 'static_sparse_graph': files('static_sparse_graph.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs/base', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/graphs/generators/distance_regular.pyx b/src/sage/graphs/generators/distance_regular.pyx index 795bfa58dc2..4a4c17b6ce0 100644 --- a/src/sage/graphs/generators/distance_regular.pyx +++ b/src/sage/graphs/generators/distance_regular.pyx @@ -1423,14 +1423,14 @@ def GeneralisedOctagonGraph(const int s, const int t): EXAMPLES:: sage: # needs sage.libs.gap - sage: G = graphs.GeneralisedOctagonGraph(1, 4) - sage: G.is_distance_regular(True) + sage: G = graphs.GeneralisedOctagonGraph(1, 4) # optional - database_graphs + sage: G.is_distance_regular(True) # optional - database_graphs ([5, 4, 4, 4, None], [None, 1, 1, 1, 5]) sage: G = graphs.GeneralisedOctagonGraph(2, 4) # optional - gap_package_atlasrep internet sage: G.is_distance_regular(True) # optional - gap_package_atlasrep internet ([10, 8, 8, 8, None], [None, 1, 1, 1, 5]) - sage: G = graphs.GeneralisedOctagonGraph(5, 1) - sage: G.is_distance_regular(True) + sage: G = graphs.GeneralisedOctagonGraph(5, 1) # optional - database_graphs + sage: G.is_distance_regular(True) # optional - database_graphs ([10, 5, 5, 5, None], [None, 1, 1, 1, 2]) .. NOTE:: @@ -2741,7 +2741,7 @@ def distance_regular_graph(list arr, existence=False, check=True): Hamming Graph with parameters 7,3: Graph on 2187 vertices sage: graphs.distance_regular_graph([66, 45, 28, 1, 6, 30]) Graph on 1024 vertices - sage: graphs.distance_regular_graph([6,5,5,5,1,1,1,6]) + sage: graphs.distance_regular_graph([6,5,5,5,1,1,1,6]) # optional - database_graphs Generalised octagon of order (1, 5): Graph on 312 vertices sage: graphs.distance_regular_graph([64, 60, 1, 1, 15, 64], check=True) Graph on 325 vertices diff --git a/src/sage/graphs/generators/meson.build b/src/sage/graphs/generators/meson.build new file mode 100644 index 00000000000..44542f2631e --- /dev/null +++ b/src/sage/graphs/generators/meson.build @@ -0,0 +1,28 @@ +py.install_sources( + 'all.py', + 'basic.py', + 'chessboard.py', + 'classical_geometries.py', + 'degree_sequence.py', + 'families.py', + 'intersection.py', + 'platonic_solids.py', + 'random.py', + 'smallgraphs.py', + 'world_map.py', + subdir: 'sage/graphs/generators', +) + +extension_data = {'distance_regular' : files('distance_regular.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs/generators', + install: true, + include_directories: [], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/graphs/graph_decompositions/meson.build b/src/sage/graphs/graph_decompositions/meson.build new file mode 100644 index 00000000000..0d9778ae2ba --- /dev/null +++ b/src/sage/graphs/graph_decompositions/meson.build @@ -0,0 +1,64 @@ +tdlib = cc.find_library('tdlib', required: false, disabler: true) +# Cannot be found via pkg-config +rw = cc.find_library('rw') + +py.install_sources( + 'all.py', + 'all__sagemath_tdlib.py', + 'fast_digraph.pxd', + 'modular_decomposition.py', + 'rankwidth.pxd', + 'slice_decomposition.pxd', + 'tree_decomposition.pxd', + 'vertex_separation.pxd', + subdir: 'sage/graphs/graph_decompositions', +) + +extension_data = { + 'bandwidth' : files('bandwidth.pyx'), + 'cutwidth' : files('cutwidth.pyx'), + 'fast_digraph' : files('fast_digraph.pyx'), + 'graph_products' : files('graph_products.pyx'), + 'rankwidth' : files('rankwidth.pyx'), + 'tree_decomposition' : files('tree_decomposition.pyx'), + 'vertex_separation' : files('vertex_separation.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs/graph_decompositions', + install: true, + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, cysignals, gmp, rw], + ) +endforeach + +extension_data_cpp = { + 'clique_separators': files('clique_separators.pyx'), + 'slice_decomposition' : files('slice_decomposition.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs/graph_decompositions', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, cysignals, gmp, rw], + ) +endforeach + +py.extension_module( + 'tdlib', + sources: 'tdlib.pyx', + subdir: 'sage/graphs/graph_decompositions', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, cysignals, tdlib], +) + diff --git a/src/sage/graphs/meson.build b/src/sage/graphs/meson.build new file mode 100644 index 00000000000..dbc1808f107 --- /dev/null +++ b/src/sage/graphs/meson.build @@ -0,0 +1,138 @@ +bliss = cc.find_library('bliss', required: false, disabler: true) +mcqd = cc.find_library('mcqd', required: false, disabler: true) +cliquer = cc.find_library('cliquer') + +# Cannot be found via pkg-config +planarity = cc.find_library('planarity') + +py.install_sources( + 'all.py', + 'all__sagemath_bliss.py', + 'all__sagemath_mcqd.py', + 'all__sagemath_tdlib.py', + 'bipartite_graph.py', + 'cliquer.pxd', + 'cographs.py', + 'connectivity.pxd', + 'convexity_properties.pxd', + 'digraph.py', + 'digraph_generators.py', + 'distances_all_pairs.pxd', + 'domination.py', + 'dot2tex_utils.py', + 'generic_graph.py', + 'generic_graph_pyx.pxd', + 'graph.py', + 'graph_database.py', + 'graph_editor.py', + 'graph_generators.py', + 'graph_input.py', + 'graph_latex.py', + 'graph_list.py', + 'graph_plot.py', + 'graph_plot_js.py', + 'hypergraph_generators.py', + 'independent_sets.pxd', + 'isgci.py', + 'lovasz_theta.py', + 'matching.py', + 'mcqd.pxd', + 'orientations.py', + 'partial_cube.py', + 'pq_trees.py', + 'print_graphs.py', + 'schnyder.py', + 'traversals.pxd', + 'trees.pxd', + 'tutte_polynomial.py', + subdir: 'sage/graphs', +) + +extension_data = { + 'asteroidal_triples' : files('asteroidal_triples.pyx'), + 'centrality' : files('centrality.pyx'), + 'chrompoly' : files('chrompoly.pyx'), + 'cliquer' : files('cliquer.pyx'), + 'comparability' : files('comparability.pyx'), + 'connectivity' : files('connectivity.pyx'), + 'convexity_properties' : files('convexity_properties.pyx'), + 'distances_all_pairs' : files('distances_all_pairs.pyx'), + 'generic_graph_pyx' : files('generic_graph_pyx.pyx'), + 'genus' : files('genus.pyx'), + 'graph_generators_pyx' : files('graph_generators_pyx.pyx'), + 'hyperbolicity' : files('hyperbolicity.pyx'), + 'independent_sets' : files('independent_sets.pyx'), + 'isoperimetric_inequalities' : files('isoperimetric_inequalities.pyx'), + 'line_graph' : files('line_graph.pyx'), + 'matchpoly' : files('matchpoly.pyx'), + 'planarity' : files('planarity.pyx'), + 'spanning_tree' : files('spanning_tree.pyx'), + 'strongly_regular_db' : files('strongly_regular_db.pyx'), + 'trees' : files('trees.pyx'), + 'views' : files('views.pyx'), + 'weakly_chordal' : files('weakly_chordal.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs', + install: true, + include_directories: [ + inc_cpython, + inc_data_structures, + inc_flint, + inc_rings, + ], + dependencies: [py_dep, cysignals, cliquer, flint, gmp, planarity], + ) +endforeach + +extension_data_cpp = { + 'edge_connectivity': files('edge_connectivity.pyx'), + 'graph_coloring': files('graph_coloring.pyx'), + 'path_enumeration': files('path_enumeration.pyx'), + 'traversals': files('traversals.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/graphs', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_data_structures, + inc_flint, + inc_rings, + ], + dependencies: [py_dep, cysignals, flint, gmp, planarity], + ) +endforeach + +py.extension_module( + 'bliss', + sources: files('bliss.pyx'), + subdir: 'sage/graphs', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_data_structures, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, bliss], +) + +py.extension_module( + 'mcqd', + sources: files('mcqd.pyx'), + subdir: 'sage/graphs', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_data_structures, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, mcqd], +) + +subdir('base') +subdir('generators') +subdir('graph_decompositions') diff --git a/src/sage/groups/matrix_gps/meson.build b/src/sage/groups/matrix_gps/meson.build new file mode 100644 index 00000000000..43968d8ed59 --- /dev/null +++ b/src/sage/groups/matrix_gps/meson.build @@ -0,0 +1,45 @@ +py.install_sources( + 'all.py', + 'binary_dihedral.py', + 'catalog.py', + 'coxeter_group.py', + 'finitely_generated.py', + 'finitely_generated_gap.py', + 'group_element.pxd', + 'group_element_gap.pxd', + 'heisenberg.py', + 'homset.py', + 'isometries.py', + 'linear.py', + 'linear_gap.py', + 'matrix_group.py', + 'matrix_group_gap.py', + 'morphism.py', + 'named_group.py', + 'named_group_gap.py', + 'orthogonal.py', + 'orthogonal_gap.py', + 'pickling_overrides.py', + 'symplectic.py', + 'symplectic_gap.py', + 'unitary.py', + 'unitary_gap.py', + subdir: 'sage/groups/matrix_gps', +) + +extension_data = { + 'group_element' : files('group_element.pyx'), + 'group_element_gap' : files('group_element_gap.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/groups/matrix_gps', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/groups/meson.build b/src/sage/groups/meson.build new file mode 100644 index 00000000000..3e2ffbb471c --- /dev/null +++ b/src/sage/groups/meson.build @@ -0,0 +1,57 @@ +py.install_sources( + 'all.py', + 'artin.py', + 'braid.py', + 'cactus_group.py', + 'class_function.py', + 'conjugacy_classes.py', + 'cubic_braid.py', + 'finitely_presented.py', + 'finitely_presented_catalog.py', + 'finitely_presented_named.py', + 'fqf_orthogonal.py', + 'free_group.py', + 'galois_group.py', + 'galois_group_perm.py', + 'generic.py', + 'group.pxd', + 'group_exp.py', + 'group_semidirect_product.py', + 'groups_catalog.py', + 'indexed_free_group.py', + 'kernel_subgroup.py', + 'libgap_group.py', + 'libgap_mixin.py', + 'libgap_morphism.py', + 'libgap_wrapper.pxd', + 'old.pxd', + 'pari_group.py', + 'raag.py', + subdir: 'sage/groups', +) + +extension_data = { + 'group' : files('group.pyx'), + 'libgap_wrapper' : files('libgap_wrapper.pyx'), + 'old' : files('old.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/groups', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + +install_subdir('abelian_gps', install_dir: sage_install_dir / 'groups') +install_subdir('additive_abelian', install_dir: sage_install_dir / 'groups') +install_subdir('affine_gps', install_dir: sage_install_dir / 'groups') +install_subdir('lie_gps', install_dir: sage_install_dir / 'groups') +subdir('matrix_gps') +install_subdir('misc_gps', install_dir: sage_install_dir / 'groups') +subdir('perm_gps') +subdir('semimonomial_transformations') diff --git a/src/sage/groups/perm_gps/meson.build b/src/sage/groups/perm_gps/meson.build new file mode 100644 index 00000000000..e986fcd964a --- /dev/null +++ b/src/sage/groups/perm_gps/meson.build @@ -0,0 +1,28 @@ +py.install_sources( + 'all.py', + 'constructor.py', + 'cubegroup.py', + 'permgroup.py', + 'permgroup_element.pxd', + 'permgroup_morphism.py', + 'permgroup_named.py', + 'permutation_groups_catalog.py', + 'symgp_conjugacy_class.py', + subdir: 'sage/groups/perm_gps', +) + +extension_data = {'permgroup_element' : files('permgroup_element.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/groups/perm_gps', + install: true, + include_directories: [inc_cpython, inc_ext, inc_rings], + dependencies: [py_dep, cysignals, gap, gmp], + ) +endforeach + +subdir('partn_ref') +subdir('partn_ref2') diff --git a/src/sage/groups/perm_gps/partn_ref/meson.build b/src/sage/groups/perm_gps/partn_ref/meson.build new file mode 100644 index 00000000000..092b0d0b2c8 --- /dev/null +++ b/src/sage/groups/perm_gps/partn_ref/meson.build @@ -0,0 +1,41 @@ +py.install_sources( + 'all.py', + 'automorphism_group_canonical_label.pxd', + 'canonical_augmentation.pxd', + 'data_structures.pxd', + 'double_coset.pxd', + 'refinement_binary.pxd', + 'refinement_graphs.pxd', + 'refinement_lists.pxd', + 'refinement_matrices.pxd', + 'refinement_python.pxd', + 'refinement_sets.pxd', + subdir: 'sage/groups/perm_gps/partn_ref', +) + +extension_data = { + 'automorphism_group_canonical_label' : files( + 'automorphism_group_canonical_label.pyx', + ), + 'canonical_augmentation' : files('canonical_augmentation.pyx'), + 'data_structures' : files('data_structures.pyx'), + 'double_coset' : files('double_coset.pyx'), + 'refinement_binary' : files('refinement_binary.pyx'), + 'refinement_graphs' : files('refinement_graphs.pyx'), + 'refinement_lists' : files('refinement_lists.pyx'), + 'refinement_matrices' : files('refinement_matrices.pyx'), + 'refinement_python' : files('refinement_python.pyx'), + 'refinement_sets' : files('refinement_sets.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/groups/perm_gps/partn_ref', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/groups/perm_gps/partn_ref2/meson.build b/src/sage/groups/perm_gps/partn_ref2/meson.build new file mode 100644 index 00000000000..ca6fadbfda9 --- /dev/null +++ b/src/sage/groups/perm_gps/partn_ref2/meson.build @@ -0,0 +1,19 @@ +py.install_sources( + 'all.py', + 'refinement_generic.pxd', + subdir: 'sage/groups/perm_gps/partn_ref2', +) + +extension_data = {'refinement_generic' : files('refinement_generic.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/groups/perm_gps/partn_ref2', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_partn_ref2], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/groups/semimonomial_transformations/meson.build b/src/sage/groups/semimonomial_transformations/meson.build new file mode 100644 index 00000000000..402cb5244e5 --- /dev/null +++ b/src/sage/groups/semimonomial_transformations/meson.build @@ -0,0 +1,22 @@ +py.install_sources( + 'all.py', + 'semimonomial_transformation.pxd', + 'semimonomial_transformation_group.py', + subdir: 'sage/groups/semimonomial_transformations', +) + +extension_data = { + 'semimonomial_transformation' : files('semimonomial_transformation.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/groups/semimonomial_transformations', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/interacts/meson.build b/src/sage/interacts/meson.build new file mode 100644 index 00000000000..4889c06f9fa --- /dev/null +++ b/src/sage/interacts/meson.build @@ -0,0 +1,24 @@ +py.install_sources( + 'algebra.py', + 'all.py', + 'calculus.py', + 'fractals.py', + 'geometry.py', + 'library.py', + 'statistics.py', + subdir: 'sage/interacts', +) + +extension_data = {'library_cython' : files('library_cython.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/interacts', + install: true, + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/interfaces/meson.build b/src/sage/interfaces/meson.build new file mode 100644 index 00000000000..4a12245d532 --- /dev/null +++ b/src/sage/interfaces/meson.build @@ -0,0 +1,79 @@ +py.install_sources( + 'abc.py', + 'all.py', + 'all__sagemath_polyhedra.py', + 'axiom.py', + 'cleaner.py', + 'ecm.py', + 'expect.py', + 'four_ti_2.py', + 'fricas.py', + 'frobby.py', + 'gap.py', + 'gap3.py', + 'gap_workspace.py', + 'genus2reduction.py', + 'gfan.py', + 'giac.py', + 'gnuplot.py', + 'gp.py', + 'interface.py', + 'jmoldata.py', + 'kash.py', + 'kenzo.py', + 'latte.py', + 'lie.py', + 'lisp.py', + 'macaulay2.py', + 'magma.py', + 'magma_free.py', + 'maple.py', + 'mathematica.py', + 'mathics.py', + 'matlab.py', + 'maxima.py', + 'maxima_abstract.py', + 'maxima_lib.py', + 'mupad.py', + 'mwrank.py', + 'octave.py', + 'phc.py', + 'polymake.py', + 'povray.py', + 'process.pxd', + 'psage.py', + 'qepcad.py', + 'qsieve.py', + 'quit.py', + 'r.py', + 'read_data.py', + 'rubik.py', + 'sage-maxima.lisp', + 'sage0.py', + 'scilab.py', + 'singular.py', + 'sympy.py', + 'sympy_wrapper.py', + 'tab_completion.py', + 'tachyon.py', + 'tests.py', + 'tides.py', + subdir: 'sage/interfaces', +) + +extension_data = { + 'process' : files('process.pyx'), + 'sagespawn' : files('sagespawn.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/interfaces', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/lfunctions/meson.build b/src/sage/lfunctions/meson.build new file mode 100644 index 00000000000..cf0ffe05e17 --- /dev/null +++ b/src/sage/lfunctions/meson.build @@ -0,0 +1,22 @@ +py.install_sources( + 'all.py', + 'dokchitser.py', + 'lcalc.py', + 'pari.py', + 'sympow.py', + subdir: 'sage/lfunctions', +) + +extension_data = {'zero_sums' : files('zero_sums.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/lfunctions', + install: true, + include_directories: [inc_flint], + dependencies: [py_dep, flint, gmp], + ) +endforeach + diff --git a/src/sage/libs/arb/meson.build b/src/sage/libs/arb/meson.build new file mode 100644 index 00000000000..aa98fb8ff3a --- /dev/null +++ b/src/sage/libs/arb/meson.build @@ -0,0 +1,33 @@ +py.install_sources( + '__init__.py', + 'acb.pxd', + 'acb_calc.pxd', + 'acb_elliptic.pxd', + 'acb_hypgeom.pxd', + 'acb_mat.pxd', + 'acb_modular.pxd', + 'acb_poly.pxd', + 'arb.pxd', + 'arb_fmpz_poly.pxd', + 'arb_hypgeom.pxd', + 'arb_wrap.h', + 'arf.pxd', + 'bernoulli.pxd', + 'mag.pxd', + 'types.pxd', + subdir: 'sage/libs/arb', +) + +extension_data = {'arith' : files('arith.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/arb', + install: true, + include_directories: [inc_cpython, inc_flint, inc_rings], + dependencies: [py_dep, flint, gmp, mpfr], + ) +endforeach + diff --git a/src/sage/libs/coxeter3/meson.build b/src/sage/libs/coxeter3/meson.build new file mode 100644 index 00000000000..83cbd2b46cd --- /dev/null +++ b/src/sage/libs/coxeter3/meson.build @@ -0,0 +1,23 @@ +coxeter3 = cc.find_library('coxeter3', required: false, disabler: true) +py.install_sources( + '__init__.py', + 'all__sagemath_coxeter3.py', + 'coxeter.pxd', + 'coxeter_group.py', + 'decl.pxd', + subdir: 'sage/libs/coxeter3', +) + +extension_data_cpp = {'coxeter': files('coxeter.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/coxeter3', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [], + dependencies: [py_dep, cysignals, coxeter3], + ) +endforeach diff --git a/src/sage/libs/eclib/meson.build b/src/sage/libs/eclib/meson.build new file mode 100644 index 00000000000..dd6ecc3f581 --- /dev/null +++ b/src/sage/libs/eclib/meson.build @@ -0,0 +1,31 @@ +py.install_sources( + '__init__.pxd', + '__init__.py', + 'all.py', + 'constructor.py', + 'homspace.pxd', + 'interface.py', + 'mat.pxd', + 'newforms.pxd', + subdir: 'sage/libs/eclib', +) + +extension_data_cpp = { + 'homspace': files('homspace.pyx'), + 'mat': files('mat.pyx'), + 'mwrank': files('mwrank.pyx'), + 'newforms': files('newforms.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/eclib', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ext, inc_flint, inc_ntl, inc_rings], + dependencies: [py_dep, cysignals, ec, flint, gmp], + ) +endforeach + diff --git a/src/sage/libs/flint/meson.build b/src/sage/libs/flint/meson.build new file mode 100644 index 00000000000..fe12b28b5f7 --- /dev/null +++ b/src/sage/libs/flint/meson.build @@ -0,0 +1,177 @@ +py.install_sources( + '__init__.py', + 'acb.pxd', + 'acb_calc.pxd', + 'acb_dft.pxd', + 'acb_dirichlet.pxd', + 'acb_elliptic.pxd', + 'acb_hypgeom.pxd', + 'acb_macros.pxd', + 'acb_mat.pxd', + 'acb_mat_macros.pxd', + 'acb_modular.pxd', + 'acb_poly.pxd', + 'acb_poly_macros.pxd', + 'acb_theta.pxd', + 'acf.pxd', + 'aprcl.pxd', + 'arb.pxd', + 'arb_calc.pxd', + 'arb_fmpz_poly.pxd', + 'arb_fpwrap.pxd', + 'arb_hypgeom.pxd', + 'arb_macros.pxd', + 'arb_mat.pxd', + 'arb_mat_macros.pxd', + 'arb_poly.pxd', + 'arf.pxd', + 'arith.pxd', + 'bernoulli.pxd', + 'bool_mat.pxd', + 'ca.pxd', + 'ca_ext.pxd', + 'ca_field.pxd', + 'ca_mat.pxd', + 'ca_poly.pxd', + 'ca_vec.pxd', + 'calcium.pxd', + 'd_mat.pxd', + 'd_vec.pxd', + 'dirichlet.pxd', + 'dlog.pxd', + 'double_extras.pxd', + 'double_interval.pxd', + 'fexpr.pxd', + 'fexpr_builtin.pxd', + 'fft.pxd', + 'flint.pxd', + 'flint_ntl_wrap.h', + 'flint_wrap.h', + 'fmpq.pxd', + 'fmpq_mat.pxd', + 'fmpq_mat_macros.pxd', + 'fmpq_mpoly.pxd', + 'fmpq_mpoly_factor.pxd', + 'fmpq_poly.pxd', + 'fmpq_poly_macros.pxd', + 'fmpq_poly_sage.pxd', + 'fmpq_vec.pxd', + 'fmpz.pxd', + 'fmpz_extras.pxd', + 'fmpz_factor.pxd', + 'fmpz_factor_sage.pxd', + 'fmpz_lll.pxd', + 'fmpz_macros.pxd', + 'fmpz_mat.pxd', + 'fmpz_mat_macros.pxd', + 'fmpz_mod.pxd', + 'fmpz_mod_mat.pxd', + 'fmpz_mod_mpoly.pxd', + 'fmpz_mod_mpoly_factor.pxd', + 'fmpz_mod_poly.pxd', + 'fmpz_mod_poly_factor.pxd', + 'fmpz_mod_vec.pxd', + 'fmpz_mpoly.pxd', + 'fmpz_mpoly_factor.pxd', + 'fmpz_mpoly_q.pxd', + 'fmpz_poly.pxd', + 'fmpz_poly_factor.pxd', + 'fmpz_poly_macros.pxd', + 'fmpz_poly_mat.pxd', + 'fmpz_poly_q.pxd', + 'fmpz_poly_sage.pxd', + 'fmpz_vec.pxd', + 'fmpzi.pxd', + 'fq.pxd', + 'fq_default.pxd', + 'fq_default_mat.pxd', + 'fq_default_poly.pxd', + 'fq_default_poly_factor.pxd', + 'fq_embed.pxd', + 'fq_mat.pxd', + 'fq_nmod.pxd', + 'fq_nmod_embed.pxd', + 'fq_nmod_mat.pxd', + 'fq_nmod_mpoly.pxd', + 'fq_nmod_mpoly_factor.pxd', + 'fq_nmod_poly.pxd', + 'fq_nmod_poly_factor.pxd', + 'fq_nmod_vec.pxd', + 'fq_poly.pxd', + 'fq_poly_factor.pxd', + 'fq_vec.pxd', + 'fq_zech.pxd', + 'fq_zech_embed.pxd', + 'fq_zech_mat.pxd', + 'fq_zech_poly.pxd', + 'fq_zech_poly_factor.pxd', + 'fq_zech_vec.pxd', + 'gr.pxd', + 'gr_generic.pxd', + 'gr_mat.pxd', + 'gr_mpoly.pxd', + 'gr_poly.pxd', + 'gr_special.pxd', + 'gr_vec.pxd', + 'hypgeom.pxd', + 'long_extras.pxd', + 'mag.pxd', + 'mag_macros.pxd', + 'mpf_mat.pxd', + 'mpf_vec.pxd', + 'mpfr_mat.pxd', + 'mpfr_vec.pxd', + 'mpn_extras.pxd', + 'mpoly.pxd', + 'nf.pxd', + 'nf_elem.pxd', + 'nmod.pxd', + 'nmod_mat.pxd', + 'nmod_mpoly.pxd', + 'nmod_mpoly_factor.pxd', + 'nmod_poly.pxd', + 'nmod_poly_factor.pxd', + 'nmod_poly_mat.pxd', + 'nmod_vec.pxd', + 'ntl_interface.pxd', + 'padic.pxd', + 'padic_mat.pxd', + 'padic_poly.pxd', + 'partitions.pxd', + 'perm.pxd', + 'profiler.pxd', + 'qadic.pxd', + 'qfb.pxd', + 'qqbar.pxd', + 'qsieve.pxd', + 'thread_pool.pxd', + 'types.pxd', + 'ulong_extras.pxd', + subdir: 'sage/libs/flint', +) + +extension_data = { + 'arith' : files('arith.pyx'), + 'arith_sage' : files('arith_sage.pyx'), + 'flint_sage' : files('flint_sage.pyx'), + 'fmpq_poly_sage' : files('fmpq_poly_sage.pyx'), + 'fmpz_factor_sage' : files('fmpz_factor_sage.pyx'), + 'fmpz_poly' : files('fmpz_poly.pyx'), + 'fmpz_poly_sage' : files('fmpz_poly_sage.pyx'), + 'qsieve' : files('qsieve.pyx'), + 'qsieve_sage' : files('qsieve_sage.pyx'), + 'ulong_extras' : files('ulong_extras.pyx'), + 'ulong_extras_sage' : files('ulong_extras_sage.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/flint', + install: true, + include_directories: [inc_cpython, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, flint, gmp, mpfr], + ) +endforeach + diff --git a/src/sage/libs/gap/meson.build b/src/sage/libs/gap/meson.build new file mode 100644 index 00000000000..2302a169cb2 --- /dev/null +++ b/src/sage/libs/gap/meson.build @@ -0,0 +1,38 @@ +py.install_sources( + 'all.py', + 'all_documented_functions.py', + 'assigned_names.py', + 'context_managers.py', + 'element.pxd', + 'gap_functions.py', + 'gap_globals.py', + 'gap_includes.pxd', + 'operations.py', + 'sage.gaprc', + 'saved_workspace.py', + 'test.py', + 'test_long.py', + 'util.pxd', + subdir: 'sage/libs/gap', +) + +# Ensure that the gaprc file is installed also in editable mode +fs.copyfile('sage.gaprc') + +extension_data = { + 'element' : files('element.pyx'), + 'libgap' : files('libgap.pyx'), + 'util' : files('util.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/gap', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gap, gmp], + ) +endforeach + diff --git a/src/sage/libs/giac/meson.build b/src/sage/libs/giac/meson.build new file mode 100644 index 00000000000..6dda5a6c8a7 --- /dev/null +++ b/src/sage/libs/giac/meson.build @@ -0,0 +1,17 @@ +giac = cc.find_library('giac', required: false, disabler: true) + +py.install_sources('__init__.py', 'giac.pxd', 'misc.h', subdir: 'sage/libs/giac') + +extension_data_cpp = {'giac': files('giac.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/giac', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ext, inc_rings], + dependencies: [py_dep, cysignals, giac, gmp], + ) +endforeach diff --git a/src/sage/libs/glpk/meson.build b/src/sage/libs/glpk/meson.build new file mode 100644 index 00000000000..ee265cc1579 --- /dev/null +++ b/src/sage/libs/glpk/meson.build @@ -0,0 +1,9 @@ +py.install_sources( + '__init__.py', + 'constants.pxd', + 'env.pxd', + 'graph.pxd', + 'lp.pxd', + 'types.pxd', + subdir: 'sage/libs/glpk', +) diff --git a/src/sage/libs/gmp/meson.build b/src/sage/libs/gmp/meson.build new file mode 100644 index 00000000000..31fb4f3a5fa --- /dev/null +++ b/src/sage/libs/gmp/meson.build @@ -0,0 +1,29 @@ +py.install_sources( + '__init__.py', + 'all.pxd', + 'binop.pxd', + 'misc.pxd', + 'mpf.pxd', + 'mpn.pxd', + 'mpq.pxd', + 'mpz.pxd', + 'pylong.pxd', + 'random.pxd', + 'randomize.pxd', + 'types.pxd', + subdir: 'sage/libs/gmp', +) + +extension_data = {'pylong' : files('pylong.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/gmp', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/libs/gsl/meson.build b/src/sage/libs/gsl/meson.build new file mode 100644 index 00000000000..ea5eac5e93a --- /dev/null +++ b/src/sage/libs/gsl/meson.build @@ -0,0 +1,82 @@ +py.install_sources( + '__init__.py', + 'airy.pxd', + 'all.pxd', + 'array.pxd', + 'bessel.pxd', + 'blas.pxd', + 'blas_types.pxd', + 'block.pxd', + 'chebyshev.pxd', + 'clausen.pxd', + 'combination.pxd', + 'complex.pxd', + 'coulomb.pxd', + 'coupling.pxd', + 'dawson.pxd', + 'debye.pxd', + 'dilog.pxd', + 'eigen.pxd', + 'elementary.pxd', + 'ellint.pxd', + 'elljac.pxd', + 'erf.pxd', + 'errno.pxd', + 'exp.pxd', + 'expint.pxd', + 'fermi_dirac.pxd', + 'fft.pxd', + 'fit.pxd', + 'gamma.pxd', + 'gegenbauer.pxd', + 'histogram.pxd', + 'hyperg.pxd', + 'integration.pxd', + 'interp.pxd', + 'laguerre.pxd', + 'lambert.pxd', + 'legendre.pxd', + 'linalg.pxd', + 'log.pxd', + 'math.pxd', + 'matrix.pxd', + 'matrix_complex.pxd', + 'min.pxd', + 'monte.pxd', + 'ntuple.pxd', + 'odeiv.pxd', + 'permutation.pxd', + 'poly.pxd', + 'pow_int.pxd', + 'psi.pxd', + 'qrng.pxd', + 'random.pxd', + 'rng.pxd', + 'roots.pxd', + 'sort.pxd', + 'statistics.pxd', + 'sum.pxd', + 'synchrotron.pxd', + 'transport.pxd', + 'trig.pxd', + 'types.pxd', + 'vector.pxd', + 'vector_complex.pxd', + 'wavelet.pxd', + 'zeta.pxd', + subdir: 'sage/libs/gsl', +) + +extension_data = {'array' : files('array.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/gsl', + install: true, + include_directories: [inc_gsl], + dependencies: [py_dep, cysignals, gmp, gsl], + ) +endforeach + diff --git a/src/sage/libs/lcalc/meson.build b/src/sage/libs/lcalc/meson.build new file mode 100644 index 00000000000..aa6d9296948 --- /dev/null +++ b/src/sage/libs/lcalc/meson.build @@ -0,0 +1,23 @@ +lcalc = dependency('lcalc', version: '>= 2.0.0') + +py.install_sources( + '__init__.py', + 'lcalc_Lfunction.pxd', + 'lcalc_sage.h', + subdir: 'sage/libs/lcalc', +) + +extension_data_cpp = {'lcalc_Lfunction': files('lcalc_Lfunction.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/lcalc', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cypari2, cysignals, gmp, lcalc, m, mpfr, ntl], + ) +endforeach + diff --git a/src/sage/libs/linbox/meson.build b/src/sage/libs/linbox/meson.build new file mode 100644 index 00000000000..252a6ae0f9e --- /dev/null +++ b/src/sage/libs/linbox/meson.build @@ -0,0 +1,26 @@ +py.install_sources( + '__init__.py', + 'conversion.pxd', + 'fflas.pxd', + 'givaro.pxd', + 'linbox.pxd', + 'linbox_flint_interface.pxd', + subdir: 'sage/libs/linbox', +) + +extension_data_cpp = { + 'linbox_flint_interface': files('linbox_flint_interface.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/linbox', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_flint], + dependencies: [py_dep, blas, flint, fplll, givaro, gmp, gmpxx, linbox], + ) +endforeach + diff --git a/src/sage/libs/meson.build b/src/sage/libs/meson.build new file mode 100644 index 00000000000..61b36da51f5 --- /dev/null +++ b/src/sage/libs/meson.build @@ -0,0 +1,86 @@ +sirocco = cc.find_library('sirocco', required: false, disabler: true) +# cannot be found via pkg-config +ecl = cc.find_library('ecl') +braiding = cc.find_library('braiding') +gc = cc.find_library('gc') +homfly = cc.find_library('homfly', has_headers: ['homfly.h']) + +py.install_sources( + 'all.py', + 'all__sagemath_coxeter3.py', + 'all__sagemath_meataxe.py', + 'all__sagemath_objects.py', + 'all__sagemath_sirocco.py', + 'ecl.pxd', + 'eclsig.h', + 'gmpxx.pxd', + 'iml.pxd', + 'm4ri.pxd', + 'm4rie.pxd', + 'meataxe.pxd', + subdir: 'sage/libs', +) + +extension_data = { + 'ecl' : files('ecl.pyx'), + 'homfly' : files('homfly.pyx'), + 'libecm' : files('libecm.pyx'), + 'sirocco': files('sirocco.pyx'), + 'meataxe': files('meataxe.pyx'), +} + +dependencies = [py_dep, braiding, cysignals, ecl, ecm, gc, gmp, homfly] + +foreach name, pyx : extension_data + deps = dependencies + if name == 'sirocco' + deps += [sirocco] + elif name == 'meataxe' + deps += [mtx, meataxe] + endif + + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: deps, + ) +endforeach + +extension_data_cpp = {'braiding': files('braiding.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_rings], + dependencies: dependencies, + ) +endforeach + +subdir('arb') +subdir('coxeter3') +install_subdir('cremona', install_dir: sage_install_dir / 'libs') +subdir('eclib') +subdir('flint') +subdir('gap') +subdir('giac') +subdir('glpk') +subdir('gmp') +subdir('gsl') +subdir('lcalc') +subdir('linbox') +install_subdir('linkages', install_dir: sage_install_dir / 'libs') +install_subdir('lrcalc', install_dir: sage_install_dir / 'libs') +install_subdir('mpfr', install_dir: sage_install_dir / 'libs') +subdir('mpmath') +install_subdir('mwrank', install_dir: sage_install_dir / 'libs') +subdir('ntl') +subdir('pari') +subdir('singular') +subdir('symmetrica') diff --git a/src/sage/libs/mpmath/meson.build b/src/sage/libs/mpmath/meson.build new file mode 100644 index 00000000000..4659da1563a --- /dev/null +++ b/src/sage/libs/mpmath/meson.build @@ -0,0 +1,27 @@ +py.install_sources( + '__init__.py', + 'all.py', + 'ext_impl.pxd', + 'ext_main.pxd', + 'utils.pxd', + subdir: 'sage/libs/mpmath', +) + +extension_data = { + 'ext_impl' : files('ext_impl.pyx'), + 'ext_libmp' : files('ext_libmp.pyx'), + 'ext_main' : files('ext_main.pyx'), + 'utils' : files('utils.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/mpmath', + install: true, + include_directories: [inc_cpython, inc_ext, inc_rings], + dependencies: [py_dep, cypari2, cysignals, gmp, mpfr], + ) +endforeach + diff --git a/src/sage/libs/ntl/meson.build b/src/sage/libs/ntl/meson.build new file mode 100644 index 00000000000..7f78db280fe --- /dev/null +++ b/src/sage/libs/ntl/meson.build @@ -0,0 +1,90 @@ +py.install_sources( + 'GF2.pxd', + 'GF2E.pxd', + 'GF2EX.pxd', + 'GF2X.pxd', + 'ZZ.pxd', + 'ZZX.pxd', + 'ZZ_p.pxd', + 'ZZ_pE.pxd', + 'ZZ_pEX.pxd', + 'ZZ_pX.pxd', + '__init__.py', + 'all.py', + 'conversion.pxd', + 'convert.pxd', + 'lzz_p.pxd', + 'lzz_pX.pxd', + 'mat_GF2.pxd', + 'mat_GF2E.pxd', + 'mat_ZZ.pxd', + 'ntl_GF2.pxd', + 'ntl_GF2E.pxd', + 'ntl_GF2EContext.pxd', + 'ntl_GF2EX.pxd', + 'ntl_GF2X.pxd', + 'ntl_ZZ.pxd', + 'ntl_ZZX.pxd', + 'ntl_ZZ_p.pxd', + 'ntl_ZZ_pContext.pxd', + 'ntl_ZZ_pE.pxd', + 'ntl_ZZ_pEContext.pxd', + 'ntl_ZZ_pEX.pxd', + 'ntl_ZZ_pX.pxd', + 'ntl_lzz_p.pxd', + 'ntl_lzz_pContext.pxd', + 'ntl_lzz_pX.pxd', + 'ntl_mat_GF2.pxd', + 'ntl_mat_GF2E.pxd', + 'ntl_mat_ZZ.pxd', + 'ntl_tools.pxd', + 'ntlwrap.h', + 'ntlwrap_impl.h', + 'types.pxd', + 'vec_GF2.pxd', + 'vec_GF2E.pxd', + subdir: 'sage/libs/ntl', +) + +extension_data_cpp = { + 'convert': files('convert.pyx'), + 'error': files('error.pyx'), + 'ntl_GF2': files('ntl_GF2.pyx'), + 'ntl_GF2E': files('ntl_GF2E.pyx'), + 'ntl_GF2EContext': files('ntl_GF2EContext.pyx'), + 'ntl_GF2EX': files('ntl_GF2EX.pyx'), + 'ntl_GF2X': files('ntl_GF2X.pyx'), + 'ntl_ZZ': files('ntl_ZZ.pyx'), + 'ntl_ZZX': files('ntl_ZZX.pyx'), + 'ntl_ZZ_p': files('ntl_ZZ_p.pyx'), + 'ntl_ZZ_pContext': files('ntl_ZZ_pContext.pyx'), + 'ntl_ZZ_pE': files('ntl_ZZ_pE.pyx'), + 'ntl_ZZ_pEContext': files('ntl_ZZ_pEContext.pyx'), + 'ntl_ZZ_pEX': files('ntl_ZZ_pEX.pyx'), + 'ntl_ZZ_pX': files('ntl_ZZ_pX.pyx'), + 'ntl_lzz_p': files('ntl_lzz_p.pyx'), + 'ntl_lzz_pContext': files('ntl_lzz_pContext.pyx'), + 'ntl_lzz_pX': files('ntl_lzz_pX.pyx'), + 'ntl_mat_GF2': files('ntl_mat_GF2.pyx'), + 'ntl_mat_GF2E': files('ntl_mat_GF2E.pyx'), + 'ntl_mat_ZZ': files('ntl_mat_ZZ.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/ntl', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_ntl, + inc_rings, + inc_rings_finite, + ], + dependencies: [py_dep, cysignals, gmp, m, ntl], + ) +endforeach + diff --git a/src/sage/libs/pari/meson.build b/src/sage/libs/pari/meson.build new file mode 100644 index 00000000000..5952060267c --- /dev/null +++ b/src/sage/libs/pari/meson.build @@ -0,0 +1,36 @@ +py.install_sources( + '__init__.py', + 'all.py', + 'convert_flint.pxd', + 'convert_gmp.pxd', + 'convert_sage.pxd', + 'convert_sage_complex_double.pxd', + 'convert_sage_real_double.pxd', + 'convert_sage_real_mpfr.pxd', + 'misc.pxd', + 'tests.py', + subdir: 'sage/libs/pari', +) + +extension_data = { + 'convert_flint' : files('convert_flint.pyx'), + 'convert_gmp' : files('convert_gmp.pyx'), + 'convert_sage' : files('convert_sage.pyx'), + 'convert_sage_complex_double' : files('convert_sage_complex_double.pyx'), + 'convert_sage_matrix' : files('convert_sage_matrix.pyx'), + 'convert_sage_real_double' : files('convert_sage_real_double.pyx'), + 'convert_sage_real_mpfr' : files('convert_sage_real_mpfr.pyx'), + 'misc' : files('misc.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/pari', + install: true, + include_directories: [inc_cpython, inc_ext, inc_flint, inc_gsl, inc_rings], + dependencies: [py_dep, cypari2, cysignals, flint, gmp, gsl, mpfr, pari], + ) +endforeach + diff --git a/src/sage/libs/singular/meson.build b/src/sage/libs/singular/meson.build new file mode 100644 index 00000000000..52ece586caa --- /dev/null +++ b/src/sage/libs/singular/meson.build @@ -0,0 +1,34 @@ +py.install_sources( + '__init__.py', + 'decl.pxd', + 'function.pxd', + 'function_factory.py', + 'groebner_strategy.pxd', + 'polynomial.pxd', + 'ring.pxd', + 'singular.pxd', + 'standard_options.py', + subdir: 'sage/libs/singular', +) + +extension_data_cpp = { + 'function': files('function.pyx'), + 'groebner_strategy': files('groebner_strategy.pyx'), + 'option': files('option.pyx'), + 'polynomial': files('polynomial.pyx'), + 'ring': files('ring.pyx'), + 'singular': files('singular.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/singular', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ntl, inc_rings, inc_rings_finite], + dependencies: [py_dep, cysignals, givaro, gmp, singular], + ) +endforeach + diff --git a/src/sage/libs/symmetrica/meson.build b/src/sage/libs/symmetrica/meson.build new file mode 100644 index 00000000000..9294ebe3b03 --- /dev/null +++ b/src/sage/libs/symmetrica/meson.build @@ -0,0 +1,18 @@ +# Cannot be found by pkg-config +symmetrica = cc.find_library('symmetrica') + +py.install_sources('__init__.py', 'all.py', subdir: 'sage/libs/symmetrica') + +extension_data = {'symmetrica' : files('symmetrica.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/libs/symmetrica', + install: true, + include_directories: [], + dependencies: [py_dep, cysignals, gmp, symmetrica], + ) +endforeach + diff --git a/src/sage/matrix/matrix_mod2_dense.pxd b/src/sage/matrix/matrix_mod2_dense.pxd index ea3575ef3be..8b9965f89d8 100644 --- a/src/sage/matrix/matrix_mod2_dense.pxd +++ b/src/sage/matrix/matrix_mod2_dense.pxd @@ -1,4 +1,4 @@ -from .matrix_dense cimport Matrix_dense +from sage.matrix.matrix_dense cimport Matrix_dense from sage.libs.m4ri cimport * cdef class Matrix_mod2_dense(Matrix_dense): diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index 431cf6f5bd9..267a818c433 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -383,7 +383,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation): return Matrix_generic_dense if implementation == 'gap': - from .matrix_gap import Matrix_gap + from sage.matrix.matrix_gap import Matrix_gap return Matrix_gap raise ValueError("unknown matrix implementation %r over %r" % (implementation, R)) diff --git a/src/sage/matrix/matrix_sparse.pxd b/src/sage/matrix/matrix_sparse.pxd index 7546645a6c9..7d8878ea4d8 100644 --- a/src/sage/matrix/matrix_sparse.pxd +++ b/src/sage/matrix/matrix_sparse.pxd @@ -1,4 +1,4 @@ -from .matrix cimport Matrix +from sage.matrix.matrix cimport Matrix cdef class Matrix_sparse(Matrix): pass diff --git a/src/sage/matrix/meson.build b/src/sage/matrix/meson.build new file mode 100644 index 00000000000..c0841d77f34 --- /dev/null +++ b/src/sage/matrix/meson.build @@ -0,0 +1,199 @@ +iml = cc.find_library('iml') + + +py.install_sources( + 'action.pxd', + 'all.py', + 'all__sagemath_meataxe.py', + 'args.pxd', + 'benchmark.py', + 'berlekamp_massey.py', + 'compute_J_ideal.py', + 'docs.py', + 'matrix.pxd', + 'matrix0.pxd', + 'matrix1.pxd', + 'matrix2.pxd', + 'matrix_cdv.pxd', + 'matrix_complex_ball_dense.pxd', + 'matrix_complex_double_dense.pxd', + 'matrix_cyclo_dense.pxd', + 'matrix_dense.pxd', + 'matrix_domain_dense.pxd', + 'matrix_domain_sparse.pxd', + 'matrix_double_dense.pxd', + 'matrix_double_sparse.pxd', + 'matrix_gap.pxd', + 'matrix_generic_dense.pxd', + 'matrix_generic_sparse.pxd', + 'matrix_gf2e_dense.pxd', + 'matrix_gfpn_dense.pxd', + 'matrix_integer_dense.pxd', + 'matrix_integer_dense_hnf.py', + 'matrix_integer_dense_saturation.py', + 'matrix_integer_sparse.pxd', + 'matrix_laurent_mpolynomial_dense.pxd', + 'matrix_misc.py', + 'matrix_mod2_dense.pxd', + 'matrix_modn_dense_double.pxd', + 'matrix_modn_dense_float.pxd', + 'matrix_modn_sparse.pxd', + 'matrix_mpolynomial_dense.pxd', + 'matrix_numpy_dense.pxd', + 'matrix_numpy_integer_dense.pxd', + 'matrix_polynomial_dense.pxd', + 'matrix_rational_dense.pxd', + 'matrix_rational_sparse.pxd', + 'matrix_real_double_dense.pxd', + 'matrix_space.py', + 'matrix_sparse.pxd', + 'matrix_symbolic_dense.pxd', + 'matrix_symbolic_sparse.pxd', + 'matrix_window.pxd', + 'operation_table.py', + 'special.py', + 'symplectic_basis.py', + 'template.pxd', + 'tests.py', + subdir: 'sage/matrix', +) + +extension_data = { + 'action' : files('action.pyx'), + 'args' : files('args.pyx'), + 'change_ring' : files('change_ring.pyx'), + 'constructor' : files('constructor.pyx'), + 'echelon_matrix' : files('echelon_matrix.pyx'), + 'matrix0' : files('matrix0.pyx'), + 'matrix1' : files('matrix1.pyx'), + 'matrix2' : files('matrix2.pyx'), + 'matrix_cdv' : files('matrix_cdv.pyx'), + 'matrix_complex_ball_dense' : files('matrix_complex_ball_dense.pyx'), + 'matrix_complex_double_dense' : files('matrix_complex_double_dense.pyx'), + 'matrix_dense' : files('matrix_dense.pyx'), + 'matrix_double_dense' : files('matrix_double_dense.pyx'), + 'matrix_double_sparse' : files('matrix_double_sparse.pyx'), + 'matrix_gap' : files('matrix_gap.pyx'), + 'matrix_generic_dense' : files('matrix_generic_dense.pyx'), + 'matrix_generic_sparse' : files('matrix_generic_sparse.pyx'), + 'matrix_gfpn_dense' : files('matrix_gfpn_dense.pyx'), + 'matrix_laurent_mpolynomial_dense' : files( + 'matrix_laurent_mpolynomial_dense.pyx', + ), + 'matrix_numpy_dense' : files('matrix_numpy_dense.pyx'), + 'matrix_numpy_integer_dense' : files('matrix_numpy_integer_dense.pyx'), + 'matrix_polynomial_dense' : files('matrix_polynomial_dense.pyx'), + 'matrix_rational_sparse' : files('matrix_rational_sparse.pyx'), + 'matrix_real_double_dense' : files('matrix_real_double_dense.pyx'), + 'matrix_sparse' : files('matrix_sparse.pyx'), + 'matrix_symbolic_dense' : files('matrix_symbolic_dense.pyx'), + 'matrix_symbolic_sparse' : files('matrix_symbolic_sparse.pyx'), + 'matrix_window' : files('matrix_window.pyx'), + 'misc' : files('misc.pyx'), + 'misc_flint' : files('misc_flint.pyx'), + 'misc_mpfr' : files('misc_mpfr.pyx'), + 'strassen' : files('strassen.pyx'), +} + +foreach name, pyx : extension_data + dependencies = [ + py_dep, + blas, + cypari2, + cysignals, + fflas, + flint, + gd, + givaro, + gmp, + gmpxx, + iml, + linbox, + m, + m4ri, + m4rie, + mpfi, + mpfr, + ntl, + pari, + png, + zlib, + ] + if name == 'matrix_gfpn_dense' + dependencies += [mtx, meataxe] + endif + + py.extension_module( + name, + sources: pyx, + subdir: 'sage/matrix', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_ntl, + inc_numpy, + inc_rings, + inc_rings_finite, + ], + dependencies: dependencies, + ) +endforeach + +extension_data_cpp = { + 'matrix_cyclo_dense': files('matrix_cyclo_dense.pyx'), + 'matrix_gf2e_dense': files('matrix_gf2e_dense.pyx'), + 'matrix_integer_dense': files('matrix_integer_dense.pyx'), + 'matrix_integer_sparse': files('matrix_integer_sparse.pyx'), + 'matrix_mod2_dense': files('matrix_mod2_dense.pyx'), + 'matrix_modn_dense_double': files('matrix_modn_dense_double.pyx'), + 'matrix_modn_dense_float': files('matrix_modn_dense_float.pyx'), + 'matrix_modn_sparse': files('matrix_modn_sparse.pyx'), + 'matrix_mpolynomial_dense': files('matrix_mpolynomial_dense.pyx'), + 'matrix_rational_dense': files('matrix_rational_dense.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/matrix', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_ntl, + inc_numpy, + inc_rings, + inc_rings_finite, + ], + dependencies: [ + py_dep, + blas, + cypari2, + cysignals, + fflas, + flint, + gd, + givaro, + gmp, + gmpxx, + iml, + linbox, + m, + m4ri, + m4rie, + mpfi, + mpfr, + ntl, + pari, + png, + singular, + zlib, + ], + ) +endforeach + diff --git a/src/sage/matroids/meson.build b/src/sage/matroids/meson.build new file mode 100644 index 00000000000..43c80789811 --- /dev/null +++ b/src/sage/matroids/meson.build @@ -0,0 +1,56 @@ +py.install_sources( + 'advanced.py', + 'all.py', + 'basis_exchange_matroid.pxd', + 'basis_matroid.pxd', + 'catalog.py', + 'circuit_closures_matroid.pxd', + 'circuits_matroid.pxd', + 'constructor.py', + 'database_collections.py', + 'database_matroids.py', + 'dual_matroid.py', + 'extension.pxd', + 'flats_matroid.pxd', + 'graphic_matroid.pxd', + 'lean_matrix.pxd', + 'linear_matroid.pxd', + 'matroid.pxd', + 'matroids_catalog.py', + 'matroids_plot_helpers.py', + 'minor_matroid.py', + 'named_matroids.py', + 'rank_matroid.py', + 'set_system.pxd', + 'union_matroid.pxd', + 'utilities.py', + subdir: 'sage/matroids', +) + +extension_data = { + 'basis_exchange_matroid' : files('basis_exchange_matroid.pyx'), + 'basis_matroid' : files('basis_matroid.pyx'), + 'circuit_closures_matroid' : files('circuit_closures_matroid.pyx'), + 'circuits_matroid' : files('circuits_matroid.pyx'), + 'extension' : files('extension.pyx'), + 'lean_matrix' : files('lean_matrix.pyx'), + 'linear_matroid' : files('linear_matroid.pyx'), + 'matroid' : files('matroid.pyx'), + 'set_system' : files('set_system.pyx'), + 'union_matroid' : files('union_matroid.pyx'), + 'unpickling' : files('unpickling.pyx'), + 'flats_matroid' : files('flats_matroid.pyx'), + 'graphic_matroid' : files('graphic_matroid.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/matroids', + install: true, + include_directories: [inc_cpython, inc_data_structures, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/matroids/union_matroid.pxd b/src/sage/matroids/union_matroid.pxd index 72d13abc91c..6542629010e 100644 --- a/src/sage/matroids/union_matroid.pxd +++ b/src/sage/matroids/union_matroid.pxd @@ -1,6 +1,5 @@ from sage.matroids.matroid cimport Matroid - cdef class MatroidUnion(Matroid): cdef list matroids cdef frozenset _groundset diff --git a/src/sage/meson.build b/src/sage/meson.build new file mode 100644 index 00000000000..687ac549c10 --- /dev/null +++ b/src/sage/meson.build @@ -0,0 +1,145 @@ +fs = import('fs') +sage_install_dir = py.get_install_dir() / 'sage' + +# Generate the configuration file +conf_data = configuration_data() +conf_data.set('PACKAGE_VERSION', '1.2.3') +conf_data.set('SAGE_ROOT', meson.current_source_dir() / '..' / '..') +# We use Python's prefix here to make it work with conda +prefix = py.get_variable('prefix', '') +conf_data.set('prefix', prefix) +datadir = fs.expanduser(get_option('datadir')) +if not fs.is_absolute(datadir) + datadir = prefix / datadir +endif +conf_data.set('SAGE_SHARE', datadir) +if not fs.exists(datadir / 'cremona') + message( + 'Warning: The specified datadir does not contain the necessary Cremona database. Either specify a different datadir or specify a correct the correct path via the environment variable SAGE_SHARE during runtime.', + ) +endif +conf_data.set('SAGE_MAXIMA', maxima.full_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') +# It can be found, so we don't have to set anything here: +conf_data.set('NTL_INCDIR', '') +conf_data.set('NTL_LIBDIR', '') +ecl_config = find_program('ecl-config', required: true) +conf_data.set('SAGE_ECL_CONFIG', ecl_config.full_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', '') +openmp = dependency('openmp', required: false, disabler: true) +if openmp.found() + conf_data.set('OPENMP_CFLAGS', '-fopenmp') + conf_data.set('OPENMP_CXXFLAGS', '-fopenmp') +endif +gap_exe = find_program('gap') +if gap_exe.found() + gaprun = run_command( + gap_exe, + '-r', + '-q', + '--bare', + '--nointeract', + '-c', + 'Display(JoinStringsWithSeparator(GAPInfo.RootPaths,";"));', + check: true, + ) + gap_root_paths = gaprun.stdout().strip() + gap_root_paths = '${prefix}/lib/gap;${prefix}/share/gap;' + gaprun.stdout().strip() +endif +conf_data.set('GAP_ROOT_PATHS', gap_root_paths) +ecm_bin = find_program(['ecm', 'gmp-ecm'], required: true) +conf_data.set('SAGE_ECMBIN', ecm_bin.full_path()) + +config_file = configure_file( + input: '../../pkgs/sage-conf_conda/_sage_conf/_conf.py.in', + output: 'config.py', + install_dir: py.get_install_dir() / 'sage', + install: true, + configuration: conf_data, +) + +# Packages that need no processing and can be installed directly +no_processing = [ + 'databases', + 'doctest', + 'ext_data', + 'features', + 'game_theory', + 'homology', + 'knots', + 'logic', + 'manifolds', + 'parallel', + 'repl', + 'sandpiles', + 'tensor', + 'topology', + 'typeset', +] +foreach package : no_processing + install_subdir(package, install_dir: sage_install_dir) +endforeach + +py.install_sources( + config_file, + 'all.py', + 'all__sagemath_bliss.py', + 'all__sagemath_categories.py', + 'all__sagemath_coxeter3.py', + 'all__sagemath_environment.py', + 'all__sagemath_mcqd.py', + 'all__sagemath_meataxe.py', + 'all__sagemath_objects.py', + 'all__sagemath_repl.py', + 'all__sagemath_sirocco.py', + 'all__sagemath_tdlib.py', + 'all_cmdline.py', + 'env.py', + 'version.py', + subdir: 'sage', +) + +subdir('cpython') +subdir('libs') +subdir('misc') +subdir('structure') +subdir('algebras') +subdir('arith') +subdir('ext') +subdir('calculus') +subdir('categories') +subdir('coding') +subdir('combinat') +subdir('crypto') +subdir('data_structures') +subdir('functions') +subdir('games') +subdir('geometry') +subdir('graphs') +subdir('groups') +subdir('interacts') +subdir('interfaces') +subdir('lfunctions') +subdir('matrix') +subdir('matroids') +subdir('modular') +subdir('modules') +subdir('monoids') +subdir('numerical') +subdir('plot') +subdir('probability') +subdir('quadratic_forms') +subdir('quivers') +subdir('rings') +subdir('schemes') +subdir('sets') +subdir('stats') +subdir('symbolic') +subdir('tests') +subdir('dynamics') +subdir('sat') diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx index 3ece833bece..7514aee1569 100644 --- a/src/sage/misc/lazy_attribute.pyx +++ b/src/sage/misc/lazy_attribute.pyx @@ -66,8 +66,8 @@ cdef class _lazy_attribute(): sage: Parent.element_class - sage: Parent.element_class.__doc__[91:147] - 'The (default) class for the elements of this parent.\n\n ' + sage: "The (default) class for the elements of this parent" in Parent.element_class.__doc__ + True sage: Parent.element_class.__name__ 'element_class' sage: Parent.element_class.__module__ diff --git a/src/sage/misc/meson.build b/src/sage/misc/meson.build new file mode 100644 index 00000000000..bd05d525252 --- /dev/null +++ b/src/sage/misc/meson.build @@ -0,0 +1,136 @@ +py.install_sources( + 'abstract_method.py', + 'all.py', + 'all__sagemath_environment.py', + 'all__sagemath_objects.py', + 'all__sagemath_repl.py', + 'allocator.pxd', + 'banner.py', + 'benchmark.py', + 'binary_tree.pxd', + 'bindable_class.py', + 'c3_controlled.pxd', + 'cachefunc.pxd', + 'call.py', + 'classcall_metaclass.pxd', + 'classgraph.py', + 'compat.py', + 'converting_dict.py', + 'copying.py', + 'cython.py', + 'decorators.py', + 'defaults.py', + 'dev_tools.py', + 'edit_module.py', + 'element_with_label.py', + 'explain_pickle.py', + 'fast_methods.pxd', + 'flatten.py', + 'func_persist.py', + 'function_mangling.pxd', + 'functional.py', + 'gperftools.py', + 'html.py', + 'inherit_comparison.pxd', + 'inline_fortran.py', + 'latex.py', + 'latex_macros.py', + 'latex_standalone.py', + 'lazy_format.py', + 'lazy_import_cache.py', + 'lazy_list.pxd', + 'lazy_string.pxd', + 'map_threaded.py', + 'mathml.py', + 'messaging.py', + 'method_decorator.py', + 'misc.py', + 'misc_c.pxd', + 'mrange.py', + 'multireplace.py', + 'namespace_package.py', + 'nested_class.pxd', + 'object_multiplexer.py', + 'package.py', + 'package_dir.py', + 'pager.py', + 'prandom.py', + 'profiler.py', + 'proof.py', + 'python.py', + 'random_testing.py', + 'randstate.pxd', + 'remote_file.py', + 'replace_dot_all.py', + 'repr.py', + 'rest_index_of_methods.py', + 'sage_eval.py', + 'sage_input.py', + 'sage_timeit.py', + 'sage_unittest.py', + 'sagedoc.py', + 'sagedoc_conf.py', + 'sageinspect.py', + 'search.pxd', + 'sh.py', + 'sphinxify.py', + 'superseded.py', + 'table.py', + 'temporary_file.py', + 'test_class_pickling.py', + 'test_nested_class.py', + 'timing.py', + 'trace.py', + 'unknown.py', + 'verbose.py', + 'viewer.py', + 'weak_dict.pxd', + subdir: 'sage/misc', +) + +extension_data = { + 'allocator' : files('allocator.pyx'), + 'binary_tree' : files('binary_tree.pyx'), + 'c3' : files('c3.pyx'), + 'c3_controlled' : files('c3_controlled.pyx'), + 'cachefunc' : files('cachefunc.pyx'), + 'callable_dict' : files('callable_dict.pyx'), + 'citation' : files('citation.pyx'), + 'classcall_metaclass' : files('classcall_metaclass.pyx'), + 'constant_function' : files('constant_function.pyx'), + 'derivative' : files('derivative.pyx'), + 'fast_methods' : files('fast_methods.pyx'), + 'fpickle' : files('fpickle.pyx'), + 'function_mangling' : files('function_mangling.pyx'), + 'inherit_comparison' : files('inherit_comparison.pyx'), + 'instancedoc' : files('instancedoc.pyx'), + 'lazy_attribute' : files('lazy_attribute.pyx'), + 'lazy_import' : files('lazy_import.pyx'), + 'lazy_list' : files('lazy_list.pyx'), + 'lazy_string' : files('lazy_string.pyx'), + 'misc_c' : files('misc_c.pyx'), + 'nested_class' : files('nested_class.pyx'), + 'parser' : files('parser.pyx'), + 'persist' : files('persist.pyx'), + 'pickle_old' : files('pickle_old.pyx'), + 'randstate' : files('randstate.pyx'), + 'reset' : files('reset.pyx'), + 'sage_ostools' : files('sage_ostools.pyx'), + 'sage_timeit_class' : files('sage_timeit_class.pyx'), + 'search' : files('search.pyx'), + 'session' : files('session.pyx'), + 'stopgap' : files('stopgap.pyx'), + 'weak_dict' : files('weak_dict.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/misc', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/misc/nested_class.pyx b/src/sage/misc/nested_class.pyx index a3a42dfe5d4..e42569abe3e 100644 --- a/src/sage/misc/nested_class.pyx +++ b/src/sage/misc/nested_class.pyx @@ -335,7 +335,7 @@ class MainClass(object, metaclass=NestedClassMetaclass): sage: from sage.misc.nested_class import MainClass sage: print(MainClass.NestedClass.NestedSubClass.dummy.__doc__) NestedSubClass.dummy(self, x, *args, r=(1, 2, 3.4), **kwds) - File: sage/misc/nested_class.pyx (starting at line ...) + File: ...sage/misc/nested_class.pyx (starting at line ...) A dummy method to demonstrate the embedding of method signature for nested classes. diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py index 827fd77e811..0505f6039a9 100644 --- a/src/sage/misc/sagedoc.py +++ b/src/sage/misc/sagedoc.py @@ -669,10 +669,7 @@ def format(s, embedded=False): EXAMPLES:: sage: from sage.misc.sagedoc import format - sage: identity_matrix(2).rook_vector.__doc__[191:263] # needs sage.modules - 'Let `A` be an `m` by `n` (0,1)-matrix. We identify `A` with a chessboard' - - sage: format(identity_matrix(2).rook_vector.__doc__[191:263]) # needs sage.modules + sage: format('Let `A` be an `m` by `n` (0,1)-matrix. We identify `A` with a chessboard') 'Let A be an m by n (0,1)-matrix. We identify A with a chessboard\n' If the first line of the string is 'nodetex', remove 'nodetex' but diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py index a6e0f7d8ad4..1f2a39d7c78 100644 --- a/src/sage/misc/sageinspect.py +++ b/src/sage/misc/sageinspect.py @@ -311,7 +311,7 @@ def _extract_embedded_signature(docstring, name): sage: from sage.misc.sageinspect import _extract_embedded_signature sage: from sage.misc.nested_class import MainClass sage: print(_extract_embedded_signature(MainClass.NestedClass.NestedSubClass.dummy.__doc__, 'dummy')[0]) - File: sage/misc/nested_class.pyx (starting at line ...) + File: ...sage/misc/nested_class.pyx (starting at line ...) ... sage: _extract_embedded_signature(MainClass.NestedClass.NestedSubClass.dummy.__doc__, 'dummy')[1] FullArgSpec(args=['self', 'x', 'r'], varargs='args', varkw='kwds', defaults=((1, 2, 3.4),), kwonlyargs=[], kwonlydefaults=None, annotations={}) @@ -1850,7 +1850,7 @@ def _sage_getdoc_unformatted(obj): sage: from sage.misc.sageinspect import _sage_getdoc_unformatted sage: print(_sage_getdoc_unformatted(sage.rings.integer.Integer)) Integer(x=None, base=0) - File: sage/rings/integer.pyx (starting at line ...) + File: ...sage/rings/integer.pyx (starting at line ...) The :class:`Integer` class represents arbitrary precision integers. It derives from the :class:`Element` class, so diff --git a/src/sage/modular/arithgroup/meson.build b/src/sage/modular/arithgroup/meson.build new file mode 100644 index 00000000000..c4a68af3217 --- /dev/null +++ b/src/sage/modular/arithgroup/meson.build @@ -0,0 +1,65 @@ +py.install_sources( + 'all.py', + 'arithgroup_generic.py', + 'arithgroup_perm.py', + 'congroup_gamma.py', + 'congroup_gamma0.py', + 'congroup_gamma1.py', + 'congroup_gammaH.py', + 'congroup_generic.py', + 'congroup_sl2z.py', + 'tests.py', + subdir: 'sage/modular/arithgroup', +) + +extension_data = { + 'arithgroup_element' : files('arithgroup_element.pyx'), + 'congroup' : files('congroup.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modular/arithgroup', + install: true, + include_directories: [inc_cpython, inc_ext, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + +# Manually create header file, which otherwise is not found +farey_symbol_header = custom_target( + 'farey_symbol.h', + output: 'farey_symbol.h', + input: 'farey_symbol.pyx', + command: [ + cython.cmd_array(), + '--cplus', + '@INPUT@', + '-o', + '@OUTPUT@', + '-I', + join_paths(meson.current_source_dir(), '../../../'), + ], +) + +extension_data_cpp = { + 'farey_symbol': [ + files('farey.cpp', 'farey_symbol.pyx', 'sl2z.cpp'), + farey_symbol_header[0], + ], +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modular/arithgroup', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ext, inc_flint, inc_rings, inc_src], + dependencies: [py_dep, cysignals, flint, gmp, gmpxx], + ) +endforeach + diff --git a/src/sage/modular/meson.build b/src/sage/modular/meson.build new file mode 100644 index 00000000000..d334cf975c8 --- /dev/null +++ b/src/sage/modular/meson.build @@ -0,0 +1,47 @@ +py.install_sources( + 'all.py', + 'buzzard.py', + 'congroup.py', + 'congroup_element.py', + 'cusps.py', + 'cusps_nf.py', + 'dims.py', + 'dirichlet.py', + 'etaproducts.py', + 'hypergeometric_misc.pxd', + 'hypergeometric_motive.py', + 'multiple_zeta.py', + 'multiple_zeta_F_algebra.py', + subdir: 'sage/modular', +) + +extension_data = {'hypergeometric_misc' : files('hypergeometric_misc.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modular', + install: true, + include_directories: [inc_cpython], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +install_subdir('abvar', install_dir: sage_install_dir / 'modular') +subdir('arithgroup') +install_subdir('btquotients', install_dir: sage_install_dir / 'modular') +install_subdir('drinfeld_modform', install_dir: sage_install_dir / 'modular') +install_subdir('hecke', install_dir: sage_install_dir / 'modular') +install_subdir('local_comp', install_dir: sage_install_dir / 'modular') +subdir('modform') +install_subdir( + 'modform_hecketriangle', + install_dir: sage_install_dir / 'modular', +) +subdir('modsym') +install_subdir('overconvergent', install_dir: sage_install_dir / 'modular') +subdir('pollack_stevens') +install_subdir('quasimodform', install_dir: sage_install_dir / 'modular') +install_subdir('quatalg', install_dir: sage_install_dir / 'modular') +install_subdir('ssmod', install_dir: sage_install_dir / 'modular') diff --git a/src/sage/modular/modform/meson.build b/src/sage/modular/modform/meson.build new file mode 100644 index 00000000000..7276059448d --- /dev/null +++ b/src/sage/modular/modform/meson.build @@ -0,0 +1,47 @@ +py.install_sources( + 'all.py', + 'ambient.py', + 'ambient_R.py', + 'ambient_eps.py', + 'ambient_g0.py', + 'ambient_g1.py', + 'constructor.py', + 'cuspidal_submodule.py', + 'defaults.py', + 'eis_series.py', + 'eisenstein_submodule.py', + 'element.py', + 'find_generators.py', + 'half_integral.py', + 'hecke_operator_on_qexp.py', + 'j_invariant.py', + 'l_series_gross_zagier.py', + 'notes.py', + 'numerical.py', + 'periods.py', + 'ring.py', + 'space.py', + 'submodule.py', + 'tests.py', + 'theta.py', + 'vm_basis.py', + 'weight1.py', + subdir: 'sage/modular/modform', +) + +extension_data = { + 'eis_series_cython' : files('eis_series_cython.pyx'), + 'l_series_gross_zagier_coeffs' : files('l_series_gross_zagier_coeffs.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modular/modform', + install: true, + include_directories: [inc_cpython, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + diff --git a/src/sage/modular/modsym/meson.build b/src/sage/modular/modsym/meson.build new file mode 100644 index 00000000000..f05d0776246 --- /dev/null +++ b/src/sage/modular/modsym/meson.build @@ -0,0 +1,41 @@ +py.install_sources( + 'all.py', + 'ambient.py', + 'apply.pxd', + 'boundary.py', + 'element.py', + 'g1list.py', + 'ghlist.py', + 'hecke_operator.py', + 'manin_symbol.pxd', + 'manin_symbol_list.py', + 'modsym.py', + 'modular_symbols.py', + 'p1list.pxd', + 'p1list_nf.py', + 'relation_matrix.py', + 'space.py', + 'subspace.py', + 'tests.py', + subdir: 'sage/modular/modsym', +) + +extension_data = { + 'apply' : files('apply.pyx'), + 'heilbronn' : files('heilbronn.pyx'), + 'manin_symbol' : files('manin_symbol.pyx'), + 'p1list' : files('p1list.pyx'), + 'relation_matrix_pyx' : files('relation_matrix_pyx.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modular/modsym', + install: true, + include_directories: [inc_cpython, inc_ext, inc_flint, inc_rings], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + diff --git a/src/sage/modular/pollack_stevens/meson.build b/src/sage/modular/pollack_stevens/meson.build new file mode 100644 index 00000000000..d22947db12c --- /dev/null +++ b/src/sage/modular/pollack_stevens/meson.build @@ -0,0 +1,26 @@ +py.install_sources( + 'all.py', + 'dist.pxd', + 'distributions.py', + 'fund_domain.py', + 'manin_map.py', + 'modsym.py', + 'padic_lseries.py', + 'sigma0.py', + 'space.py', + subdir: 'sage/modular/pollack_stevens', +) + +extension_data = {'dist' : files('dist.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modular/pollack_stevens', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/modules/meson.build b/src/sage/modules/meson.build new file mode 100644 index 00000000000..bc505da9372 --- /dev/null +++ b/src/sage/modules/meson.build @@ -0,0 +1,101 @@ +py.install_sources( + 'all.py', + 'complex_double_vector.py', + 'diamond_cutting.py', + 'filtered_vector_space.py', + 'finite_submodule_iter.pxd', + 'free_module.py', + 'free_module_element.pxd', + 'free_module_homspace.py', + 'free_module_integer.py', + 'free_module_morphism.py', + 'free_quadratic_module.py', + 'free_quadratic_module_integer_symmetric.py', + 'matrix_morphism.py', + 'misc.py', + 'module.pxd', + 'module_functors.py', + 'multi_filtered_vector_space.py', + 'quotient_module.py', + 'real_double_vector.py', + 'submodule.py', + 'tensor_operations.py', + 'torsion_quadratic_module.py', + 'tutorial_free_modules.py', + 'vector_callable_symbolic_dense.py', + 'vector_complex_double_dense.pxd', + 'vector_double_dense.pxd', + 'vector_integer_dense.pxd', + 'vector_integer_sparse.pxd', + 'vector_mod2_dense.pxd', + 'vector_modn_dense.pxd', + 'vector_modn_sparse.pxd', + 'vector_numpy_dense.pxd', + 'vector_numpy_integer_dense.pxd', + 'vector_rational_dense.pxd', + 'vector_rational_sparse.pxd', + 'vector_real_double_dense.pxd', + 'vector_space_homspace.py', + 'vector_space_morphism.py', + 'vector_symbolic_dense.py', + 'vector_symbolic_sparse.py', + subdir: 'sage/modules', +) + +extension_data = { + 'finite_submodule_iter' : files('finite_submodule_iter.pyx'), + 'free_module_element' : files('free_module_element.pyx'), + 'module' : files('module.pyx'), + 'vector_complex_double_dense' : files('vector_complex_double_dense.pyx'), + 'vector_double_dense' : files('vector_double_dense.pyx'), + 'vector_integer_dense' : files('vector_integer_dense.pyx'), + 'vector_integer_sparse' : files('vector_integer_sparse.pyx'), + 'vector_modn_dense' : files('vector_modn_dense.pyx'), + 'vector_modn_sparse' : files('vector_modn_sparse.pyx'), + 'vector_numpy_dense' : files('vector_numpy_dense.pyx'), + 'vector_numpy_integer_dense' : files('vector_numpy_integer_dense.pyx'), + 'vector_rational_dense' : files('vector_rational_dense.pyx'), + 'vector_rational_sparse' : files('vector_rational_sparse.pyx'), + 'vector_real_double_dense' : files('vector_real_double_dense.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modules', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_numpy, + inc_rings, + inc_rings_finite, + ], + dependencies: [py_dep, cysignals, gd, gmp, m4ri, png], + ) +endforeach + +extension_data_cpp = {'vector_mod2_dense': files('vector_mod2_dense.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modules', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_numpy, + inc_rings, + inc_rings_finite, + ], + dependencies: [py_dep, cysignals, gd, gmp, m4ri, png], + ) +endforeach + +install_subdir('fg_pid', install_dir: sage_install_dir / 'modules') +install_subdir('fp_graded', install_dir: sage_install_dir / 'modules') +subdir('with_basis') diff --git a/src/sage/modules/with_basis/meson.build b/src/sage/modules/with_basis/meson.build new file mode 100644 index 00000000000..1956c6ac99c --- /dev/null +++ b/src/sage/modules/with_basis/meson.build @@ -0,0 +1,24 @@ +py.install_sources( + 'all.py', + 'cell_module.py', + 'indexed_element.pxd', + 'invariant.py', + 'morphism.py', + 'representation.py', + 'subquotient.py', + subdir: 'sage/modules/with_basis', +) + +extension_data = {'indexed_element' : files('indexed_element.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/modules/with_basis', + install: true, + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/monoids/meson.build b/src/sage/monoids/meson.build new file mode 100644 index 00000000000..df2a4ae36be --- /dev/null +++ b/src/sage/monoids/meson.build @@ -0,0 +1,32 @@ +py.install_sources( + 'all.py', + 'automatic_semigroup.py', + 'free_abelian_monoid.py', + 'free_abelian_monoid_element.pxd', + 'free_monoid.py', + 'free_monoid_element.py', + 'hecke_monoid.py', + 'indexed_free_monoid.py', + 'monoid.py', + 'string_monoid.py', + 'string_monoid_element.py', + 'string_ops.py', + 'trace_monoid.py', + subdir: 'sage/monoids', +) + +extension_data = { + 'free_abelian_monoid_element' : files('free_abelian_monoid_element.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/monoids', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/numerical/backends/meson.build b/src/sage/numerical/backends/meson.build new file mode 100644 index 00000000000..a6a53e97033 --- /dev/null +++ b/src/sage/numerical/backends/meson.build @@ -0,0 +1,66 @@ +# Cannot be found via pkg-config +glpk = cc.find_library('glpk') + +py.install_sources( + 'all.py', + 'all__sagemath_polyhedra.py', + 'cvxopt_backend_test.py', + 'cvxpy_backend.pxd', + 'cvxpy_backend_test.py', + 'generic_backend.pxd', + 'generic_backend_test.py', + 'generic_sdp_backend.pxd', + 'glpk_backend.pxd', + 'glpk_backend_test.py', + 'glpk_exact_backend.pxd', + 'glpk_exact_backend_test.py', + 'glpk_graph_backend.pxd', + 'interactivelp_backend.pxd', + 'interactivelp_backend_test.py', + 'logging_backend.py', + 'matrix_sdp_backend.pxd', + 'ppl_backend_test.py', + 'scip_backend.pxd', + 'scip_backend_test.py', + subdir: 'sage/numerical/backends', +) + +extension_data = { + 'cvxopt_backend' : files('cvxopt_backend.pyx'), + 'cvxopt_sdp_backend' : files('cvxopt_sdp_backend.pyx'), + 'cvxpy_backend' : files('cvxpy_backend.pyx'), + 'generic_backend' : files('generic_backend.pyx'), + 'generic_sdp_backend' : files('generic_sdp_backend.pyx'), + 'glpk_backend' : files('glpk_backend.pyx'), + 'glpk_exact_backend' : files('glpk_exact_backend.pyx'), + 'glpk_graph_backend' : files('glpk_graph_backend.pyx'), + 'interactivelp_backend' : files('interactivelp_backend.pyx'), + 'matrix_sdp_backend' : files('matrix_sdp_backend.pyx'), + 'ppl_backend' : files('ppl_backend.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/numerical/backends', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, glpk, gmp], + ) +endforeach + +extension_data_cpp = {'scip_backend': files('scip_backend.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/numerical/backends', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/numerical/meson.build b/src/sage/numerical/meson.build new file mode 100644 index 00000000000..222deff834e --- /dev/null +++ b/src/sage/numerical/meson.build @@ -0,0 +1,35 @@ +py.install_sources( + 'all.py', + 'all__sagemath_polyhedra.py', + 'interactive_simplex_method.py', + 'knapsack.py', + 'linear_functions.pxd', + 'linear_tensor.py', + 'linear_tensor_constraints.py', + 'linear_tensor_element.pxd', + 'mip.pxd', + 'optimize.py', + 'sdp.pxd', + subdir: 'sage/numerical', +) + +extension_data = { + 'gauss_legendre' : files('gauss_legendre.pyx'), + 'linear_functions' : files('linear_functions.pyx'), + 'linear_tensor_element' : files('linear_tensor_element.pyx'), + 'mip' : files('mip.pyx'), + 'sdp' : files('sdp.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/numerical', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cypari2, gmp, mpfr], + ) +endforeach + +subdir('backends') diff --git a/src/sage/plot/meson.build b/src/sage/plot/meson.build new file mode 100644 index 00000000000..96a337faf78 --- /dev/null +++ b/src/sage/plot/meson.build @@ -0,0 +1,48 @@ +py.install_sources( + 'all.py', + 'animate.py', + 'arc.py', + 'arrow.py', + 'bar_chart.py', + 'bezier_path.py', + 'circle.py', + 'colors.py', + 'contour_plot.py', + 'density_plot.py', + 'disk.py', + 'ellipse.py', + 'graphics.py', + 'histogram.py', + 'hyperbolic_arc.py', + 'hyperbolic_polygon.py', + 'hyperbolic_regular_polygon.py', + 'line.py', + 'matrix_plot.py', + 'misc.py', + 'multigraphics.py', + 'plot.py', + 'plot_field.py', + 'point.py', + 'polygon.py', + 'primitive.py', + 'scatter_plot.py', + 'step.py', + 'streamline_plot.py', + 'text.py', + subdir: 'sage/plot', +) + +extension_data = {'complex_plot' : files('complex_plot.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/plot', + install: true, + include_directories: [inc_cpython, inc_gsl, inc_numpy, inc_rings], + dependencies: [py_dep, cysignals, gmp, gsl], + ) +endforeach + +subdir('plot3d') diff --git a/src/sage/plot/plot3d/meson.build b/src/sage/plot/plot3d/meson.build new file mode 100644 index 00000000000..46cc4a25ffc --- /dev/null +++ b/src/sage/plot/plot3d/meson.build @@ -0,0 +1,45 @@ +py.install_sources( + 'all.py', + 'base.pxd', + 'implicit_plot3d.py', + 'index_face_set.pxd', + 'introduction.py', + 'list_plot3d.py', + 'parametric_plot3d.py', + 'parametric_surface.pxd', + 'platonic.py', + 'plot3d.py', + 'plot_field3d.py', + 'revolution_plot3d.py', + 'shapes.pxd', + 'shapes2.py', + 'tachyon.py', + 'texture.py', + 'transform.pxd', + 'tri_plot.py', + subdir: 'sage/plot/plot3d', +) + +extension_data = { + 'base' : files('base.pyx'), + 'implicit_surface' : files('implicit_surface.pyx'), + 'index_face_set' : files('index_face_set.pyx'), + 'shapes' : files('shapes.pyx'), + 'transform' : files('transform.pyx'), + 'parametric_surface' : files('parametric_surface.pyx'), +} + +foreach name, pyx : extension_data + dependencies = [py_dep, cysignals, gmp] + if name == 'parametric_surface' + dependencies += [interpreters_dep] + endif + py.extension_module( + name, + sources: pyx, + subdir: 'sage/plot/plot3d', + install: true, + include_directories: [inc_cpython, inc_ext, inc_numpy], + dependencies: dependencies, + ) +endforeach diff --git a/src/sage/probability/meson.build b/src/sage/probability/meson.build new file mode 100644 index 00000000000..83b6a7e091e --- /dev/null +++ b/src/sage/probability/meson.build @@ -0,0 +1,17 @@ +py.install_sources('all.py', 'random_variable.py', subdir: 'sage/probability') + +extension_data = { + 'probability_distribution' : files('probability_distribution.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/probability', + install: true, + include_directories: [], + dependencies: [py_dep, cysignals, gmp, gsl], + ) +endforeach + diff --git a/src/sage/quadratic_forms/meson.build b/src/sage/quadratic_forms/meson.build new file mode 100644 index 00000000000..0e352ed72be --- /dev/null +++ b/src/sage/quadratic_forms/meson.build @@ -0,0 +1,51 @@ +py.install_sources( + 'all.py', + 'binary_qf.py', + 'bqf_class_group.py', + 'constructions.py', + 'extras.py', + 'qfsolve.py', + 'quadratic_form.py', + 'quadratic_form__automorphisms.py', + 'quadratic_form__count_local_2.py', + 'quadratic_form__equivalence_testing.py', + 'quadratic_form__genus.py', + 'quadratic_form__local_density_congruence.py', + 'quadratic_form__local_density_interfaces.py', + 'quadratic_form__local_field_invariants.py', + 'quadratic_form__local_normal_form.py', + 'quadratic_form__local_representation_conditions.py', + 'quadratic_form__mass.py', + 'quadratic_form__mass__Conway_Sloane_masses.py', + 'quadratic_form__mass__Siegel_densities.py', + 'quadratic_form__neighbors.py', + 'quadratic_form__reduction_theory.py', + 'quadratic_form__siegel_product.py', + 'quadratic_form__split_local_covering.py', + 'quadratic_form__ternary_Tornaria.py', + 'quadratic_form__theta.py', + 'quadratic_form__variable_substitutions.py', + 'random_quadraticform.py', + 'special_values.py', + 'ternary_qf.py', + subdir: 'sage/quadratic_forms', +) + +extension_data = { + 'count_local_2' : files('count_local_2.pyx'), + 'quadratic_form__evaluate' : files('quadratic_form__evaluate.pyx'), + 'ternary' : files('ternary.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/quadratic_forms', + install: true, + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + +install_subdir('genera', install_dir: sage_install_dir / 'quadratic_forms') diff --git a/src/sage/quivers/meson.build b/src/sage/quivers/meson.build new file mode 100644 index 00000000000..cdefdce952b --- /dev/null +++ b/src/sage/quivers/meson.build @@ -0,0 +1,29 @@ +py.install_sources( + 'algebra.py', + 'algebra_elements.pxd', + 'all.py', + 'ar_quiver.py', + 'homspace.py', + 'morphism.py', + 'path_semigroup.py', + 'paths.pxd', + 'representation.py', + subdir: 'sage/quivers', +) + +extension_data = { + 'algebra_elements' : files('algebra_elements.pyx'), + 'paths' : files('paths.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/quivers', + install: true, + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py index c0f52dc7c30..b91d310954b 100644 --- a/src/sage/repl/interpreter.py +++ b/src/sage/repl/interpreter.py @@ -75,13 +75,14 @@ sage: from sage.repl.interpreter import get_test_shell sage: shell = get_test_shell() - sage: print("dummy line"); shell.run_cell('1/0') # see #25320 for the reason of the `...` and the dummy line in this test + sage: print("dummy line"); shell.run_cell('1/0') # known bug (meson doesn't include the Cython source code) # see #25320 for the reason of the `...` and the dummy line in this test dummy line ... ZeroDivisionError...Traceback (most recent call last) ... ----> 1 Integer(1)/Integer(0) - .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div... + ... + ...integer.pyx... in sage.rings.integer.Integer...div... ... -> ... raise ZeroDivisionError("rational division by zero") ....: x = Rational.__new__(Rational) diff --git a/src/sage/rings/bernmm/bern_rat.cpp b/src/sage/rings/bernmm/bern_rat.cpp index 963cb173524..1a1ad87b6c2 100644 --- a/src/sage/rings/bernmm/bern_rat.cpp +++ b/src/sage/rings/bernmm/bern_rat.cpp @@ -87,7 +87,7 @@ struct Item */ struct Item_cmp { - bool operator()(const Item* x, const Item* y) + bool operator()(const Item* x, const Item* y) const { return mpz_cmp(x->modulus, y->modulus) < 0; } @@ -331,9 +331,9 @@ void bern_rat(mpq_t res, long k, int num_threads) #ifdef USE_THREADS for (long i = 0; i < num_threads - 1; i++) pthread_join(threads[i], NULL); -#endif pthread_attr_destroy (&attr); +#endif // reconstruct B_k as a rational number Item* item = *(state.items.begin()); diff --git a/src/sage/rings/convert/meson.build b/src/sage/rings/convert/meson.build new file mode 100644 index 00000000000..0b485247bf1 --- /dev/null +++ b/src/sage/rings/convert/meson.build @@ -0,0 +1,15 @@ +py.install_sources('all.py', 'mpfi.pxd', subdir: 'sage/rings/convert') + +extension_data = {'mpfi' : files('mpfi.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/convert', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cypari2, gmp, gsl, mpfi, mpfr, pari], + ) +endforeach + diff --git a/src/sage/rings/finite_rings/meson.build b/src/sage/rings/finite_rings/meson.build new file mode 100644 index 00000000000..896d69651cf --- /dev/null +++ b/src/sage/rings/finite_rings/meson.build @@ -0,0 +1,81 @@ +py.install_sources( + 'all.py', + 'conway_polynomials.py', + 'element_base.pxd', + 'element_givaro.pxd', + 'element_ntl_gf2e.pxd', + 'element_pari_ffelt.pxd', + 'finite_field_base.pxd', + 'finite_field_constructor.py', + 'finite_field_givaro.py', + 'finite_field_ntl_gf2e.py', + 'finite_field_pari_ffelt.py', + 'finite_field_prime_modn.py', + 'galois_group.py', + 'hom_finite_field.pxd', + 'hom_finite_field_givaro.pxd', + 'hom_prime_finite_field.pxd', + 'homset.py', + 'integer_mod.pxd', + 'integer_mod_limits.h', + 'integer_mod_ring.py', + 'maps_finite_field.py', + 'residue_field.pxd', + 'stdint.pxd', + subdir: 'sage/rings/finite_rings', +) + +extension_data = { + 'element_base' : files('element_base.pyx'), + 'element_pari_ffelt' : files('element_pari_ffelt.pyx'), + 'finite_field_base' : files('finite_field_base.pyx'), + 'hom_finite_field' : files('hom_finite_field.pyx'), + 'hom_prime_finite_field' : files('hom_prime_finite_field.pyx'), + 'integer_mod' : files('integer_mod.pyx'), + 'residue_field' : files('residue_field.pyx'), + 'residue_field_givaro' : files('residue_field_givaro.pyx'), + 'residue_field_ntl_gf2e' : files('residue_field_ntl_gf2e.pyx'), + 'residue_field_pari_ffelt' : files('residue_field_pari_ffelt.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/finite_rings', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_ntl, + inc_rings, + inc_rings_finite, + ], + dependencies: [py_dep, cypari2, cysignals, givaro, gmp, m, ntl, pari], + ) +endforeach + +extension_data_cpp = { + 'element_givaro': files('element_givaro.pyx'), + 'element_ntl_gf2e': files('element_ntl_gf2e.pyx'), + 'hom_finite_field_givaro': files('hom_finite_field_givaro.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/finite_rings', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_ntl, + inc_rings, + inc_rings_finite, + ], + dependencies: [py_dep, cypari2, cysignals, givaro, gmp, m, ntl, pari], + ) +endforeach + diff --git a/src/sage/rings/function_field/meson.build b/src/sage/rings/function_field/meson.build new file mode 100644 index 00000000000..16e5fa6fa6f --- /dev/null +++ b/src/sage/rings/function_field/meson.build @@ -0,0 +1,55 @@ +py.install_sources( + 'all.py', + 'constructor.py', + 'derivations.py', + 'derivations_polymod.py', + 'derivations_rational.py', + 'differential.py', + 'divisor.py', + 'element.pxd', + 'extensions.py', + 'function_field.py', + 'function_field_polymod.py', + 'function_field_rational.py', + 'ideal.py', + 'ideal_polymod.py', + 'ideal_rational.py', + 'jacobian_base.py', + 'jacobian_hess.py', + 'jacobian_khuri_makdisi.py', + 'maps.py', + 'order.py', + 'order_basis.py', + 'order_polymod.py', + 'order_rational.py', + 'place.py', + 'place_polymod.py', + 'place_rational.py', + 'valuation.py', + 'valuation_ring.py', + subdir: 'sage/rings/function_field', +) + +extension_data = { + 'element' : files('element.pyx'), + 'element_polymod' : files('element_polymod.pyx'), + 'element_rational' : files('element_rational.pyx'), + 'hermite_form_polynomial' : files('hermite_form_polynomial.pyx'), + 'khuri_makdisi' : files('khuri_makdisi.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/function_field', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp], + ) +endforeach + +install_subdir( + 'drinfeld_modules', + install_dir: sage_install_dir / 'rings/function_field', +) diff --git a/src/sage/rings/meson.build b/src/sage/rings/meson.build new file mode 100644 index 00000000000..9aff2d7c8f3 --- /dev/null +++ b/src/sage/rings/meson.build @@ -0,0 +1,217 @@ +pthread = cc.find_library('pthread') + +py.install_sources( + 'abc.pxd', + 'algebraic_closure_finite_field.py', + 'all.py', + 'all__sagemath_categories.py', + 'all__sagemath_objects.py', + 'big_oh.py', + 'cc.py', + 'cfinite_sequence.py', + 'cif.py', + 'commutative_algebra.py', + 'complex_arb.pxd', + 'complex_conversion.pxd', + 'complex_double.pxd', + 'complex_interval.pxd', + 'complex_interval_field.py', + 'complex_mpc.pxd', + 'complex_mpfr.pxd', + 'continued_fraction.py', + 'continued_fraction_gosper.py', + 'derivation.py', + 'fast_arith.pxd', + 'fraction_field.py', + 'fraction_field_FpT.pxd', + 'generic.py', + 'homset.py', + 'ideal.py', + 'ideal_monoid.py', + 'imaginary_unit.py', + 'infinity.py', + 'integer.pxd', + 'integer.pyx', + 'integer_fake.h', + 'integer_fake.pxd', + 'integer_ring.pxd', + 'integer_ring.pyx', + 'laurent_series_ring.py', + 'laurent_series_ring_element.pxd', + 'lazy_series.py', + 'lazy_series_ring.py', + 'localization.py', + 'monomials.py', + 'morphism.pxd', + 'multi_power_series_ring.py', + 'multi_power_series_ring_element.py', + 'numbers_abc.py', + 'pari_ring.py', + 'power_series_mpoly.pxd', + 'power_series_pari.pxd', + 'power_series_poly.pxd', + 'power_series_ring.py', + 'power_series_ring_element.pxd', + 'puiseux_series_ring.py', + 'puiseux_series_ring_element.pxd', + 'qqbar.py', + 'qqbar_decorators.py', + 'quotient_ring.py', + 'quotient_ring_element.py', + 'rational.pxd', + 'rational.pyx', + 'rational_field.py', + 'real_arb.pxd', + 'real_double.pxd', + 'real_double_element_gsl.pxd', + 'real_field.py', + 'real_lazy.pxd', + 'real_mpfi.pxd', + 'real_mpfr.pxd', + 'ring.pxd', + 'ring_extension.pxd', + 'ring_extension_conversion.pxd', + 'ring_extension_element.pxd', + 'ring_extension_homset.py', + 'ring_extension_morphism.pxd', + 'sum_of_squares.pxd', + 'tate_algebra.py', + 'tate_algebra_element.pxd', + 'tate_algebra_ideal.pxd', + 'tests.py', + 'universal_cyclotomic_field.py', + subdir: 'sage/rings', +) + +extension_data = { + 'abc' : files('abc.pyx'), + 'complex_arb' : files('complex_arb.pyx'), + 'complex_conversion' : files('complex_conversion.pyx'), + 'complex_double' : files('complex_double.pyx'), + 'complex_interval' : files('complex_interval.pyx'), + 'complex_mpc' : files('complex_mpc.pyx'), + 'complex_mpfr' : files('complex_mpfr.pyx'), + 'factorint' : files('factorint.pyx'), + 'factorint_flint' : files('factorint_flint.pyx'), + 'factorint_pari' : files('factorint_pari.pyx'), + 'fast_arith' : files('fast_arith.pyx'), + 'fraction_field_element' : files('fraction_field_element.pyx'), + 'integer' : files('integer.pyx'), + 'integer_ring' : files('integer_ring.pyx'), + 'laurent_series_ring_element' : files('laurent_series_ring_element.pyx'), + 'morphism' : files('morphism.pyx'), + 'noncommutative_ideals' : files('noncommutative_ideals.pyx'), + 'power_series_mpoly' : files('power_series_mpoly.pyx'), + 'power_series_pari' : files('power_series_pari.pyx'), + 'power_series_poly' : files('power_series_poly.pyx'), + 'power_series_ring_element' : files('power_series_ring_element.pyx'), + 'puiseux_series_ring_element' : files('puiseux_series_ring_element.pyx'), + 'real_arb' : files('real_arb.pyx'), + 'real_double' : files('real_double.pyx'), + 'real_double_element_gsl' : files('real_double_element_gsl.pyx'), + 'real_interval_absolute' : files('real_interval_absolute.pyx'), + 'real_lazy' : files('real_lazy.pyx'), + 'real_mpfi' : files('real_mpfi.pyx'), + 'real_mpfr' : files('real_mpfr.pyx'), + 'ring' : files('ring.pyx'), + 'ring_extension' : files('ring_extension.pyx'), + 'ring_extension_conversion' : files('ring_extension_conversion.pyx'), + 'ring_extension_element' : files('ring_extension_element.pyx'), + 'ring_extension_morphism' : files('ring_extension_morphism.pyx'), + 'sum_of_squares' : files('sum_of_squares.pyx'), + 'tate_algebra_element' : files('tate_algebra_element.pyx'), + 'tate_algebra_ideal' : files('tate_algebra_ideal.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_gsl, + inc_ntl, + inc_rings, + inc_rings_finite, + ], + dependencies: [ + py_dep, + cypari2, + cysignals, + flint, + gmp, + gmpy2, + gsl, + m, + mpc, + mpfi, + mpfr, + ntl, + pari, + pthread, + ], + ) +endforeach + +extension_data_cpp = { + 'bernmm': files( + 'bernmm.pyx', + 'bernmm/bern_modp.cpp', + 'bernmm/bern_modp_util.cpp', + 'bernmm/bern_rat.cpp', + ), + 'bernoulli_mod_p': files('bernoulli_mod_p.pyx'), + 'fraction_field_FpT': files('fraction_field_FpT.pyx'), + 'rational': files('rational.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings', + install: true, + cpp_args: ['-DUSE_THREADS=1', '-DTHREAD_STACK_SIZE=4096'], + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_gsl, + inc_ntl, + inc_rings, + inc_rings_finite, + ], + dependencies: [ + py_dep, + cypari2, + cysignals, + flint, + gmp, + gmpy2, + gsl, + m, + mpc, + mpfi, + mpfr, + ntl, + pari, + pthread, + ], + ) +endforeach + +install_subdir('asymptotic', install_dir: sage_install_dir / 'rings') +subdir('convert') +subdir('finite_rings') +subdir('function_field') +install_subdir('invariants', install_dir: sage_install_dir / 'rings') +subdir('number_field') +subdir('padics') +subdir('polynomial') +subdir('semirings') +install_subdir('valuation', install_dir: sage_install_dir / 'rings') diff --git a/src/sage/rings/number_field/meson.build b/src/sage/rings/number_field/meson.build new file mode 100644 index 00000000000..077c1d918e6 --- /dev/null +++ b/src/sage/rings/number_field/meson.build @@ -0,0 +1,66 @@ +py.install_sources( + 'S_unit_solver.py', + 'all.py', + 'bdd_height.py', + 'class_group.py', + 'galois_group.py', + 'homset.py', + 'maps.py', + 'morphism.py', + 'number_field.py', + 'number_field_base.pxd', + 'number_field_element.pxd', + 'number_field_element_base.pxd', + 'number_field_element_quadratic.pxd', + 'number_field_ideal.py', + 'number_field_ideal_rel.py', + 'number_field_rel.py', + 'order.py', + 'order_ideal.py', + 'selmer_group.py', + 'small_primes_of_degree_one.py', + 'splitting_field.py', + 'structure.py', + 'totallyreal_data.pxd', + 'totallyreal_phc.py', + 'totallyreal_rel.py', + 'unit_group.py', + subdir: 'sage/rings/number_field', +) + +extension_data = { + 'number_field_base' : files('number_field_base.pyx'), + 'number_field_element_base' : files('number_field_element_base.pyx'), + 'number_field_morphisms' : files('number_field_morphisms.pyx'), + 'totallyreal' : files('totallyreal.pyx'), + 'totallyreal_data' : files('totallyreal_data.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/number_field', + install: true, + include_directories: [inc_cpython, inc_ext, inc_flint, inc_ntl, inc_rings], + dependencies: [py_dep, cypari2, cysignals, flint, gmp, mpfi, mpfr, ntl], + ) +endforeach + +extension_data_cpp = { + 'number_field_element': files('number_field_element.pyx'), + 'number_field_element_quadratic': files('number_field_element_quadratic.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/number_field', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ext, inc_flint, inc_ntl, inc_rings], + dependencies: [py_dep, cypari2, cysignals, flint, gmp, mpfi, mpfr, ntl], + ) +endforeach + diff --git a/src/sage/rings/padics/meson.build b/src/sage/rings/padics/meson.build new file mode 100644 index 00000000000..9cb64492095 --- /dev/null +++ b/src/sage/rings/padics/meson.build @@ -0,0 +1,123 @@ +py.install_sources( + 'all.py', + 'common_conversion.pxd', + 'eisenstein_extension_generic.py', + 'factory.py', + 'generic_nodes.py', + 'lattice_precision.py', + 'local_generic.py', + 'local_generic_element.pxd', + 'misc.py', + 'morphism.pxd', + 'padic_ZZ_pX_CA_element.pxd', + 'padic_ZZ_pX_CR_element.pxd', + 'padic_ZZ_pX_FM_element.pxd', + 'padic_ZZ_pX_element.pxd', + 'padic_base_generic.py', + 'padic_base_leaves.py', + 'padic_capped_absolute_element.pxd', + 'padic_capped_relative_element.pxd', + 'padic_ext_element.pxd', + 'padic_extension_generic.py', + 'padic_extension_leaves.py', + 'padic_fixed_mod_element.pxd', + 'padic_floating_point_element.pxd', + 'padic_generic.py', + 'padic_generic_element.pxd', + 'padic_lattice_element.py', + 'padic_printing.pxd', + 'padic_relaxed_element.pxd', + 'padic_relaxed_errors.pxd', + 'padic_valuation.py', + 'pow_computer.pxd', + 'pow_computer_ext.pxd', + 'pow_computer_flint.pxd', + 'pow_computer_relative.pxd', + 'precision_error.py', + 'qadic_flint_CA.pxd', + 'qadic_flint_CR.pxd', + 'qadic_flint_FM.pxd', + 'qadic_flint_FP.pxd', + 'relative_extension_leaves.py', + 'relative_ramified_CA.pxd', + 'relative_ramified_CR.pxd', + 'relative_ramified_FM.pxd', + 'relative_ramified_FP.pxd', + 'tests.py', + 'tutorial.py', + 'unramified_extension_generic.py', + subdir: 'sage/rings/padics', +) + +extension_data = { + 'common_conversion' : files('common_conversion.pyx'), + 'local_generic_element' : files('local_generic_element.pyx'), + 'morphism' : files('morphism.pyx'), + 'padic_capped_absolute_element' : files('padic_capped_absolute_element.pyx'), + 'padic_capped_relative_element' : files('padic_capped_relative_element.pyx'), + 'padic_fixed_mod_element' : files('padic_fixed_mod_element.pyx'), + 'padic_floating_point_element' : files('padic_floating_point_element.pyx'), + 'padic_generic_element' : files('padic_generic_element.pyx'), + 'padic_relaxed_element' : files('padic_relaxed_element.pyx'), + 'padic_relaxed_errors' : files('padic_relaxed_errors.pyx'), + 'qadic_flint_CA' : files('qadic_flint_CA.pyx'), + 'qadic_flint_CR' : files('qadic_flint_CR.pyx'), + 'qadic_flint_FM' : files('qadic_flint_FM.pyx'), + 'qadic_flint_FP' : files('qadic_flint_FP.pyx'), + 'relative_ramified_CA' : files('relative_ramified_CA.pyx'), + 'relative_ramified_CR' : files('relative_ramified_CR.pyx'), + 'relative_ramified_FM' : files('relative_ramified_FM.pyx'), + 'relative_ramified_FP' : files('relative_ramified_FP.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/padics', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_ntl, + inc_rings, + inc_rings_finite, + inc_src, + ], + dependencies: [py_dep, cypari2, cysignals, flint, gmp, m, ntl], + ) +endforeach + +extension_data_cpp = { + 'padic_ZZ_pX_CA_element': files('padic_ZZ_pX_CA_element.pyx'), + 'padic_ZZ_pX_CR_element': files('padic_ZZ_pX_CR_element.pyx'), + 'padic_ZZ_pX_FM_element': files('padic_ZZ_pX_FM_element.pyx'), + 'padic_ZZ_pX_element': files('padic_ZZ_pX_element.pyx'), + 'padic_ext_element': files('padic_ext_element.pyx'), + 'padic_printing': files('padic_printing.pyx'), + 'pow_computer': files('pow_computer.pyx'), + 'pow_computer_ext': files('pow_computer_ext.pyx'), + 'pow_computer_flint': files('pow_computer_flint.pyx'), + 'pow_computer_relative': files('pow_computer_relative.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/padics', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_ntl, + inc_rings, + inc_rings_finite, + ], + dependencies: [py_dep, cypari2, cysignals, flint, gmp, m, ntl], + ) +endforeach + diff --git a/src/sage/rings/polynomial/meson.build b/src/sage/rings/polynomial/meson.build new file mode 100644 index 00000000000..c1625c5eb94 --- /dev/null +++ b/src/sage/rings/polynomial/meson.build @@ -0,0 +1,174 @@ +py.install_sources( + 'all.py', + 'binary_form_reduce.py', + 'commutative_polynomial.pxd', + 'complex_roots.py', + 'convolution.py', + 'evaluation.pxd', + 'evaluation_flint.pxd', + 'evaluation_ntl.pxd', + 'flatten.py', + 'groebner_fan.py', + 'ideal.py', + 'infinite_polynomial_element.py', + 'infinite_polynomial_ring.py', + 'integer_valued_polynomials.py', + 'laurent_polynomial.pxd', + 'laurent_polynomial_ideal.py', + 'laurent_polynomial_mpair.pxd', + 'laurent_polynomial_ring.py', + 'laurent_polynomial_ring_base.py', + 'msolve.py', + 'multi_polynomial.pxd', + 'multi_polynomial_element.py', + 'multi_polynomial_ideal.py', + 'multi_polynomial_ideal_libsingular.pxd', + 'multi_polynomial_libsingular.pxd', + 'multi_polynomial_ring.py', + 'multi_polynomial_ring_base.pxd', + 'multi_polynomial_sequence.py', + 'omega.py', + 'ore_function_element.py', + 'ore_function_field.py', + 'ore_polynomial_element.pxd', + 'ore_polynomial_ring.py', + 'plural.pxd', + 'polydict.pxd', + 'polynomial_compiled.pxd', + 'polynomial_complex_arb.pxd', + 'polynomial_element.pxd', + 'polynomial_element_generic.py', + 'polynomial_fateman.py', + 'polynomial_gf2x.pxd', + 'polynomial_integer_dense_flint.pxd', + 'polynomial_integer_dense_ntl.pxd', + 'polynomial_modn_dense_ntl.pxd', + 'polynomial_quotient_ring.py', + 'polynomial_quotient_ring_element.py', + 'polynomial_rational_flint.pxd', + 'polynomial_ring.py', + 'polynomial_ring_constructor.py', + 'polynomial_ring_homomorphism.pxd', + 'polynomial_singular_interface.py', + 'polynomial_zmod_flint.pxd', + 'polynomial_zz_pex.pxd', + 'real_roots.pxd', + 'skew_polynomial_element.pxd', + 'skew_polynomial_finite_field.pxd', + 'skew_polynomial_finite_order.pxd', + 'skew_polynomial_ring.py', + 'symmetric_ideal.py', + 'symmetric_reduction.pxd', + 'term_order.py', + 'toy_buchberger.py', + 'toy_d_basis.py', + 'toy_variety.py', + subdir: 'sage/rings/polynomial', +) + +extension_data = { + 'commutative_polynomial' : files('commutative_polynomial.pyx'), + 'cyclotomic' : files('cyclotomic.pyx'), + 'evaluation_flint' : files('evaluation_flint.pyx'), + 'hilbert' : files('hilbert.pyx'), + 'laurent_polynomial' : files('laurent_polynomial.pyx'), + 'laurent_polynomial_mpair' : files('laurent_polynomial_mpair.pyx'), + 'multi_polynomial' : files('multi_polynomial.pyx'), + 'multi_polynomial_ring_base' : files('multi_polynomial_ring_base.pyx'), + 'ore_polynomial_element' : files('ore_polynomial_element.pyx'), + 'polydict' : files('polydict.pyx'), + 'polynomial_compiled' : files('polynomial_compiled.pyx'), + 'polynomial_complex_arb' : files('polynomial_complex_arb.pyx'), + 'polynomial_element' : files('polynomial_element.pyx'), + 'polynomial_number_field' : files('polynomial_number_field.pyx'), + 'polynomial_real_mpfr_dense' : files('polynomial_real_mpfr_dense.pyx'), + 'polynomial_ring_homomorphism' : files('polynomial_ring_homomorphism.pyx'), + 'real_roots' : files('real_roots.pyx'), + 'refine_root' : files('refine_root.pyx'), + 'skew_polynomial_element' : files('skew_polynomial_element.pyx'), + 'skew_polynomial_finite_field' : files('skew_polynomial_finite_field.pyx'), + 'skew_polynomial_finite_order' : files('skew_polynomial_finite_order.pyx'), + 'symmetric_reduction' : files('symmetric_reduction.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/polynomial', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_ntl, + inc_numpy, + inc_rings, + inc_rings_finite, + ], + dependencies: [ + py_dep, + cypari2, + cysignals, + flint, + givaro, + gmp, + mpfi, + mpfr, + ntl, + pari, + ], + ) +endforeach + +extension_data_cpp = { + 'evaluation_ntl': files('evaluation_ntl.pyx'), + 'multi_polynomial_ideal_libsingular': files( + 'multi_polynomial_ideal_libsingular.pyx', + ), + 'multi_polynomial_libsingular': files('multi_polynomial_libsingular.pyx'), + 'plural': files('plural.pyx'), + 'polynomial_gf2x': files('polynomial_gf2x.pyx'), + 'polynomial_integer_dense_flint': files('polynomial_integer_dense_flint.pyx'), + 'polynomial_integer_dense_ntl': files('polynomial_integer_dense_ntl.pyx'), + 'polynomial_modn_dense_ntl': files('polynomial_modn_dense_ntl.pyx'), + 'polynomial_rational_flint': files('polynomial_rational_flint.pyx'), + 'polynomial_zmod_flint': files('polynomial_zmod_flint.pyx'), + 'polynomial_zz_pex': files('polynomial_zz_pex.pyx'), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/polynomial', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_flint, + inc_ntl, + inc_numpy, + inc_rings, + inc_rings_finite, + ], + dependencies: [ + py_dep, + cypari2, + cysignals, + flint, + givaro, + gmp, + mpfi, + mpfr, + ntl, + pari, + singular, + ], + ) +endforeach + +install_subdir('padics', install_dir: sage_install_dir / 'rings/polynomial') +subdir('pbori') +subdir('weil') diff --git a/src/sage/rings/polynomial/pbori/meson.build b/src/sage/rings/polynomial/pbori/meson.build new file mode 100644 index 00000000000..c7541ae492d --- /dev/null +++ b/src/sage/rings/polynomial/pbori/meson.build @@ -0,0 +1,42 @@ +brial = cc.find_library('brial', required: false, disabler: true) +# Cannot be found via pkg-config +brial_groebner = cc.find_library('brial_groebner') + +py.install_sources( + 'PyPolyBoRi.py', + '__init__.py', + 'blocks.py', + 'cnf.py', + 'easy_polynomials.py', + 'fglm.py', + 'frontend.py', + 'gbcore.py', + 'gbrefs.py', + 'heuristics.py', + 'interpolate.py', + 'interred.py', + 'll.py', + 'nf.py', + 'parallel.py', + 'pbori.pxd', + 'randompoly.py', + 'rank.py', + 'specialsets.py', + 'statistics.py', + subdir: 'sage/rings/polynomial/pbori', +) + +extension_data_cpp = {'pbori': files('pbori.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/polynomial/pbori', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_ext, inc_rings, inc_src], + dependencies: [py_dep, brial, brial_groebner, cysignals, gmp, m4ri, png], + ) +endforeach + diff --git a/src/sage/rings/polynomial/weil/meson.build b/src/sage/rings/polynomial/weil/meson.build new file mode 100644 index 00000000000..2c9bd006919 --- /dev/null +++ b/src/sage/rings/polynomial/weil/meson.build @@ -0,0 +1,19 @@ +py.install_sources( + 'all.py', + 'power_sums.h', + subdir: 'sage/rings/polynomial/weil', +) + +extension_data = {'weil_polynomials' : files('weil_polynomials.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/polynomial/weil', + install: true, + include_directories: [inc_cpython, inc_flint, inc_rings, inc_src], + dependencies: [py_dep, cysignals, flint, gmp], + ) +endforeach + diff --git a/src/sage/rings/semirings/meson.build b/src/sage/rings/semirings/meson.build new file mode 100644 index 00000000000..e1e4e627ba3 --- /dev/null +++ b/src/sage/rings/semirings/meson.build @@ -0,0 +1,22 @@ +py.install_sources( + 'all.py', + 'non_negative_integer_semiring.py', + 'tropical_mpolynomial.py', + 'tropical_polynomial.py', + 'tropical_variety.py', + subdir: 'sage/rings/semirings', +) + +extension_data = {'tropical_semiring' : files('tropical_semiring.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/rings/semirings', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/sat/meson.build b/src/sage/sat/meson.build new file mode 100644 index 00000000000..a1a0246dfce --- /dev/null +++ b/src/sage/sat/meson.build @@ -0,0 +1,4 @@ +py.install_sources('all.py', 'boolean_polynomials.py', subdir: 'sage/sat') + +install_subdir('converters', install_dir: sage_install_dir / 'sat') +subdir('solvers') diff --git a/src/sage/sat/solvers/meson.build b/src/sage/sat/solvers/meson.build new file mode 100644 index 00000000000..86657c5c854 --- /dev/null +++ b/src/sage/sat/solvers/meson.build @@ -0,0 +1,23 @@ +py.install_sources( + '__init__.py', + 'cryptominisat.py', + 'dimacs.py', + 'picosat.py', + 'sat_lp.py', + 'satsolver.pxd', + subdir: 'sage/sat/solvers', +) + +extension_data = {'satsolver' : files('satsolver.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/sat/solvers', + install: true, + include_directories: [], + dependencies: [py_dep, gmp], + ) +endforeach + diff --git a/src/sage/schemes/elliptic_curves/meson.build b/src/sage/schemes/elliptic_curves/meson.build new file mode 100644 index 00000000000..3448c5d1c0a --- /dev/null +++ b/src/sage/schemes/elliptic_curves/meson.build @@ -0,0 +1,71 @@ +py.install_sources( + 'BSD.py', + 'Qcurves.py', + 'all.py', + 'cardinality.py', + 'cm.py', + 'constructor.py', + 'ec_database.py', + 'ell_curve_isogeny.py', + 'ell_egros.py', + 'ell_field.py', + 'ell_finite_field.py', + 'ell_generic.py', + 'ell_local_data.py', + 'ell_modular_symbols.py', + 'ell_number_field.py', + 'ell_padic_field.py', + 'ell_point.py', + 'ell_rational_field.py', + 'ell_tate_curve.py', + 'ell_torsion.py', + 'ell_wp.py', + 'formal_group.py', + 'gal_reps.py', + 'gal_reps_number_field.py', + 'gp_simon.py', + 'heegner.py', + 'height.py', + 'hom.py', + 'hom_composite.py', + 'hom_frobenius.py', + 'hom_scalar.py', + 'hom_sum.py', + 'hom_velusqrt.py', + 'homset.py', + 'isogeny_class.py', + 'isogeny_small_degree.py', + 'jacobian.py', + 'kodaira_symbol.py', + 'kraus.py', + 'lseries_ell.py', + 'mod5family.py', + 'mod_poly.py', + 'modular_parametrization.py', + 'padic_lseries.py', + 'padics.py', + 'period_lattice.py', + 'saturation.py', + 'sha_tate.py', + 'weierstrass_morphism.py', + 'weierstrass_transform.py', + subdir: 'sage/schemes/elliptic_curves', +) + +extension_data = { + 'descent_two_isogeny' : files('descent_two_isogeny.pyx'), + 'mod_sym_num' : files('mod_sym_num.pyx'), + 'period_lattice_region' : files('period_lattice_region.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/schemes/elliptic_curves', + install: true, + include_directories: [inc_cpython, inc_flint, inc_numpy, inc_rings], + dependencies: [py_dep, cypari2, cysignals, flint, gmp, mpfr, pari], + ) +endforeach + diff --git a/src/sage/schemes/hyperelliptic_curves/meson.build b/src/sage/schemes/hyperelliptic_curves/meson.build new file mode 100644 index 00000000000..e4b017d4192 --- /dev/null +++ b/src/sage/schemes/hyperelliptic_curves/meson.build @@ -0,0 +1,48 @@ +inc_hypellfrob = include_directories('hypellfrob') +py.install_sources( + 'all.py', + 'constructor.py', + 'hyperelliptic_finite_field.py', + 'hyperelliptic_g2.py', + 'hyperelliptic_generic.py', + 'hyperelliptic_padic_field.py', + 'hyperelliptic_rational_field.py', + 'invariants.py', + 'jacobian_endomorphism_utils.py', + 'jacobian_g2.py', + 'jacobian_generic.py', + 'jacobian_homset.py', + 'jacobian_morphism.py', + 'kummer_surface.py', + 'mestre.py', + 'monsky_washnitzer.py', + subdir: 'sage/schemes/hyperelliptic_curves', +) + +extension_data_cpp = { + 'hypellfrob': files( + 'hypellfrob.pyx', + 'hypellfrob/hypellfrob.cpp', + 'hypellfrob/recurrences_ntl.cpp', + ), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/schemes/hyperelliptic_curves', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [ + inc_cpython, + inc_ext, + inc_ntl, + inc_rings, + inc_rings_finite, + inc_hypellfrob, + ], + dependencies: [py_dep, cysignals, gmp, ntl], + ) +endforeach + diff --git a/src/sage/schemes/meson.build b/src/sage/schemes/meson.build new file mode 100644 index 00000000000..c74c532b930 --- /dev/null +++ b/src/sage/schemes/meson.build @@ -0,0 +1,16 @@ +py.install_sources('all.py', 'overview.py', subdir: 'sage/schemes') + +install_subdir('affine', install_dir: sage_install_dir / 'schemes') +install_subdir('berkovich', install_dir: sage_install_dir / 'schemes') +install_subdir('curves', install_dir: sage_install_dir / 'schemes') +install_subdir('cyclic_covers', install_dir: sage_install_dir / 'schemes') +subdir('elliptic_curves') +install_subdir('generic', install_dir: sage_install_dir / 'schemes') +subdir('hyperelliptic_curves') +install_subdir('jacobians', install_dir: sage_install_dir / 'schemes') +install_subdir('plane_conics', install_dir: sage_install_dir / 'schemes') +install_subdir('plane_quartics', install_dir: sage_install_dir / 'schemes') +install_subdir('product_projective', install_dir: sage_install_dir / 'schemes') +install_subdir('projective', install_dir: sage_install_dir / 'schemes') +install_subdir('riemann_surfaces', install_dir: sage_install_dir / 'schemes') +subdir('toric') diff --git a/src/sage/schemes/toric/meson.build b/src/sage/schemes/toric/meson.build new file mode 100644 index 00000000000..d9dea45fcc8 --- /dev/null +++ b/src/sage/schemes/toric/meson.build @@ -0,0 +1,32 @@ +py.install_sources( + 'all.py', + 'chow_group.py', + 'divisor.py', + 'fano_variety.py', + 'homset.py', + 'ideal.py', + 'library.py', + 'morphism.py', + 'points.py', + 'toric_subscheme.py', + 'variety.py', + 'weierstrass.py', + 'weierstrass_covering.py', + 'weierstrass_higher.py', + subdir: 'sage/schemes/toric', +) + +extension_data = {'divisor_class' : files('divisor_class.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/schemes/toric', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, gmp], + ) +endforeach + +install_subdir('sheaf', install_dir: sage_install_dir / 'schemes/toric') diff --git a/src/sage/sets/meson.build b/src/sage/sets/meson.build new file mode 100644 index 00000000000..73faddaf9c7 --- /dev/null +++ b/src/sage/sets/meson.build @@ -0,0 +1,44 @@ +py.install_sources( + 'all.py', + 'all__sagemath_objects.py', + 'cartesian_product.py', + 'condition_set.py', + 'disjoint_set.pxd', + 'disjoint_union_enumerated_sets.py', + 'family.pxd', + 'finite_enumerated_set.py', + 'finite_set_map_cy.pxd', + 'finite_set_maps.py', + 'image_set.py', + 'integer_range.py', + 'non_negative_integers.py', + 'positive_integers.py', + 'primes.py', + 'pythonclass.pxd', + 'real_set.py', + 'recursively_enumerated_set.pxd', + 'set.py', + 'set_from_iterator.py', + 'totally_ordered_finite_set.py', + subdir: 'sage/sets', +) + +extension_data = { + 'disjoint_set' : files('disjoint_set.pyx'), + 'family' : files('family.pyx'), + 'finite_set_map_cy' : files('finite_set_map_cy.pyx'), + 'pythonclass' : files('pythonclass.pyx'), + 'recursively_enumerated_set' : files('recursively_enumerated_set.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/sets', + install: true, + include_directories: [inc_cpython, inc_data_structures], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/stats/distributions/meson.build b/src/sage/stats/distributions/meson.build new file mode 100644 index 00000000000..129d5f74d13 --- /dev/null +++ b/src/sage/stats/distributions/meson.build @@ -0,0 +1,31 @@ +py.install_sources( + 'all.py', + 'catalog.py', + 'dgs.pxd', + 'discrete_gaussian_integer.pxd', + 'discrete_gaussian_lattice.py', + 'discrete_gaussian_polynomial.py', + subdir: 'sage/stats/distributions', +) + +extension_data = { + 'discrete_gaussian_integer' : files( + 'dgs_bern.c', + 'dgs_gauss_dp.c', + 'dgs_gauss_mp.c', + 'discrete_gaussian_integer.pyx', + ), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + c_args: ['-D_XOPEN_SOURCE=600'], + subdir: 'sage/stats/distributions', + install: true, + include_directories: [inc_cpython, inc_rings, inc_src], + dependencies: [py_dep, cypari2, cysignals, gmp, mpfr], + ) +endforeach + diff --git a/src/sage/stats/hmm/meson.build b/src/sage/stats/hmm/meson.build new file mode 100644 index 00000000000..cbf4a30caa5 --- /dev/null +++ b/src/sage/stats/hmm/meson.build @@ -0,0 +1,26 @@ +py.install_sources( + 'all.py', + 'distributions.pxd', + 'hmm.pxd', + 'util.pxd', + subdir: 'sage/stats/hmm', +) + +extension_data = { + 'chmm' : files('chmm.pyx'), + 'distributions' : files('distributions.pyx'), + 'hmm' : files('hmm.pyx'), + 'util' : files('util.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/stats/hmm', + install: true, + include_directories: [], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + diff --git a/src/sage/stats/meson.build b/src/sage/stats/meson.build new file mode 100644 index 00000000000..414a909270c --- /dev/null +++ b/src/sage/stats/meson.build @@ -0,0 +1,27 @@ +py.install_sources( + 'all.py', + 'basic_stats.py', + 'intlist.pxd', + 'r.py', + 'time_series.pxd', + subdir: 'sage/stats', +) + +extension_data = { + 'intlist' : files('intlist.pyx'), + 'time_series' : files('time_series.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/stats', + install: true, + include_directories: [inc_cpython, inc_numpy], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +subdir('distributions') +subdir('hmm') diff --git a/src/sage/structure/__init__.py b/src/sage/structure/__init__.py index bf977ccc379..2534e5a71f8 100644 --- a/src/sage/structure/__init__.py +++ b/src/sage/structure/__init__.py @@ -1,3 +1,3 @@ # sage_setup: distribution = sagemath-objects # Resolve a cyclic import -import sage.structure.element +import sage.structure.element \ No newline at end of file diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index cc15eff82e9..7ee41f74a04 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -685,7 +685,7 @@ cdef class CoercionModel: sage: cm.record_exceptions() sage: cm._test_exception_stack() sage: cm.exception_stack() - ['Traceback (most recent call last):\n File "sage/structure/coerce.pyx", line ...TypeError: just a test'] + ['Traceback (most recent call last):\n File "...coerce.pyx", line ...TypeError: just a test'] sage: cm.record_exceptions(False) sage: cm._test_exception_stack() sage: cm.exception_stack() @@ -713,7 +713,7 @@ cdef class CoercionModel: [] sage: cm._test_exception_stack() sage: cm.exception_stack() - ['Traceback (most recent call last):\n File "sage/structure/coerce.pyx", line ...TypeError: just a test'] + ['Traceback (most recent call last):\n File "...coerce.pyx", line ...TypeError: just a test'] The function _test_exception_stack is executing the following code:: @@ -743,7 +743,7 @@ cdef class CoercionModel: [] sage: cm._test_exception_stack() sage: cm.exception_stack() - ['Traceback (most recent call last):\n File "sage/structure/coerce.pyx", line ...TypeError: just a test'] + ['Traceback (most recent call last):\n File "...coerce.pyx", line ...TypeError: just a test'] """ try: raise TypeError("just a test") diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index 5f1db5de82b..18a58f46103 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -2719,7 +2719,7 @@ cdef class RingElement(ModuleElement): Exponent overflow should throw an :exc:`OverflowError` (:issue:`2956`):: sage: K. = AA[] # needs sage.rings.number_field - sage: x^(2^64 + 12345) # needs sage.rings.number_field + sage: x^(2^64 + 12345) # known bug: macos # needs sage.rings.number_field Traceback (most recent call last): ... OverflowError: exponent overflow (2147483648) diff --git a/src/sage/structure/meson.build b/src/sage/structure/meson.build new file mode 100644 index 00000000000..6f4c75d58a4 --- /dev/null +++ b/src/sage/structure/meson.build @@ -0,0 +1,73 @@ +py.install_sources( + '__init__.py', + 'all.py', + 'category_object.pxd', + 'coerce.pxd', + 'coerce_actions.pxd', + 'coerce_dict.pxd', + 'coerce_exceptions.py', + 'coerce_maps.pxd', + 'debug_options.pxd', + 'dynamic_class.py', + 'element.pxd', + 'element_wrapper.pxd', + 'factorization.py', + 'factorization_integer.py', + 'formal_sum.py', + 'gens_py.py', + 'global_options.py', + 'indexed_generators.py', + 'list_clone.pxd', + 'list_clone_timings.py', + 'mutability.pxd', + 'nonexact.py', + 'parent.pxd', + 'parent_base.pxd', + 'parent_gens.pxd', + 'parent_old.pxd', + 'richcmp.pxd', + 'sage_object.pxd', + 'sage_object_test.py', + 'sequence.py', + 'set_factories.py', + 'set_factories_example.py', + 'support_view.py', + 'test_factory.py', + 'unique_representation.py', + subdir: 'sage/structure', +) + +extension_data = { + 'category_object' : files('category_object.pyx'), + 'coerce' : files('coerce.pyx'), + 'coerce_actions' : files('coerce_actions.pyx'), + 'coerce_dict' : files('coerce_dict.pyx'), + 'coerce_maps' : files('coerce_maps.pyx'), + 'debug_options' : files('debug_options.pyx'), + 'element' : files('element.pyx'), + 'element_wrapper' : files('element_wrapper.pyx'), + 'factory' : files('factory.pyx'), + 'list_clone' : files('list_clone.pyx'), + 'list_clone_demo' : files('list_clone_demo.pyx'), + 'list_clone_timings_cy' : files('list_clone_timings_cy.pyx'), + 'mutability' : files('mutability.pyx'), + 'parent' : files('parent.pyx'), + 'parent_base' : files('parent_base.pyx'), + 'parent_gens' : files('parent_gens.pyx'), + 'parent_old' : files('parent_old.pyx'), + 'richcmp' : files('richcmp.pyx'), + 'sage_object' : files('sage_object.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/structure', + install: true, + include_directories: [inc_cpython, inc_ext, inc_rings], + dependencies: [py_dep, cysignals, gmp, gmpy2, mpc, mpfr], + ) +endforeach + +install_subdir('proof', install_dir: sage_install_dir / 'structure') diff --git a/src/sage/symbolic/meson.build b/src/sage/symbolic/meson.build new file mode 100644 index 00000000000..a9ca57ebf43 --- /dev/null +++ b/src/sage/symbolic/meson.build @@ -0,0 +1,152 @@ +inc_ginac = include_directories('ginac') +inc_pynac = include_directories('.') + +py.install_sources( + 'all.py', + 'assumptions.py', + 'benchmark.py', + 'callable.py', + 'complexity_measures.py', + 'constants.py', + 'expression.pxd', + 'expression_conversion_algebraic.py', + 'expression_conversion_sympy.py', + 'expression_conversions.py', + 'function.pxd', + 'function_factory.py', + 'maxima_wrapper.py', + 'operators.py', + 'pynac_wrap.h', + 'random_tests.py', + 'relation.py', + 'ring.pxd', + 'subring.py', + 'symbols.py', + 'symengine.py', + 'tests.py', + 'units.py', + subdir: 'sage/symbolic', +) + +extension_data = { + 'function' : files('function.pyx'), + 'ring' : files('ring.pyx'), +} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/symbolic', + install: true, + include_directories: [ + inc_cpython, + inc_ext, + inc_ginac, + inc_gsl, + inc_pynac, + inc_rings, + ], + dependencies: [ + py_dep, + cypari2, + cysignals, + flint, + gmp, + gsl, + mpfr, + pari, + singular, + ], + ) +endforeach + +extension_data_cpp = { + 'expression': files( + 'expression.pyx', + 'ginac/add.cpp', + 'ginac/archive.cpp', + 'ginac/assume.cpp', + 'ginac/basic.cpp', + 'ginac/cmatcher.cpp', + 'ginac/constant.cpp', + 'ginac/context.cpp', + 'ginac/ex.cpp', + 'ginac/expair.cpp', + 'ginac/expairseq.cpp', + 'ginac/exprseq.cpp', + 'ginac/fderivative.cpp', + 'ginac/function.cpp', + 'ginac/function_info.cpp', + 'ginac/infinity.cpp', + 'ginac/infoflagbase.cpp', + 'ginac/inifcns.cpp', + 'ginac/inifcns_comb.cpp', + 'ginac/inifcns_gamma.cpp', + 'ginac/inifcns_hyperb.cpp', + 'ginac/inifcns_hyperg.cpp', + 'ginac/inifcns_nstdsums.cpp', + 'ginac/inifcns_orthopoly.cpp', + 'ginac/inifcns_trans.cpp', + 'ginac/inifcns_trig.cpp', + 'ginac/inifcns_zeta.cpp', + 'ginac/lst.cpp', + 'ginac/matrix.cpp', + 'ginac/mpoly-ginac.cpp', + 'ginac/mpoly-singular.cpp', + 'ginac/mpoly.cpp', + 'ginac/mul.cpp', + 'ginac/normal.cpp', + 'ginac/numeric.cpp', + 'ginac/operators.cpp', + 'ginac/order.cpp', + 'ginac/power.cpp', + 'ginac/print.cpp', + 'ginac/pseries.cpp', + 'ginac/py_funcs.cpp', + 'ginac/registrar.cpp', + 'ginac/relational.cpp', + 'ginac/remember.cpp', + 'ginac/sum.cpp', + 'ginac/symbol.cpp', + 'ginac/templates.cpp', + 'ginac/upoly-ginac.cpp', + 'ginac/useries.cpp', + 'ginac/utils.cpp', + 'ginac/wildcard.cpp', + ), +} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/symbolic', + install: true, + override_options: ['cython_language=cpp'], + cpp_args: '-std=c++11', + include_directories: [ + inc_cpython, + inc_ext, + inc_ginac, + inc_gsl, + inc_pynac, + inc_rings, + include_directories('../libs/gmp'), + ], + dependencies: [ + py_dep, + cypari2, + cysignals, + gmp, + flint, + gsl, + m, + mpfr, + pari, + singular, + ], + ) +endforeach + +install_subdir('integration', install_dir: sage_install_dir / 'symbolic') diff --git a/src/sage/tests/books/__init__.py b/src/sage/tests/books/__init__.py index e69de29bb2d..1b10e244496 100644 --- a/src/sage/tests/books/__init__.py +++ b/src/sage/tests/books/__init__.py @@ -0,0 +1 @@ +# Here so that cython creates the correct module name diff --git a/src/sage/tests/meson.build b/src/sage/tests/meson.build new file mode 100644 index 00000000000..4592d9d9d4e --- /dev/null +++ b/src/sage/tests/meson.build @@ -0,0 +1,54 @@ +py.install_sources( + '__init__.py', + 'all.py', + 'article_heuberger_krenn_kropf_fsm-in-sage.py', + 'arxiv_0812_2725.py', + 'benchmark.py', + 'book_schilling_zabrocki_kschur_primer.py', + 'book_stein_ent.py', + 'book_stein_modform.py', + 'cmdline.py', + 'combinatorial_hopf_algebras.py', + 'finite_poset.py', + 'functools_partial_src.py', + 'gosper-sum.py', + 'lazy_imports.py', + 'modular_group_cohomology.py', + 'numpy.py', + 'parigp.py', + 'startup.py', + 'symbolic-series.py', + 'sympy.py', + 'test_deprecation.py', + subdir: 'sage/tests', +) + +extension_data = {'cython' : files('cython.pyx')} + +foreach name, pyx : extension_data + py.extension_module( + name, + sources: pyx, + subdir: 'sage/tests', + install: true, + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +extension_data_cpp = {'stl_vector': files('stl_vector.pyx')} + +foreach name, pyx : extension_data_cpp + py.extension_module( + name, + sources: pyx, + subdir: 'sage/tests', + install: true, + override_options: ['cython_language=cpp'], + include_directories: [inc_cpython, inc_rings], + dependencies: [py_dep, cysignals, gmp], + ) +endforeach + +install_subdir('books', install_dir: sage_install_dir / 'tests') +install_subdir('memcheck', install_dir: sage_install_dir / 'tests') diff --git a/src/sage_setup/autogen/__init__.py b/src/sage_setup/autogen/__init__.py index 380983c06c7..2ec85acde21 100644 --- a/src/sage_setup/autogen/__init__.py +++ b/src/sage_setup/autogen/__init__.py @@ -1,6 +1,6 @@ import os -from . import interpreters +from sage_setup.autogen.interpreters.internal import rebuild def autogen_all(): @@ -11,6 +11,7 @@ def autogen_all(): of packages built/installed by setup.py. """ from sage.env import SAGE_SRC - interpreters.rebuild(os.path.join(SAGE_SRC, "sage", "ext", "interpreters")) - return ['sage.ext.interpreters'] + rebuild(os.path.join(SAGE_SRC, "sage", "ext", "interpreters")) + + return ["sage.ext.interpreters"] diff --git a/src/sage_setup/autogen/interpreters/__main__.py b/src/sage_setup/autogen/interpreters/__main__.py old mode 100644 new mode 100755 index 398a7b30039..3649565e7a0 --- a/src/sage_setup/autogen/interpreters/__main__.py +++ b/src/sage_setup/autogen/interpreters/__main__.py @@ -1,8 +1,9 @@ +#!/usr/bin/env python3 # Usage: python -m sage_setup.autogen.interpreters import argparse -from . import rebuild +from internal import rebuild parser = argparse.ArgumentParser() parser.add_argument("output_dir", help="Output directory") diff --git a/src/sage_setup/autogen/interpreters/__init__.py b/src/sage_setup/autogen/interpreters/internal/__init__.py similarity index 91% rename from src/sage_setup/autogen/interpreters/__init__.py rename to src/sage_setup/autogen/interpreters/internal/__init__.py index 75096d06b80..c2489ecd486 100644 --- a/src/sage_setup/autogen/interpreters/__init__.py +++ b/src/sage_setup/autogen/interpreters/internal/__init__.py @@ -109,20 +109,18 @@ # that will have to be changed. ##################################################################### -from __future__ import print_function, absolute_import +from __future__ import absolute_import, print_function import os - from os.path import getmtime -from .generator import InterpreterGenerator, AUTOGEN_WARN +from .generator import AUTOGEN_WARN, InterpreterGenerator from .instructions import * from .memory import * from .specs.base import * from .storage import * from .utils import * - # Tuple of (filename_root, extension, method) where filename_root is the # root of the filename to be joined with "_".ext and # method is the name of a get_ method on InterpreterGenerator that returns @@ -141,8 +139,8 @@ def build_interp(interp_spec, dir): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: testdir = tmp_dir() sage: rdf_interp = RDFInterpreter() sage: build_interp(rdf_interp, testdir) @@ -183,10 +181,10 @@ def rebuild(dirname, force=False, interpreters=None, distribution=None): Monolithic build:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: testdir = tmp_dir() sage: rebuild(testdir) - Building interpreters for fast_callable + Generating interpreters for fast_callable in ... -> First build of interpreters sage: with open(testdir + '/wrapper_el.pyx') as f: ....: f.readline() @@ -197,7 +195,7 @@ def rebuild(dirname, force=False, interpreters=None, distribution=None): sage: testdir = tmp_dir() sage: rebuild(testdir, interpreters=['Element', 'Python'], ....: distribution='sagemath-categories') - Building interpreters for fast_callable + Generating interpreters for fast_callable in ... -> First build of interpreters sage: with open(testdir + '/all__sagemath_categories.py') as f: ....: f.readline() @@ -205,16 +203,22 @@ def rebuild(dirname, force=False, interpreters=None, distribution=None): """ # This line will show up in "sage -b" (once per upgrade, not every time # you run it). - print("Building interpreters for fast_callable") + print(f"Generating interpreters for fast_callable in {dirname}") if interpreters is None: interpreters = ['CDF', 'Element', 'Python', 'RDF', 'RR', 'CC'] from importlib import import_module - _INTERPRETERS = [getattr(import_module('sage_setup.autogen.interpreters.specs.' + interpreter.lower()), - interpreter + 'Interpreter') - for interpreter in interpreters] + _INTERPRETERS = [ + getattr( + import_module( + ".specs." + interpreter.lower(), package=__name__ + ), + interpreter + "Interpreter", + ) + for interpreter in interpreters + ] if distribution is None: all_py = 'all.py' @@ -226,11 +230,6 @@ def rebuild(dirname, force=False, interpreters=None, distribution=None): except OSError: if not os.path.isdir(dirname): raise - # Remove leftover file from before move to namespace packages - try: - os.remove(os.path.join(dirname, '__init__.py')) - except FileNotFoundError: - pass # Although multiple files are generated by this function, since # they are all generated at once it suffices to make sure if just @@ -264,3 +263,6 @@ class NeedToRebuild(Exception): with open(os.path.join(dirname, all_py), 'w') as f: f.write("# " + AUTOGEN_WARN) + + with open(os.path.join(dirname, '__init__.py'), 'w') as f: + f.write("# " + AUTOGEN_WARN) diff --git a/src/sage_setup/autogen/interpreters/generator.py b/src/sage_setup/autogen/interpreters/internal/generator.py similarity index 94% rename from src/sage_setup/autogen/interpreters/generator.py rename to src/sage_setup/autogen/interpreters/internal/generator.py index 33877422a8c..ebfea5478fc 100644 --- a/src/sage_setup/autogen/interpreters/generator.py +++ b/src/sage_setup/autogen/interpreters/internal/generator.py @@ -42,8 +42,8 @@ def __init__(self, spec): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: interp = RDFInterpreter() sage: gen = InterpreterGenerator(interp) sage: gen._spec is interp @@ -72,8 +72,8 @@ def gen_code(self, instr_desc, write): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: interp = RDFInterpreter() sage: gen = InterpreterGenerator(interp) sage: from io import StringIO @@ -219,8 +219,8 @@ def func_header(self, cython=False): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.element import ElementInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.element import ElementInterpreter sage: interp = ElementInterpreter() sage: gen = InterpreterGenerator(interp) sage: print(gen.func_header()) @@ -262,8 +262,8 @@ def write_interpreter(self, write): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: interp = RDFInterpreter() sage: gen = InterpreterGenerator(interp) sage: from io import StringIO @@ -310,8 +310,8 @@ def write_wrapper(self, write): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: interp = RDFInterpreter() sage: gen = InterpreterGenerator(interp) sage: from io import StringIO @@ -480,8 +480,8 @@ def write_pxd(self, write): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: interp = RDFInterpreter() sage: gen = InterpreterGenerator(interp) sage: from io import StringIO @@ -532,10 +532,10 @@ def get_interpreter(self): First we get the InterpreterSpec for several interpreters:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter - sage: from sage_setup.autogen.interpreters.specs.element import ElementInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.element import ElementInterpreter sage: rdf_spec = RDFInterpreter() sage: rr_spec = RRInterpreter() sage: el_spec = ElementInterpreter() @@ -657,10 +657,10 @@ def get_wrapper(self): First we get the InterpreterSpec for several interpreters:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter - sage: from sage_setup.autogen.interpreters.specs.element import ElementInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.element import ElementInterpreter sage: rdf_spec = RDFInterpreter() sage: rr_spec = RRInterpreter() sage: el_spec = ElementInterpreter() @@ -983,10 +983,10 @@ def get_pxd(self): First we get the InterpreterSpec for several interpreters:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter - sage: from sage_setup.autogen.interpreters.specs.element import ElementInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.element import ElementInterpreter sage: rdf_spec = RDFInterpreter() sage: rr_spec = RRInterpreter() sage: el_spec = ElementInterpreter() diff --git a/src/sage_setup/autogen/interpreters/instructions.py b/src/sage_setup/autogen/interpreters/internal/instructions.py similarity index 89% rename from src/sage_setup/autogen/interpreters/instructions.py rename to src/sage_setup/autogen/interpreters/internal/instructions.py index 116f598197c..aad7583196d 100644 --- a/src/sage_setup/autogen/interpreters/instructions.py +++ b/src/sage_setup/autogen/interpreters/internal/instructions.py @@ -56,7 +56,7 @@ def params_gen(**chunks): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc_stack = MemoryChunkScratch('stack', ty_double, is_stack=True) sage: mc_args = MemoryChunkArguments('args', ty_double) sage: mc_code = MemoryChunkConstants('code', ty_int) @@ -186,8 +186,8 @@ class InstrSpec(object): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: pg = RDFInterpreter().pg sage: InstrSpec('add', pg('SS','S'), code='o0 = i0+i1;') add: SS->S = 'o0 = i0+i1;' @@ -213,8 +213,8 @@ def __init__(self, name, io, code=None, uses_error_handler=False, EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: pg = RDFInterpreter().pg sage: InstrSpec('add', pg('SS','S'), code='o0 = i0+i1;') add: SS->S = 'o0 = i0+i1;' @@ -288,8 +288,8 @@ def __repr__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: pg = RDFInterpreter().pg sage: InstrSpec('add', pg('SS','S'), code='o0 = i0+i1;') add: SS->S = 'o0 = i0+i1;' @@ -311,8 +311,8 @@ def instr_infix(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: pg = RDFInterpreter().pg sage: instr_infix('mul', pg('SS', 'S'), '*') mul: SS->S = 'o0 = i0 * i1;' @@ -327,8 +327,8 @@ def instr_funcall_2args(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: pg = RDFInterpreter().pg sage: instr_funcall_2args('atan2', pg('SS', 'S'), 'atan2') atan2: SS->S = 'o0 = atan2(i0, i1);' @@ -343,8 +343,8 @@ def instr_unary(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: pg = RDFInterpreter().pg sage: instr_unary('sin', pg('S','S'), 'sin(i0)') sin: S->S = 'o0 = sin(i0);' @@ -361,8 +361,8 @@ def instr_funcall_2args_mpfr(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter sage: pg = RRInterpreter().pg sage: instr_funcall_2args_mpfr('add', pg('SS','S'), 'mpfr_add') add: SS->S = 'mpfr_add(o0, i0, i1, MPFR_RNDN);' @@ -377,8 +377,8 @@ def instr_funcall_1arg_mpfr(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter sage: pg = RRInterpreter().pg sage: instr_funcall_1arg_mpfr('exp', pg('S','S'), 'mpfr_exp') exp: S->S = 'mpfr_exp(o0, i0, MPFR_RNDN);' @@ -392,8 +392,8 @@ def instr_funcall_2args_mpc(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import CCInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import CCInterpreter sage: pg = CCInterpreter().pg sage: instr_funcall_2args_mpc('add', pg('SS','S'), 'mpc_add') add: SS->S = 'mpc_add(o0, i0, i1, MPC_RNDNN);' @@ -407,8 +407,8 @@ def instr_funcall_1arg_mpc(name, io, op): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import CCInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import CCInterpreter sage: pg = CCInterpreter().pg sage: instr_funcall_1arg_mpc('exp', pg('S','S'), 'mpc_exp') exp: S->S = 'mpc_exp(o0, i0, MPC_RNDNN);' diff --git a/src/sage_setup/autogen/interpreters/memory.py b/src/sage_setup/autogen/interpreters/internal/memory.py similarity index 90% rename from src/sage_setup/autogen/interpreters/memory.py rename to src/sage_setup/autogen/interpreters/internal/memory.py index e719f47d77a..801596e98c8 100644 --- a/src/sage_setup/autogen/interpreters/memory.py +++ b/src/sage_setup/autogen/interpreters/internal/memory.py @@ -27,7 +27,7 @@ def string_of_addr(a): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc_code = MemoryChunkConstants('code', ty_int) sage: string_of_addr(mc_code) '*code++' @@ -72,7 +72,7 @@ def __init__(self, name, storage_type): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: mc.name 'args' @@ -88,7 +88,7 @@ def __repr__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: mc {MC:args} @@ -104,7 +104,7 @@ def declare_class_members(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: mc.declare_class_members() ' cdef int _n_args\n cdef mpfr_t* _args\n' @@ -119,7 +119,7 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: print(mc.init_class_members()) count = args['args'] @@ -139,7 +139,7 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: print(mc.dealloc_class_members()) if self._args: @@ -157,7 +157,7 @@ def declare_parameter(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: mc.declare_parameter() 'mpfr_t* args' @@ -171,8 +171,8 @@ class using this memory chunk, to allocate local variables. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: mc = MemoryChunkRRRetval('retval', ty_mpfr) sage: mc.declare_call_locals() ' cdef RealNumber retval = (self.domain)()\n' @@ -186,7 +186,7 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkConstants('constants', ty_mpfr) sage: mc.pass_argument() 'self._constants' @@ -201,7 +201,7 @@ def pass_call_c_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkConstants('constants', ty_mpfr) sage: mc.pass_call_c_argument() 'self._constants' @@ -221,7 +221,7 @@ def needs_cleanup_on_error(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkConstants('constants', ty_mpfr) sage: mc.needs_cleanup_on_error() False @@ -246,7 +246,7 @@ def is_stack(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkScratch('scratch', ty_mpfr) sage: mc.is_stack() False @@ -268,7 +268,7 @@ def is_python_refcounted_stack(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkScratch('args', ty_python) sage: mc.is_python_refcounted_stack() False @@ -297,7 +297,7 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_double) sage: print(mc.init_class_members()) count = args['args'] @@ -318,7 +318,7 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: print(mc.dealloc_class_members()) if self._args: @@ -336,7 +336,7 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkConstants('constants', ty_mpfr) sage: mc.pass_argument() 'self._constants' @@ -360,7 +360,7 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkConstants('constants', ty_mpfr) sage: print(mc.init_class_members()) val = args['constants'] @@ -398,7 +398,7 @@ def setup_args(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: print(mc.setup_args()) cdef mpfr_t* c_args = self._args @@ -422,7 +422,7 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkArguments('args', ty_mpfr) sage: mc.pass_argument() 'c_args' @@ -449,7 +449,7 @@ def __init__(self, name, storage_type, is_stack=False): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkScratch('stack', ty_double, is_stack=True) sage: mc.name 'stack' @@ -469,7 +469,7 @@ def is_stack(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkScratch('stack', ty_mpfr, is_stack=True) sage: mc.is_stack() True @@ -489,7 +489,7 @@ def needs_cleanup_on_error(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkScratch('registers', ty_python) sage: mc.needs_cleanup_on_error() True @@ -508,7 +508,7 @@ def handle_cleanup(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: mc = MemoryChunkScratch('registers', ty_python) sage: print(mc.handle_cleanup()) for i in range(self._n_registers): diff --git a/src/sage_setup/autogen/interpreters/specs/__init__.py b/src/sage_setup/autogen/interpreters/internal/specs/__init__.py similarity index 100% rename from src/sage_setup/autogen/interpreters/specs/__init__.py rename to src/sage_setup/autogen/interpreters/internal/specs/__init__.py diff --git a/src/sage_setup/autogen/interpreters/specs/base.py b/src/sage_setup/autogen/interpreters/internal/specs/base.py similarity index 87% rename from src/sage_setup/autogen/interpreters/specs/base.py rename to src/sage_setup/autogen/interpreters/internal/specs/base.py index c311c76fb04..6abd2253870 100644 --- a/src/sage_setup/autogen/interpreters/specs/base.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/base.py @@ -48,9 +48,9 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter sage: interp = RDFInterpreter() sage: interp.c_header '#include ' @@ -85,8 +85,8 @@ def _set_opcodes(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter sage: interp = RDFInterpreter() sage: interp.instr_descs[5].opcode 5 @@ -130,10 +130,10 @@ def __init__(self, type, mc_retval=None): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import RDFInterpreter - sage: from sage_setup.autogen.interpreters.specs.rr import RRInterpreter - sage: from sage_setup.autogen.interpreters.specs.element import ElementInterpreter + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import RDFInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.rr import RRInterpreter + sage: from sage_setup.autogen.interpreters.internal.specs.element import ElementInterpreter sage: rdf = RDFInterpreter() sage: rr = RRInterpreter() sage: el = ElementInterpreter() diff --git a/src/sage_setup/autogen/interpreters/specs/cc.py b/src/sage_setup/autogen/interpreters/internal/specs/cc.py similarity index 91% rename from src/sage_setup/autogen/interpreters/specs/cc.py rename to src/sage_setup/autogen/interpreters/internal/specs/cc.py index e16252b0b79..cc42a6defab 100644 --- a/src/sage_setup/autogen/interpreters/specs/cc.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/cc.py @@ -30,8 +30,8 @@ def declare_class_members(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import * sage: mc = MemoryChunkCCRetval('retval', ty_mpc) sage: mc.declare_class_members() '' @@ -45,8 +45,8 @@ class using this memory chunk, to allocate local variables. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import * sage: mc = MemoryChunkCCRetval('retval', ty_mpc) sage: mc.declare_call_locals() ' cdef ComplexNumber retval = (self.domain_element._new())\n' @@ -63,8 +63,8 @@ def declare_parameter(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import * sage: mc = MemoryChunkCCRetval('retval', ty_mpc) sage: mc.declare_parameter() 'mpc_t retval' @@ -78,8 +78,8 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import * sage: mc = MemoryChunkCCRetval('retval', ty_mpc) sage: mc.pass_argument() '((retval.__re))' @@ -93,8 +93,8 @@ def pass_call_c_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import * sage: mc = MemoryChunkCCRetval('retval', ty_mpc) sage: mc.pass_call_c_argument() 'result' @@ -115,8 +115,8 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cc import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cc import * sage: interp = CCInterpreter() sage: interp.name 'cc' @@ -149,7 +149,6 @@ def __init__(self): sage: print(interp.c_header) #include - #include "wrapper_cc.h" So instructions where you need to interact with Python can @@ -171,7 +170,6 @@ def __init__(self): self.c_header = ri(0, ''' #include - #include "wrapper_cc.h" ''') self.pxd_header = ri(0, diff --git a/src/sage_setup/autogen/interpreters/specs/cdf.py b/src/sage_setup/autogen/interpreters/internal/specs/cdf.py similarity index 98% rename from src/sage_setup/autogen/interpreters/specs/cdf.py rename to src/sage_setup/autogen/interpreters/internal/specs/cdf.py index c9ea258e221..1edc1f7abe3 100644 --- a/src/sage_setup/autogen/interpreters/specs/cdf.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/cdf.py @@ -33,8 +33,8 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.cdf import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.cdf import * sage: interp = CDFInterpreter() sage: interp.name 'cdf' @@ -85,7 +85,6 @@ def __init__(self): self.c_header = ri(0,""" #include #include - #include "wrapper_cdf.h" /* On Solaris, we need to define _Imaginary_I when compiling with GCC, * otherwise the constant I doesn't work. The definition below is based diff --git a/src/sage_setup/autogen/interpreters/specs/element.py b/src/sage_setup/autogen/interpreters/internal/specs/element.py similarity index 90% rename from src/sage_setup/autogen/interpreters/specs/element.py rename to src/sage_setup/autogen/interpreters/internal/specs/element.py index 2f280f703f1..5dc7c6592c9 100644 --- a/src/sage_setup/autogen/interpreters/specs/element.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/element.py @@ -37,8 +37,8 @@ def setup_args(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.element import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.element import * sage: mc = MemoryChunkElementArguments('args', ty_python) sage: mc.setup_args() 'mapped_args = [self._domain(a) for a in args]\n' @@ -51,8 +51,8 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.element import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.element import * sage: mc = MemoryChunkElementArguments('args', ty_python) sage: mc.pass_argument() '(mapped_args).ob_item' @@ -81,8 +81,8 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.element import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.element import * sage: interp = ElementInterpreter() sage: interp.name 'el' @@ -105,8 +105,6 @@ def __init__(self): self.chunks = [self.mc_args, self.mc_constants, self.mc_stack, self.mc_domain_info, self.mc_code] self.c_header = ri(0, """ - #include "wrapper_el.h" - #define CHECK(x) do_check(&(x), domain) static inline int do_check(PyObject **x, PyObject *domain) { diff --git a/src/sage_setup/autogen/interpreters/specs/python.py b/src/sage_setup/autogen/interpreters/internal/specs/python.py similarity index 86% rename from src/sage_setup/autogen/interpreters/specs/python.py rename to src/sage_setup/autogen/interpreters/internal/specs/python.py index c185557165f..24bab75f10d 100644 --- a/src/sage_setup/autogen/interpreters/specs/python.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/python.py @@ -31,8 +31,8 @@ def declare_class_members(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPythonArguments('args', ty_python) """ return " cdef int _n_%s\n" % self.name @@ -45,8 +45,8 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPythonArguments('args', ty_python) sage: mc.init_class_members() " count = args['args']\n self._n_args = count\n" @@ -63,8 +63,8 @@ def setup_args(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPythonArguments('args', ty_python) sage: mc.setup_args() '' @@ -77,8 +77,8 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPythonArguments('args', ty_python) sage: mc.pass_argument() '(args).ob_item' @@ -100,8 +100,8 @@ def __init__(self, name): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPyConstant('domain') sage: mc.name 'domain' @@ -117,8 +117,8 @@ def declare_class_members(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPyConstant('domain') sage: mc.declare_class_members() ' cdef object _domain\n' @@ -136,8 +136,8 @@ class members. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPyConstant('domain') sage: mc.init_class_members() " self._domain = args['domain']\n" @@ -154,8 +154,8 @@ def declare_parameter(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPyConstant('domain') sage: mc.declare_parameter() 'PyObject* domain' @@ -169,8 +169,8 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: mc = MemoryChunkPyConstant('domain') sage: mc.pass_argument() 'self._domain' @@ -212,8 +212,8 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.python import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.python import * sage: interp = PythonInterpreter() sage: interp.name 'py' diff --git a/src/sage_setup/autogen/interpreters/specs/rdf.py b/src/sage_setup/autogen/interpreters/internal/specs/rdf.py similarity index 97% rename from src/sage_setup/autogen/interpreters/specs/rdf.py rename to src/sage_setup/autogen/interpreters/internal/specs/rdf.py index 95894f8d6d2..83a0ecde012 100644 --- a/src/sage_setup/autogen/interpreters/specs/rdf.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/rdf.py @@ -36,8 +36,8 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rdf import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rdf import * sage: interp = RDFInterpreter() sage: interp.name 'rdf' diff --git a/src/sage_setup/autogen/interpreters/specs/rr.py b/src/sage_setup/autogen/interpreters/internal/specs/rr.py similarity index 91% rename from src/sage_setup/autogen/interpreters/specs/rr.py rename to src/sage_setup/autogen/interpreters/internal/specs/rr.py index 06452e24047..e51262d6196 100644 --- a/src/sage_setup/autogen/interpreters/specs/rr.py +++ b/src/sage_setup/autogen/interpreters/internal/specs/rr.py @@ -30,8 +30,8 @@ def declare_class_members(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: mc = MemoryChunkRRRetval('retval', ty_mpfr) sage: mc.declare_class_members() '' @@ -45,8 +45,8 @@ class using this memory chunk, to allocate local variables. EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: mc = MemoryChunkRRRetval('retval', ty_mpfr) sage: mc.declare_call_locals() ' cdef RealNumber retval = (self.domain)()\n' @@ -63,8 +63,8 @@ def declare_parameter(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: mc = MemoryChunkRRRetval('retval', ty_mpfr) sage: mc.declare_parameter() 'mpfr_t retval' @@ -78,8 +78,8 @@ def pass_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: mc = MemoryChunkRRRetval('retval', ty_mpfr) sage: mc.pass_argument() 'retval.value' @@ -93,8 +93,8 @@ def pass_call_c_argument(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: mc = MemoryChunkRRRetval('retval', ty_mpfr) sage: mc.pass_call_c_argument() 'result' @@ -116,8 +116,8 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * - sage: from sage_setup.autogen.interpreters.specs.rr import * + sage: from sage_setup.autogen.interpreters.internal import * + sage: from sage_setup.autogen.interpreters.internal.specs.rr import * sage: interp = RRInterpreter() sage: interp.name 'rr' @@ -148,7 +148,6 @@ def __init__(self): sage: print(interp.c_header) #include - #include "wrapper_rr.h" The function ``rr_py_call_helper`` is implemented in Cython:: @@ -188,7 +187,6 @@ def __init__(self): self.c_header = ri(0, ''' #include - #include "wrapper_rr.h" ''') self.pxd_header = ri(0, diff --git a/src/sage_setup/autogen/interpreters/storage.py b/src/sage_setup/autogen/interpreters/internal/storage.py similarity index 90% rename from src/sage_setup/autogen/interpreters/storage.py rename to src/sage_setup/autogen/interpreters/internal/storage.py index 291398fd9d9..ce77abbe586 100644 --- a/src/sage_setup/autogen/interpreters/storage.py +++ b/src/sage_setup/autogen/interpreters/internal/storage.py @@ -67,7 +67,7 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.class_member_declarations '' sage: ty_double.class_member_initializations @@ -104,7 +104,7 @@ def cheap_copies(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.cheap_copies() True sage: ty_python.cheap_copies() @@ -126,7 +126,7 @@ def python_refcounted(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.python_refcounted() False sage: ty_python.python_refcounted() @@ -140,7 +140,7 @@ def cython_decl_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.cython_decl_type() 'double' sage: ty_python.cython_decl_type() @@ -157,7 +157,7 @@ def cython_array_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.cython_array_type() 'double*' sage: ty_python.cython_array_type() @@ -180,7 +180,7 @@ def needs_cython_init_clear(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.needs_cython_init_clear() False sage: ty_mpfr.needs_cython_init_clear() @@ -196,7 +196,7 @@ def c_decl_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.c_decl_type() 'double' sage: ty_python.c_decl_type() @@ -213,7 +213,7 @@ def c_ptr_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.c_ptr_type() 'double*' sage: ty_python.c_ptr_type() @@ -231,7 +231,7 @@ def c_reference_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.c_reference_type() 'double*' sage: ty_python.c_reference_type() @@ -248,7 +248,7 @@ def c_local_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.c_local_type() 'double' sage: ty_python.c_local_type() @@ -266,7 +266,7 @@ def assign_c_from_py(self, c, py): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.assign_c_from_py('foo', 'bar') 'foo = bar' sage: ty_python.assign_c_from_py('foo[i]', 'bar[j]') @@ -284,7 +284,7 @@ def declare_chunk_class_members(self, name): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.declare_chunk_class_members('args') ' cdef int _n_args\n cdef mpfr_t* _args\n' """ @@ -302,7 +302,7 @@ def alloc_chunk_data(self, name, len): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: print(ty_mpfr.alloc_chunk_data('args', 'MY_LENGTH')) self._n_args = MY_LENGTH self._args = check_allocarray(self._n_args, sizeof(mpfr_t)) @@ -328,7 +328,7 @@ def dealloc_chunk_data(self, name): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: print(ty_double.dealloc_chunk_data('args')) if self._args: sig_free(self._args) @@ -364,7 +364,7 @@ def __init__(self, ty): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.class_member_declarations '' sage: ty_double.class_member_initializations @@ -391,7 +391,7 @@ def cheap_copies(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.cheap_copies() True sage: ty_python.cheap_copies() @@ -405,7 +405,7 @@ def c_decl_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.c_decl_type() 'double' sage: ty_python.c_decl_type() @@ -422,7 +422,7 @@ def c_local_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_double.c_local_type() 'double' sage: ty_python.c_local_type() @@ -456,7 +456,7 @@ class StorageTypeDoubleComplex(StorageTypeSimple): """ def assign_c_from_py(self, c, py): """ - sage: from sage_setup.autogen.interpreters import ty_double_complex + sage: from sage_setup.autogen.interpreters.internal import ty_double_complex sage: ty_double_complex.assign_c_from_py('z_c', 'z_py') 'z_c = CDE_to_dz(z_py)' """ @@ -500,7 +500,7 @@ def __init__(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.class_member_declarations '' sage: ty_python.class_member_initializations @@ -521,7 +521,7 @@ def python_refcounted(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.python_refcounted() True """ @@ -533,7 +533,7 @@ def cython_decl_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.cython_decl_type() 'object' """ @@ -547,7 +547,7 @@ def declare_chunk_class_members(self, name): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.declare_chunk_class_members('args') ' cdef object _list_args\n cdef int _n_args\n cdef PyObject** _args\n' """ @@ -565,7 +565,7 @@ def alloc_chunk_data(self, name, len): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: print(ty_python.alloc_chunk_data('args', 'MY_LENGTH')) self._n_args = MY_LENGTH self._list_args = PyList_New(self._n_args) @@ -590,7 +590,7 @@ def dealloc_chunk_data(self, name): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.dealloc_chunk_data('args') '' """ @@ -605,7 +605,7 @@ def needs_cython_init_clear(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.needs_cython_init_clear() True """ @@ -619,7 +619,7 @@ def assign_c_from_py(self, c, py): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.assign_c_from_py('foo[i]', 'bar[j]') 'foo[i] = bar[j]; Py_INCREF(foo[i])' """ @@ -633,7 +633,7 @@ def cython_init(self, loc): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.cython_init('foo[i]') 'foo[i] = NULL' """ @@ -646,7 +646,7 @@ def cython_clear(self, loc): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_python.cython_clear('foo[i]') 'Py_CLEAR(foo[i])' """ @@ -674,7 +674,7 @@ def __init__(self, decl_ty, ref_ty): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.class_member_declarations 'cdef RealField_class domain\n' sage: ty_mpfr.class_member_initializations @@ -696,7 +696,7 @@ def c_decl_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.c_decl_type() 'mpfr_t' """ @@ -711,7 +711,7 @@ def c_local_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.c_local_type() 'mpfr_ptr' """ @@ -725,7 +725,7 @@ def c_reference_type(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.c_reference_type() 'mpfr_t' """ @@ -741,7 +741,7 @@ def needs_cython_init_clear(self): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.needs_cython_init_clear() True """ @@ -775,7 +775,7 @@ def __init__(self, id=''): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.class_member_declarations 'cdef RealField_class domain\n' sage: ty_mpfr.class_member_initializations @@ -812,7 +812,7 @@ def cython_init(self, loc): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.cython_init('foo[i]') 'mpfr_init2(foo[i], self.domain.prec())' """ @@ -826,7 +826,7 @@ def cython_clear(self, loc): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.cython_clear('foo[i]') 'mpfr_clear(foo[i])' """ @@ -840,7 +840,7 @@ def assign_c_from_py(self, c, py): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpfr.assign_c_from_py('foo[i]', 'bar[j]') 'rn = self.domain(bar[j])\nmpfr_set(foo[i], rn.value, MPFR_RNDN)' """ @@ -879,7 +879,7 @@ def __init__(self, id=''): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpc.class_member_declarations 'cdef object domain\ncdef ComplexNumber domain_element\n' sage: ty_mpc.class_member_initializations @@ -916,7 +916,7 @@ def cython_init(self, loc): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpc.cython_init('foo[i]') 'mpc_init2(foo[i], self.domain_element._prec)' """ @@ -930,7 +930,7 @@ def cython_clear(self, loc): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpc.cython_clear('foo[i]') 'mpc_clear(foo[i])' """ @@ -944,7 +944,7 @@ def assign_c_from_py(self, c, py): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: ty_mpc.assign_c_from_py('foo[i]', 'bar[j]') 'cn = self.domain(bar[j])\nmpc_set_fr_fr(foo[i], cn.__re, cn.__im, MPC_RNDNN)' """ diff --git a/src/sage_setup/autogen/interpreters/utils.py b/src/sage_setup/autogen/interpreters/internal/utils.py similarity index 93% rename from src/sage_setup/autogen/interpreters/utils.py rename to src/sage_setup/autogen/interpreters/internal/utils.py index 10f239ed2a3..247243ef644 100644 --- a/src/sage_setup/autogen/interpreters/utils.py +++ b/src/sage_setup/autogen/interpreters/internal/utils.py @@ -50,7 +50,7 @@ def je(template, **kwargs): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import je + sage: from sage_setup.autogen.interpreters.internal import je sage: je("{{ a }} > {{ b }} * {{ c }}", a='"a suffusion of yellow"', b=3, c=7) '"a suffusion of yellow" > 3 * 7' """ @@ -76,7 +76,7 @@ def indent_lines(n, text): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import indent_lines + sage: from sage_setup.autogen.interpreters.internal import indent_lines sage: indent_lines(3, "foo") ' foo' sage: indent_lines(3, "foo\nbar") @@ -102,7 +102,7 @@ def reindent_lines(n, text): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import reindent_lines + sage: from sage_setup.autogen.interpreters.internal import reindent_lines sage: print(reindent_lines(3, " foo\n bar")) foo bar @@ -118,7 +118,7 @@ def write_if_changed(fn, value): EXAMPLES:: - sage: from sage_setup.autogen.interpreters import * + sage: from sage_setup.autogen.interpreters.internal import * sage: def last_modification(fn): return os.stat(fn).st_mtime sage: fn = tmp_filename('gen_interp') sage: write_if_changed(fn, 'Hello, world') diff --git a/src/sage_setup/find.py b/src/sage_setup/find.py index 5447f6418a4..e00336b3443 100644 --- a/src/sage_setup/find.py +++ b/src/sage_setup/find.py @@ -343,6 +343,92 @@ def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[], *, 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): """ diff --git a/src/tox.ini b/src/tox.ini index 42f976e070d..b6548bc55a4 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -379,7 +379,7 @@ exclude = [pytest] python_files = *_test.py -norecursedirs = local prefix venv build pkgs .git src/doc src/bin +norecursedirs = local prefix venv build builddir pkgs .git src/doc src/bin tools addopts = --import-mode importlib doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS # https://docs.pytest.org/en/stable/reference/reference.html#confval-consider_namespace_packages @@ -389,7 +389,9 @@ consider_namespace_packages = True source = sage concurrency = multiprocessing,thread data_file = .coverage/.coverage -disable_warnings = no-data-collected +disable_warnings = + no-data-collected + module-not-measured [coverage:report] ignore_errors = True diff --git a/tools/README.md b/tools/README.md new file mode 100644 index 00000000000..b0c2e4bb68b --- /dev/null +++ b/tools/README.md @@ -0,0 +1,13 @@ +# Tools Directory + +This folder contains various command-line tools that are used to facilitate different development tasks. Below is a brief description of each command available in this directory. + +## Update Meson Build Files + +This command is used to updates the Meson build files in the project. It automatically adds new source files (py, pyx) to the Meson files and removes deleted source files. This command is useful when adding or removing source files from the project. + +Within an active virtual environment where Meson is installed, run the following command: + +```bash +tools/update_meson.py +``` diff --git a/tools/update-meson.py b/tools/update-meson.py new file mode 100755 index 00000000000..827b7d9b5a3 --- /dev/null +++ b/tools/update-meson.py @@ -0,0 +1,297 @@ +#!/usr/bin/env python3 + +import argparse +import os +from argparse import Namespace +from pathlib import Path + +from mesonbuild import mlog +from mesonbuild.ast import ( + AstPrinter, + AstVisitor, +) +from mesonbuild.ast.interpreter import MethodNode +from mesonbuild.mformat import ( + run as meson_format, +) +from mesonbuild.mparser import ( + AssignmentNode, + BaseNode, + DictNode, + SymbolNode, +) +from mesonbuild.rewriter import ( + ArgumentNode, + ArrayNode, + FunctionNode, + Rewriter, + StringNode, + Token, +) + +# Get target directory from command line arguments +parser = argparse.ArgumentParser() +parser.add_argument( + "sourcedir", help="Source directory", nargs="?", default=".", type=Path +) +options = parser.parse_args() + + +class AstPython(AstVisitor): + install_sources_calls: list[MethodNode] = [] + extension_data: list[AssignmentNode] = [] + + def visit_MethodNode(self, node: MethodNode) -> None: + if node.name.value == "install_sources": + self.install_sources_calls += [node] + return super().visit_MethodNode(node) + + def visit_AssignmentNode(self, node: AssignmentNode) -> None: + if node.var_name.value in ["extension_data", "extension_data_cpp"]: + self.extension_data += [node] + return super().visit_AssignmentNode(node) + + +# Utility function to get a list of the sources from a node +def arg_list_from_node(n): + args = [] + if isinstance(n, FunctionNode) or isinstance(n, MethodNode): + args = list(n.args.arguments) + # if 'func_name' in n and n.func_name.value in BUILD_TARGET_FUNCTIONS: + # args.pop(0) + elif isinstance(n, ArrayNode): + args = n.args.arguments + elif isinstance(n, ArgumentNode): + args = n.arguments + return args + + +def _symbol(val: str) -> SymbolNode: + return SymbolNode(Token("", "", 0, 0, 0, (0, 0), val)) + + +def update_python_sources(self: Rewriter, visitor: AstPython): + for target in visitor.install_sources_calls: + # Generate the current source list + src_list: list[str] = [] + for arg in arg_list_from_node(target): + if isinstance(arg, StringNode): + src_list += [arg.value] + + folder = Path(target.filename).parent + python_files = sorted( + list(folder.glob("*.py")) + list(folder.glob('*.pxd')) + ) # + list(folder.glob('*.pxd')) + list(folder.glob('*.h'))) + + to_append: list[StringNode] = [] + for file in python_files: + file_name = file.name + if file_name == "__init__.py": + # We don't want to add __init__.py files + continue + if file_name in src_list: + continue + token = Token("string", target.filename, 0, 0, 0, None, file_name) + to_append += [StringNode(token)] + + # Get all deleted files + to_remove = [] + for src in src_list: + if not folder.joinpath(src).exists(): + to_remove += [src] + + if not to_append and not to_remove: + continue + + # Update the source list + target.args.arguments = sorted( + [ + arg + for arg in target.args.arguments + if not (isinstance(arg, StringNode) and arg.value in to_remove) + ] + + to_append, + key=lambda x: x.value, + ) + + # Mark the node as modified + if target not in self.modified_nodes: + self.modified_nodes += [target] + + ext_data: dict[Path, list[str]] = {} + for target in visitor.extension_data: + folder = Path(target.filename).parent + # Generate the current source dict + src_list: dict[str, BaseNode] = {} + if isinstance(target.value, DictNode): + src_list.update({k.value: v for k, v in target.value.args.kwargs.items()}) + ext_data.setdefault(folder, []) + ext_data[folder] += src_list.keys() + + for target in visitor.extension_data: + if target.var_name.value != "extension_data": + continue + folder = Path(target.filename).parent + src_list = ext_data[folder] + + cython_files = sorted(list(folder.glob("*.pyx"))) + # Some cython files are compiled in a special way, so we don't want to add them + special_cython_files = { + "bliss.pyx", + "mcqd.pyx", + "tdlib.pyx", + } + cython_files = [x for x in cython_files if x.name not in special_cython_files] + # Add all cython files that are not in the source list + for file in cython_files: + file_name = file.stem + if file_name in src_list: + continue + token = Token("string", target.filename, 0, 0, 0, None, file_name) + arg = ArgumentNode(Token("", target.filename, 0, 0, 0, None, "[]")) + arg.append( + StringNode(Token("string", target.filename, 0, 0, 0, None, file.name)) + ) + func = FunctionNode(_symbol("files"), _symbol("("), arg, _symbol(")")) + target.value.args.kwargs.update({StringNode(token): func}) + if target not in self.modified_nodes: + self.modified_nodes += [target] + + +def apply_changes(self: Rewriter): + assert all( + hasattr(x, "lineno") and hasattr(x, "colno") and hasattr(x, "filename") + for x in self.modified_nodes + ) + assert all( + hasattr(x, "lineno") and hasattr(x, "colno") and hasattr(x, "filename") + for x in self.to_remove_nodes + ) + assert all( + isinstance(x, (ArrayNode, FunctionNode, MethodNode, AssignmentNode)) + for x in self.modified_nodes + ) + assert all( + isinstance(x, (ArrayNode, AssignmentNode, FunctionNode)) + for x in self.to_remove_nodes + ) + # Sort based on line and column in reversed order + work_nodes = [{"node": x, "action": "modify"} for x in self.modified_nodes] + work_nodes += [{"node": x, "action": "rm"} for x in self.to_remove_nodes] + work_nodes = sorted( + work_nodes, key=lambda x: (x["node"].lineno, x["node"].colno), reverse=True + ) + work_nodes += [{"node": x, "action": "add"} for x in self.to_add_nodes] + + # Generating the new replacement string + str_list = [] + for i in work_nodes: + new_data = "" + if i["action"] == "modify" or i["action"] == "add": + printer = AstPrinter() + i["node"].accept(printer) + printer.post_process() + new_data = printer.result.strip() + data = { + "file": i["node"].filename, + "str": new_data, + "node": i["node"], + "action": i["action"], + } + str_list += [data] + + # Load build files + files = {} + for i in str_list: + if i["file"] in files: + continue + fpath = os.path.realpath(os.path.join(self.sourcedir, i["file"])) + fdata = "" + # Create an empty file if it does not exist + if not os.path.exists(fpath): + with open(fpath, "w", encoding="utf-8"): + pass + with open(fpath, encoding="utf-8") as fp: + fdata = fp.read() + + # Generate line offsets numbers + m_lines = fdata.splitlines(True) + offset = 0 + line_offsets = [] + for j in m_lines: + line_offsets += [offset] + offset += len(j) + + files[i["file"]] = {"path": fpath, "raw": fdata, "offsets": line_offsets} + + # Replace in source code + def remove_node(i): + offsets = files[i["file"]]["offsets"] + raw = files[i["file"]]["raw"] + node = i["node"] + line = node.lineno - 1 + col = node.colno + if isinstance(node, MethodNode): + # The new data contains the source object as well + col = node.source_object.colno + elif isinstance(node, AssignmentNode): + col = node.var_name.colno + start = offsets[line] + col + end = start + if isinstance(node, (ArrayNode, FunctionNode, MethodNode)): + end = offsets[node.end_lineno - 1] + node.end_colno + elif isinstance(node, AssignmentNode): + end = offsets[node.value.end_lineno - 1] + node.value.end_colno + + # Only removal is supported for assignments + elif isinstance(node, AssignmentNode) and i["action"] == "rm": + if isinstance(node.value, (ArrayNode, FunctionNode, MethodNode)): + remove_node( + {"file": i["file"], "str": "", "node": node.value, "action": "rm"} + ) + raw = files[i["file"]]["raw"] + while raw[end] != "=": + end += 1 + end += 1 # Handle the '=' + while raw[end] in {" ", "\n", "\t"}: + end += 1 + + files[i["file"]]["raw"] = raw[:start] + i["str"] + raw[end:] + + for i in str_list: + if i["action"] in {"modify", "rm"}: + remove_node(i) + elif i["action"] == "add": + files[i["file"]]["raw"] += i["str"] + "\n" + + # Write the files back + for key, val in files.items(): + mlog.log("Rewriting", mlog.yellow(key)) + with open(val["path"], "w", encoding="utf-8") as fp: + fp.write(val["raw"]) + + +# Monkey patch the apply_changes method until https://github.com/mesonbuild/meson/pull/12899 is merged +Rewriter.apply_changes = apply_changes +# Monkey patch the update_python_sources method until this is upstreamed +Rewriter.process_update_python_sources = update_python_sources + +rewriter = Rewriter(options.sourcedir) +visitor = AstPython() +rewriter.interpreter.visitors += [visitor] +rewriter.analyze_meson() +rewriter.process_update_python_sources(visitor) +rewriter.apply_changes() +rewriter.print_info() + +# Run meson format +meson_format( + Namespace( + sources=[options.sourcedir], + inplace=True, + recursive=True, + output=None, + configuration=None, + editor_config=None, + ) +)