Skip to content

Commit 07eab50

Browse files
committed
Search for PARI data directory using gp path
1 parent 70e2e55 commit 07eab50

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

autogen/parser.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ def pari_share():
4040
out = gp.communicate(b"print(default(datadir))")[0]
4141
datadir = out.strip()
4242
if not os.path.isdir(datadir):
43-
raise EnvironmentError("PARI data directory {!r} does not exist".format(datadir))
43+
# As a fallback, try a path relative to the gp executable.
44+
# This is useful for broken Conda versions, see
45+
# https://github.com/conda-forge/pari-feedstock/issues/4
46+
from distutils.spawn import find_executable
47+
gppath = find_executable("gp")
48+
if gppath is not None:
49+
datadir = os.path.join(os.path.dirname(gppath), "..", "share", "pari")
50+
if not os.path.isdir(datadir):
51+
raise EnvironmentError("PARI data directory {!r} does not exist".format(datadir))
4452
return datadir
4553

4654

0 commit comments

Comments
 (0)