Skip to content

Commit

Permalink
Merge pull request sagemath#303 from passagemath/sagemath-gfan
Browse files Browse the repository at this point in the history
pkgs/sagemath-gfan: New
  • Loading branch information
mkoeppe authored Nov 5, 2024
2 parents 621488b + cb6fdaa commit 2094923
Show file tree
Hide file tree
Showing 30 changed files with 329 additions and 4 deletions.
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/SPKG.rst
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/bootstrap
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$(SAGE_ROOT)/pkgs/sagemath-gfan/pyproject.toml $(SAGE_ROOT)/pkgs/sagemath-gfan/MANIFEST.in gfan cysignals | $(PYTHON_TOOLCHAIN) sage_setup sage_conf sagemath_environment cython pkgconfig $(PYTHON)
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/dependencies_check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tox sagemath_modules sagemath_repl
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/package-version.txt
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/spkg-check
9 changes: 9 additions & 0 deletions build/pkgs/sagemath_gfan/spkg-install.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cd src

export PIP_NO_INDEX=true
export PIP_FIND_LINKS="file://$SAGE_SPKG_WHEELS"

# Modularized install via wheels
# --no-build-isolation so that declared build dependencies,
# in particular sagemath-environment do not have to be present as wheels.
sdh_pip_install --no-build-isolation .
24 changes: 24 additions & 0 deletions build/pkgs/sagemath_gfan/spkg-src
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#
# Script to prepare an sdist tarball for sagemath-gfan
# This script is not used during build.
#
# HOW TO MAKE THE TARBALL:
# ./sage --sh build/pkgs/sagemath_gfan/spkg-src

if [ -z "$SAGE_ROOT" ] ; then
echo >&2 "Error - SAGE_ROOT undefined ... exiting"
echo >&2 "Maybe run 'sage -sh'?"
exit 1
fi

# Exit on failure
set -e

cd build/pkgs/sagemath_gfan

cd src
# Get rid of old *.egg-info/SOURCES.txt
rm -Rf *.egg-info

python3 -m build --sdist --no-isolation --skip-dependency-check --outdir "$SAGE_DISTFILES"
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/src
1 change: 1 addition & 0 deletions build/pkgs/sagemath_gfan/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
2 changes: 2 additions & 0 deletions build/pkgs/sagemath_gfan/version_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This file is updated on every release by the sage-update-version script
passagemath-gfan ~= 10.4.44.0
21 changes: 21 additions & 0 deletions pkgs/sagemath-gfan/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
prune sage

include VERSION.txt

include sage/libs/gfan.p*
include sage/rings/polynomial/groebner_fan.p*

global-exclude *.c
global-exclude *.cpp

global-exclude all__sagemath_*.py
global-include all__sagemath_gfan.py

global-exclude __pycache__
global-exclude *.py[co]
global-exclude *.bak
global-exclude *.so
global-exclude *~
prune .tox
prune build
prune dist
25 changes: 25 additions & 0 deletions pkgs/sagemath-gfan/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
===========================================================
passagemath: Groebner fans and tropical varieties with gfan
===========================================================

About SageMath
--------------

"Creating a Viable Open Source Alternative to
Magma, Maple, Mathematica, and MATLAB"

Copyright (C) 2005-2024 The Sage Development Team

https://www.sagemath.org

SageMath fully supports all major Linux distributions, recent versions of
macOS, and Windows (Windows Subsystem for Linux).

See https://doc.sagemath.org/html/en/installation/index.html
for general installation instructions.


About this pip-installable distribution package
-----------------------------------------------

This pip-installable source distribution ``passagemath-gfan`` provides an interface to gfan.
1 change: 1 addition & 0 deletions pkgs/sagemath-gfan/VERSION.txt
71 changes: 71 additions & 0 deletions pkgs/sagemath-gfan/pyproject.toml.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
include(`sage_spkg_versions_toml.m4')dnl' -*- conf-toml -*-
[build-system]
# Minimum requirements for the build system to execute.
requires = [
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_pkgconfig
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_cython
SPKG_INSTALL_REQUIRES_cysignals
]
build-backend = "setuptools.build_meta"

[project]
name = "passagemath-gfan"
description = "passagemath: Groebner fans and tropical varieties with gfan"
dependencies = [
SPKG_INSTALL_REQUIRES_cysignals
]
dynamic = ["version"]
include(`pyproject_toml_metadata.m4')dnl'

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[project.optional-dependencies]
test = [
SPKG_INSTALL_REQUIRES_sagemath_modules
SPKG_INSTALL_REQUIRES_sagemath_repl
]

[tool.cibuildwheel.linux]
# Unfortunately CIBW_REPAIR_WHEEL_COMMAND does not expand {project} (and other placeholders),
# so there is no clean way to refer to the repair_wheel.py script
# https://github.com/pypa/cibuildwheel/issues/1931
repair-wheel-command = [
'python3 -m pip install passagemath-conf',
'python3 pkgs/sagemath-gfan/repair_wheel.py {wheel}',
'auditwheel repair -w {dest_dir} {wheel}',
]
[tool.cibuildwheel.macos]
repair-wheel-command = [
'python3 -m pip install passagemath-conf',
'python3 pkgs/sagemath-gfan/repair_wheel.py {wheel}',
'delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}',
]

[tool.setuptools]
include-package-data = false

[tool.setuptools.dynamic]
version = {file = ["VERSION.txt"]}

[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 = [
"pkg:generic/gfan",
"pkg:generic/gmp",
"pkg:generic/mpc",
"pkg:generic/mpfr",
]

dependencies = [
]
17 changes: 17 additions & 0 deletions pkgs/sagemath-gfan/repair_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add Maxima data to the wheel

import os
import shlex
import sys

from pathlib import Path

from sage_conf import SAGE_LOCAL

wheel = sys.argv[1]

# SAGE_LOCAL/bin/gfan* --> sage_wheels/bin/gfan*
command = f'ln -sf {shlex.quote(SAGE_LOCAL)} sage_wheels && zip -r {shlex.quote(wheel)} sage_wheels/bin/gfan*'
print(f'Running {command}')
sys.stdout.flush()
os.system(command)
6 changes: 6 additions & 0 deletions pkgs/sagemath-gfan/requirements-editable.txt.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include(`sage_spkg_versions.m4')dnl
dnl Same as setup.cfg.m4 install_requires; FIXME: should pin to built wheels.
SPKG_INSTALL_REQUIRES_gmpy2
SPKG_INSTALL_REQUIRES_cysignals
-e ../sagemath-objects
-e ../sagemath-categories
2 changes: 2 additions & 0 deletions pkgs/sagemath-gfan/requirements.txt.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cython==esyscmd(`printf $(sed "s/[.]p.*//;" ../cython/package-version.txt)')
sagemath-standard==esyscmd(`printf $(sed "s/[.]p.*//;" ../sagelib/package-version.txt)')
1 change: 1 addition & 0 deletions pkgs/sagemath-gfan/sage
11 changes: 11 additions & 0 deletions pkgs/sagemath-gfan/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python

# PEP 517 builds do not have . in sys.path
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))

from sage_setup import sage_setup

sage_setup(['sagemath-gfan'],
spkgs=['gfan'])
123 changes: 123 additions & 0 deletions pkgs/sagemath-gfan/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# To build and test in the tox environment:
#
# ./sage -sh -c '(cd pkgs/sagemath-gfan && tox -v -v -v -e sagepython)'
#
# To test interactively:
#
# pkgs/sagemath-gfan/.tox/sagepython/bin/python
#
[tox]
envlist =
sagepython-sagewheels-nopypi-norequirements

requires =
# Auto-provision a modern tox.
# [pkgenv] added in 4.2 - https://tox.wiki/en/latest/upgrading.html#packaging-configuration-and-inheritance
# Because of https://github.com/tox-dev/tox/issues/3238, need <4.14.1
tox>=4.2
tox<4.14.1

[pkgenv]
# Environment in which to build the sdist.
# https://tox.wiki/en/latest/upgrading.html#packaging-environments
passenv =
# Variables set by .homebrew-build-env
CPATH
LIBRARY_PATH
PKG_CONFIG_PATH
# Parallel build
SAGE_NUM_THREADS
SAGE_NUM_THREADS_PARALLEL
MAKEFLAGS
# SAGE_VENV only for referring to the basepython or finding the wheels
sagepython, sagewheels: SAGE_VENV
# Location of the wheels
sagewheels: SAGE_SPKG_WHEELS

setenv =
# We supply pip options by environment variables so that they
# apply both to the installation of the dependencies and of the package
sagewheels: PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
nopypi: PIP_NO_INDEX=true

[testenv]
deps =
!norequirements: -rrequirements.txt

extras = test

passenv = {[pkgenv]passenv}

setenv = {[pkgenv]setenv}
# Sage scripts such as sage-runtests like to use $HOME/.sage
HOME={envdir}
# Stop 'sage -t --installed' from picking up doc installed in SAGE_LOCAL
SAGE_DOC=/doesnotexist
KNOWN_TEST_FAILURES={toxinidir}/known-test-failures.json
# See src/bin/sage-env
PYDEVD_DISABLE_FILE_VALIDATION=1

allowlist_externals =
bash

commands =
# Beware of the treacherous non-src layout. "./sage/" shadows the installed sage package.
{envpython} -c 'import sys; "" in sys.path and sys.path.remove(""); import sage.all__sagemath_gfan; import sage.rings.polynomial.gfan'

bash -c 'cd $(python -c "import sys; \"\" in sys.path and sys.path.remove(\"\"); from sage.env import SAGE_LIB; print(SAGE_LIB)") \
&& sage-runtests -p --force-lib --initial --environment=sage.all__sagemath_gfan --probe all --baseline-stats-path=$KNOWN_TEST_FAILURES --optional=sage sage/rings/polynomial/groebner_fan.py sage/interfaces/gfan.py'

[testenv:.tox]
# Allow access to PyPI for auto-provisioning a suitable tox version
passenv =
setenv = PIP_NO_INDEX=false

[testenv:.pkg-sagepython]
# Environment in which to build the sdist.
# inherits from [pkgenv] - https://tox.wiki/en/latest/upgrading.html#packaging-environments
basepython = {env:SAGE_VENV}/bin/python3

[testenv:.pkg-sagepython-sagewheels-nopypi]
passenv = {[pkgenv]passenv}
SAGE_VENV
SAGE_SPKG_WHEELS

setenv = {[pkgenv]setenv}
PIP_FIND_LINKS=file://{env:SAGE_SPKG_WHEELS:{env:SAGE_VENV:{toxinidir}/../../../../venv}/var/lib/sage/wheels}
PIP_NO_INDEX=true

basepython = {env:SAGE_VENV}/bin/python3

[testenv:.pkg-sagepython-sagewheels-nopypi-editable]
config_settings_build_editable =
editable_mode = strict


[testenv:sagepython]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython

[testenv:sagepython-sagewheels-nopypi]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython-sagewheels-nopypi

[testenv:sagepython-sagewheels]
basepython = {env:SAGE_VENV}/bin/python
package_env = .pkg-sagepython

[testenv:sagepython-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython


[testenv:sagepython-sagewheels-nopypi-norequirements]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython-sagewheels-nopypi

[testenv:sagepython-sagewheels-nopypi-editable]
basepython = {env:SAGE_VENV}/bin/python3
package_env = .pkg-sagepython-sagewheels-nopypi-editable
package = editable
deps = -r requirements-editable.txt
config_settings_build_editable =
editable_mode = strict
2 changes: 0 additions & 2 deletions pkgs/sagemath-polyhedra/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ include VERSION.txt
exclude *.m4
include requirements.txt

include sage/interfaces/gfan.p*
include sage/interfaces/polymake.p*

graft sage/geometry
Expand All @@ -26,7 +25,6 @@ exclude sage/numerical/gauss_legendre.p* # sagemath-modules
exclude sage/numerical/optimize.p* # sagemath-modules
exclude sage/numerical/backends/glpk*.p* # sagemath-glpk

include sage/rings/polynomial/groebner_fan.p*
include sage/rings/polynomial/omega.py

graft sage/schemes/toric
Expand Down
1 change: 1 addition & 0 deletions src/sage/all__sagemath_gfan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sage_setup: distribution = sagemath-gfan
1 change: 1 addition & 0 deletions src/sage/interfaces/all__sagemath_gfan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sage_setup: distribution = sagemath-gfan
2 changes: 1 addition & 1 deletion src/sage/interfaces/gfan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage_setup: distribution = sagemath-polyhedra
# sage_setup: distribution = sagemath-gfan
r"""
Interface to Groebner Fan
Expand Down
1 change: 1 addition & 0 deletions src/sage/libs/all__sagemath_gfan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sage_setup: distribution = sagemath-gfan
1 change: 1 addition & 0 deletions src/sage/libs/gfan.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sage_setup: distribution = sagemath-gfan
1 change: 1 addition & 0 deletions src/sage/rings/all__sagemath_gfan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sage_setup: distribution = sagemath-gfan
1 change: 1 addition & 0 deletions src/sage/rings/polynomial/all__sagemath_gfan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sage_setup: distribution = sagemath-gfan
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/groebner_fan.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage_setup: distribution = sagemath-polyhedra
# sage_setup: distribution = sagemath-gfan
r"""
Groebner Fans
Expand Down

0 comments on commit 2094923

Please sign in to comment.