From 72d6527b6c94281cba0169c3de232e7734d2e8b2 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 29 May 2019 15:48:50 +0200 Subject: [PATCH] work around new import statements generated by swig-4.0 Those statements are not compatible with the fact that libtool-generated modules are in .libs/ until they get installed. * python/spot/__init__.py: Add sys.path to __path__ if SPOT_BUILD is set. * tests/run.in: Set SPOT_BUILD. --- python/spot/__init__.py | 18 ++++++++++++------ tests/run.in | 4 +++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/python/spot/__init__.py b/python/spot/__init__.py index 97c1aa5d9..556a2bf04 100644 --- a/python/spot/__init__.py +++ b/python/spot/__init__.py @@ -20,21 +20,27 @@ import sys - if sys.hexversion < 0x03030000: sys.exit("This module requires Python 3.3 or newer") +import subprocess +import os +import signal +import tempfile +from contextlib import suppress as _supress + +if 'SPOT_UNINSTALLED' in os.environ: + # When Spot is installed, _impl.so will be in the same directory as + # spot/impl.py, however when we run Spot's test suite, Spot is not yet + # installed and we want "from . import _impl" (generated by Swig4) to look + # into .libs/ + __path__.extend(sys.path) from spot.impl import * from spot.aux import \ extend as _extend, \ str_to_svg as _str_to_svg, \ ostream_to_svg as _ostream_to_svg -import subprocess -import os -import signal -import tempfile -from contextlib import suppress as _supress # The parrameters used by default when show() is called on an automaton. diff --git a/tests/run.in b/tests/run.in index ecfff458a..e7ca121b2 100755 --- a/tests/run.in +++ b/tests/run.in @@ -1,6 +1,6 @@ #!/bin/sh # -*- coding: utf-8 -*- -# Copyright (C) 2010, 2011, 2014-2016, 2018 Laboratoire de Recherche +# Copyright (C) 2010, 2011, 2014-2016, 2018, 2019 Laboratoire de Recherche # et Developpement de l'EPITA (LRDE). # Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 # (LIP6), département Systèmes Répartis Coopératifs (SRC), Université @@ -61,6 +61,8 @@ export top_builddir top_srcdir='@abs_top_srcdir@' export top_srcdir +SPOT_UNINSTALLED=1 +export SPOT_UNINSTALLED case $1 in */*)