Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit c52e798

Browse files
author
Frédéric Chapoton
committedMay 22, 2015
Merge branch 'public/ticket/14416' into 6.7
Conflicts: src/module_list.py src/sage/geometry/polytope.py
2 parents e00f17b + faa22c6 commit c52e798

File tree

10 files changed

+1065
-15
lines changed

10 files changed

+1065
-15
lines changed
 

‎build/pkgs/polymake/SPKG.txt

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
= polymake =
2+
3+
== Description ==
4+
5+
polymake started out as a tool for the algorithmic treatment of convex polyhedra. By now it also deals with finite simplicial complexes, tight spans of finite metric spaces, polyhedral surfaces, and other objects.
6+
7+
Website: http://www.math.tu-berlin.de/polymake/
8+
9+
== License ==
10+
11+
GPL V2
12+
13+
== SPKG Maintainers ==
14+
15+
* Michael Abshoff
16+
* Marshall Hampton
17+
18+
== Upstream Contact ==
19+
20+
* Ewgenij Gawrilow and Michael Joswig - see http://www.math.tu-berlin.de/polymake/
21+
22+
== Dependencies ==
23+
24+
* gmp
25+
* cddlib
26+
* lrs
27+
28+
== Special Update/Build Instructions ==
29+
30+
See blow, but the info is outdated and at least partially wrong.
31+
32+
== Changelog ==
33+
34+
=== polymake-2.12 (Timo Kluck, February 28th, 2013) ===
35+
36+
* upgrade to 2.12; depends on boost_cropped >= 1.52.0
37+
38+
=== polymake-2.2.p5 (Michael Abshoff, December 24th, 2008) ===
39+
40+
* convert spkg-install to bash script
41+
* fix version detection of gmp and cddlib so that things do not break with version changes
42+
* write a proper SPKG.txt
43+
* move sources to src
44+
45+
=== polymake-2.2.p4 ===
46+
47+
* previous changes lost to history
48+
49+
--------------------------------------------------------------------------
50+
The info below is outdated and needs to be cleaned up
51+
--------------------------------------------------------------------------
52+
53+
Changes:
54+
55+
1) I deleted the gmp and cddlib directories; but extract them from
56+
the SAGE standard distro when they're needed.
57+
58+
2) If you update gmp or cddlib, you *must* change the spkg-install in
59+
this directory (because it refs specific version numbers).
60+
61+
3) I modified support/configure.pl so it works non-interactively
62+
in the context of SAGE. Here are the diffs:
63+
64+
"diff new_ver orig_ver":
65+
48,51d47
66+
< $Cflags="-I".$ENV{"SAGE_LOCAL"}."/include";
67+
< $CXXflags="-I".$ENV{"SAGE_LOCAL"}."/include";
68+
< $LDflags="-I".$ENV{"SAGE_LOCAL"}."/lib";
69+
<
70+
272c268
71+
< $InstallTop ||= $multi ? "/usr/local/share/polymake" : $ENV{"SAGE_LOCAL"}."/polymake";
72+
---
73+
> $InstallTop ||= $multi ? "/usr/local/share/polymake" : "/usr/local/polymake";
74+
75+
4) After the build process we replace the standard script
76+
perl/polymake by our own. This fixes it so polymake is
77+
*relocatable* (can be moved to another directory safely). In
78+
particular, it uses paths determined by SAGE environment
79+
variables.
80+
81+
==========================================
82+
These are some "notes to self" I made
83+
when writing spkg-install.
84+
85+
Notes:
86+
87+
(1) "make" asks less questions than "make configure"
88+
89+
(2) the make process gets confused and corrupts arguments
90+
passed in that involve environment variables; so make
91+
them into exact paths somehow, e.g.,
92+
93+
-I/home/was/s/local
94+
95+
was@sha:~/s/spkg/build/polymake-2.2$ make
96+
97+
Where should polymake be installed? [/usr/local/polymake] /home/was/s/local/
98+
99+
A program checking for the GNU Multiprecision Library (GMP) couldn't be compiled:
100+
polymake_configure.c:1:17: error: gmp.h: No such file or directory
101+
...
102+
polymake_configure.c:6: error: '__GNU_MP_VERSION_PATCHLEVEL' undeclared (first use in this function)
103+
104+
If you know that the required version of GMP is installed somewhere at your site,
105+
would you like to adjust compiler and linker options,
106+
so that it can be found by the next try? [n] y
107+
108+
Please supply the path to gmp.h in the -I compiler option
109+
and the path to libgmp.a or libgmp.so in the -L linker option
110+
111+
Which additional C++ compiler flags should be used (e.g. choosing specific CPU model)? [none] /home/-I/home/was/s/local/include
112+
113+
Which additional C compiler flags should be used? [-I/home/was/s/local/include]
114+
115+
Which additional linker flags should be used? [none]
116+
117+
-------
118+
119+
After first failure (due to missing libs), do the following:
120+
121+
cd build/external/cdd
122+
ln -s $SAGE_LOCAL/lib/libcddgmp.a .
123+
ln -s $SAGE_LOCAL/lib/libcdd.a .
124+
125+
126+
----------------
127+
128+
For some reason
129+
130+
was@sha:~/s/spkg/build/polymake-2.2/build/external/cdd/src/ext_lib/cdd$ mv globals_gmp.h globals_gmp.h.orig
131+
was@sha:~/s/spkg/build/polymake-2.2/build/external/cdd/src/ext_lib/cdd$ touch globals_gmp.h
132+
was@sha:~/s/spkg/build/polymake-2.2/build/external/cdd/src/ext_lib/cdd$
133+
134+

‎build/pkgs/polymake/checksums.ini

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sha1=a990ea31a68740cbf1aba02d49ec23ef589c173d
2+
md5=f07ecafc7a946001c38cdd20e6434b09
3+
cksum=1918099647
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.12

‎build/pkgs/polymake/spkg-install

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$SAGE_LOCAL" = "" ]; then
4+
echo "SAGE_LOCAL undefined ... exiting";
5+
echo "Maybe run 'sage -sh'?"
6+
exit 1
7+
fi
8+
9+
cd src
10+
11+
./configure --prefix="$SAGE_LOCAL" --with-boost="$SAGE_LOCAL" --with-gmp="$SAGE_LOCAL" \
12+
--with-mpfr="$SAGE_LOCAL" --with-readline="$SAGE_LOCAL" --with-fink=no --without-java
13+
if [ $? -ne 0 ]; then
14+
echo "Failed to configure."
15+
exit 1
16+
fi
17+
18+
make
19+
if [ $? -ne 0 ]; then
20+
echo "Failed to build polymake"
21+
exit 1
22+
fi
23+
24+
make install
25+
if [ $? -ne 0 ]; then
26+
echo "Failed to install polymake"
27+
exit 1
28+
fi
29+
30+

‎src/module_list.py

+2
Original file line numberDiff line numberDiff line change
@@ -2048,8 +2048,10 @@ def uname_specific(name, value, alternative):
20482048

20492049
Extension('sage.schemes.projective.projective_morphism_helper',
20502050
sources = ['sage/schemes/projective/projective_morphism_helper.pyx']),
2051+
20512052
]
20522053

20532054
# Add auto-generated modules
20542055
import sage_setup.autogen.interpreters
20552056
ext_modules += sage_setup.autogen.interpreters.modules
2057+

‎src/sage/geometry/polytope.py

+22-15
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,21 @@
1111
Perl interfaces which make it highly adaptable to individual
1212
needs.'
1313
14-
.. note::
14+
This file is a wrapper for the polymake module, which cannot be
15+
imported by default because it is linked to an optional shared
16+
library
1517
16-
If you have trouble with this module do::
17-
18-
sage: !polymake --reconfigure # not tested
19-
20-
at the command line.
21-
22-
AUTHORS:
23-
24-
- Ewgenij Gawrilow, Michael Joswig: main authors of polymake
25-
26-
- William Stein: Sage interface
2718
"""
2819

2920
########################################################################
30-
# Copyright (C) 2006 William Stein <wstein@gmail.com>
21+
# Copyright (C) 2012 Timo Kluck <tkluck@infty.nl>
22+
# Copyright (C) 2012 William Stein <wstein@gmail.com>
3123
#
3224
# Distributed under the terms of the GNU General Public License (GPL)
3325
#
3426
# http://www.gnu.org/licenses/
3527
########################################################################
3628

37-
3829
from sage.misc.all import SAGE_TMP, tmp_filename
3930
from sage.rings.all import Integer, QQ
4031
from sage.structure.all import Sequence
@@ -354,5 +345,21 @@ def rand01(self, d, n, seed=None):
354345
'%s-dimensional 0/1-polytope with %s random vertices (uniform distribution)'%(d, n))
355346

356347

348+
class PolymakeProxy(object):
349+
# TODO: use some wrapper decorator to make sure that this proxy has
350+
# the right tab completion and docstrings
351+
def __getattr__(self, attr):
352+
try:
353+
import sage.libs.polymake.polymake as pm
354+
except:
355+
raise RuntimeError(
356+
"""Polymake requires the optional polymake package. It can be installed
357+
by typing
358+
359+
sage -i polymake
360+
361+
on the command line""")
362+
return getattr(pm, attr)
363+
357364

358-
polymake = Polymake()
365+
polymake = PolymakeProxy()

‎src/sage/libs/polymake/__init__.py

Whitespace-only changes.

‎src/sage/libs/polymake/defs.pxd

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# distutils: language = c++
2+
3+
from libcpp.string cimport string
4+
from sage.libs.gmp.types cimport mpz_t, mpq_t
5+
6+
cdef extern from "wrap.h" namespace "polymake":
7+
pass
8+
9+
cdef extern from "polymake/Main.h" namespace "polymake":
10+
cdef cppclass Main:
11+
Main(char*)
12+
void set_application(char*)
13+
void set_preference(char*)
14+
void set_custom(char*, int) except +ValueError
15+
16+
cdef extern from "polymake/Main.h":
17+
cdef cppclass PropertyValue:
18+
pass
19+
20+
21+
cdef extern from "polymake/Rational.h" namespace 'polymake':
22+
cdef cppclass Integer:
23+
mpz_t get_rep()
24+
Py_ssize_t strsize(int)
25+
int compare(int)
26+
27+
cdef cppclass Rational:
28+
Rational()
29+
Rational(mpq_t)
30+
mpq_t get_rep()
31+
Rational set(mpq_t)
32+
33+
cdef extern from "polymake/client.h":
34+
cdef extern PerlObject load "perl::Object::load" (char*) except +
35+
cdef cppclass PerlObject "perl::Object":
36+
PerlObject()
37+
PerlObject(char*) except +ValueError
38+
void VoidCallPolymakeMethod(char*) except +ValueError
39+
void save(char*)
40+
PropertyValue take(char*)
41+
PropertyValue give(char*) # do not add except here, see pm_get for why
42+
43+
PerlObject CallPolymakeFunction (char*) except +ValueError
44+
PerlObject CallPolymakeFunction1 "CallPolymakeFunction" \
45+
(char*, int) except +ValueError
46+
PerlObject CallPolymakeFunction2 "CallPolymakeFunction" \
47+
(char*, int, int) except +ValueError
48+
PerlObject CallPolymakeFunction3 "CallPolymakeFunction" \
49+
(char*, int, int, int) except +ValueError
50+
PerlObject* new_PerlObject_from_PerlObject "new perl::Object" (PerlObject)
51+
PerlObject CallPolymakeFunction_PerlObject2 "CallPolymakeFunction" (char*, PerlObject, PerlObject) except +ValueError
52+
bint BoolCallPolymakeFunction_PerlObject2 "CallPolymakeFunction" (char*, PerlObject, PerlObject) except +ValueError
53+
54+
cdef extern from "polymake/SparseMatrix.h" namespace "polymake":
55+
pass
56+
57+
cdef extern from "polymake/Matrix.h" namespace 'polymake':
58+
cdef cppclass MatrixRational "Matrix<Rational>":
59+
MatrixRational()
60+
MatrixRational(int nr, int nc)
61+
void assign(int r, int c, Rational val)
62+
MatrixRational operator|(MatrixRational)
63+
Py_ssize_t rows()
64+
Py_ssize_t cols()
65+
66+
Rational get_element "WRAP_CALL"(MatrixRational, int i, int j)
67+
68+
#cdef extern from "polymake/GenericVector.h" namespace 'polymake':
69+
MatrixRational ones_vector_Rational "ones_vector<Rational>" ()
70+
71+
#cdef extern from "polymake/GenericMatrix.h" namespace 'polymake':
72+
MatrixRational unit_matrix_Rational "unit_matrix<Rational>" (int dim)
73+
74+
75+
void pm_assign "WRAP_OUT" (PropertyValue, MatrixRational)
76+
77+
# the except clause below is fake
78+
# it is used to catch errors in PerlObject.give(), however adding
79+
# the except statement to the declaration of give() makes cython
80+
# split lines like
81+
# pm_get(self.pm_obj.give(prop), pm_res)
82+
# and store the result of give() first. This causes problems since
83+
# PropertyValue doesn't have a default constructor.
84+
void pm_get "WRAP_IN" (PropertyValue, Integer) except +ValueError
85+
void pm_get_String "WRAP_IN" (PropertyValue, string) except +ValueError
86+
void pm_get_Rational "WRAP_IN" (PropertyValue, Rational) except +ValueError
87+
void pm_get_MatrixRational "WRAP_IN" (PropertyValue, MatrixRational) \
88+
except +ValueError
89+
void pm_get_VectorInteger "WRAP_IN" (PropertyValue, VectorInteger) \
90+
except +ValueError
91+
void pm_get_PerlObject "WRAP_IN" (PropertyValue, PerlObject) \
92+
except +ValueError
93+
94+
cdef extern from "polymake/Vector.h" namespace 'polymake':
95+
cdef cppclass VectorInteger "Vector<Integer>":
96+
VectorInteger()
97+
VectorInteger(int nr)
98+
#void assign(int r, int val)
99+
Integer get "operator[]" (int i)
100+
int size()

‎src/sage/libs/polymake/polymake.pyx

+766
Large diffs are not rendered by default.

‎src/sage/libs/polymake/wrap.h

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <polymake/Main.h>
2+
3+
using namespace polymake;
4+
5+
#define WRAP_OUT(x,y) x << y
6+
#define WRAP_IN(x,y) x >> y
7+
#define WRAP_CALL(t, i, j) t(i,j)

0 commit comments

Comments
 (0)
This repository has been archived.