Skip to content

Commit fa0c93f

Browse files
author
Release Manager
committed
Trac #33467: sage.geometry: Use PalpExecutable(...).absolute_filename()
This is so that the Sage library becomes fully functional even when not being run from within sage-env (which sets PATH). To test: {{{ $ venv/bin/python3 -c 'from sage.all import *; print(lattice_polytope.cr oss_polytope(3).polar().facets()[0].ambient_point_indices())' $ venv/bin/python3 -c 'from sage.all import *; from sage.geometry.polyhedron.palp_database import PALPreader; print(next(iter(PALPreader(2, output="list"))))' }}} URL: https://trac.sagemath.org/33467 Reported by: mkoeppe Ticket author(s): Matthias Koeppe Reviewer(s): Dima Pasechnik
2 parents b9155bf + 4b58ad6 commit fa0c93f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/sage/geometry/lattice_polytope.py

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117

118118
from sage.misc.lazy_import import lazy_import
119119
from sage.features import PythonModule
120+
from sage.features.palp import PalpExecutable
120121
lazy_import('ppl', ['C_Polyhedron', 'Generator_System', 'Linear_Expression'],
121122
feature=PythonModule("ppl", spkg="pplpy"))
122123
lazy_import('ppl', 'point', as_='PPL_point',
@@ -146,6 +147,7 @@
146147
from collections.abc import Hashable
147148
from copyreg import constructor as copyreg_constructor
148149
import os
150+
import shlex
149151
from subprocess import Popen, PIPE
150152
from warnings import warn
151153
from functools import reduce
@@ -5105,6 +5107,11 @@ def _palp(command, polytopes, reduce_dimension=False):
51055107
if _palp_dimension is not None:
51065108
dot = command.find(".")
51075109
command = command[:dot] + "-%dd" % _palp_dimension + command[dot:]
5110+
executable, args = command.split(" ", 1)
5111+
if executable.endswith('.x'):
5112+
executable = executable[:-2]
5113+
executable = PalpExecutable(executable).absolute_filename()
5114+
command = " ".join([shlex.quote(executable), args])
51085115
input_file_name = tmp_filename()
51095116
input_file = open(input_file_name, "w")
51105117
for p in polytopes:

src/sage/geometry/polyhedron/palp_database.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
from sage.structure.sage_object import SageObject
3737
from sage.rings.integer_ring import ZZ
38+
from sage.features.palp import PalpExecutable
3839

3940
from sage.interfaces.process import terminate
4041

@@ -134,7 +135,7 @@ def _palp_Popen(self):
134135
<...Popen...>
135136
"""
136137

137-
return Popen(["class.x", "-b2a", "-di", self._data_basename],
138+
return Popen([PalpExecutable("class").absolute_filename(), "-b2a", "-di", self._data_basename],
138139
stdout=PIPE, encoding='utf-8', errors='surrogateescape')
139140

140141
def _read_vertices(self, stdout, rows, cols):
@@ -459,7 +460,7 @@ def _palp_Popen(self):
459460
<...Popen...>
460461
"""
461462

462-
return Popen(['class-4d.x', '-He',
463+
return Popen([PalpExecutable('class-4d').absolute_filename(), '-He',
463464
'H{}:{}L100000000'.format(self._h21, self._h11),
464465
'-di', self._data_basename], stdout=PIPE,
465466
encoding='utf-8', errors='surrogateescape')

0 commit comments

Comments
 (0)