Opened 7 years ago

Closed 7 years ago

#3257 closed defect (fixed)

Do not require ctypes for compilation in temporal modules

Reported by: wenzeslaus Owned by: grass-dev@…
Priority: normal Milestone: 7.2.1
Component: Temporal Version: unspecified
Keywords: ctypes, compilation, build, homebrew, brew, conda, macos, osx, v.what.strds, t.create Cc:
CPU: Unspecified Platform: All

Description

The temporal modules require ctypes even during compilation. This makes the whole compilation more fragile. When ctypes fails compilation fails. This currently happens for example with Homebrew on Mac or in Conda environment (see below examples of error messages). The errors are somewhere else and the modules won't work, but I think the failure should come only when user actually needs them. The temporal modules should not break the build with ctypes not present or the dynamic libraries broken.

The list of directories with errors:

/usr/local/src/grass/scripts/v.what.strds
/usr/local/src/grass/temporal/t.create
/usr/local/src/grass/temporal/t.support
...
/usr/local/src/grass/temporal/t.vect.what.strds
/usr/local/src/grass/temporal/t.vect.observe.strds
/usr/local/src/grass/temporal/t.vect.univar

Examples of actual errors:

Traceback (most recent call last):
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.what.strds", line 53, in <module>
	import grass.temporal as tgis
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/init.py", line 3, in <module>
	from .core import *
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/core.py", line 44, in <module>
	from .c_libraries_interface import *
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/c_libraries_interface.py", line 23, in <module>
	import grass.lib.vector as libvector
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/vector.py", line 23, in <module>
	_libs["grass_vector.7.3.svn"] = load_library("grass_vector.7.3.svn")
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_loader.py", line 62, in load_library
	return self.load(path)
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_loader.py", line 78, in load
	raise ImportError(e)
ImportError: /home/main/anaconda2/bin/../lib/libgfortran.so.3: version `GFORTRAN_1.4' not found (required by /usr/lib/liblapack.so.3)
make[3]: *** [v.what.strds.tmp.html] Error 1
../../include/Make/Html.make:14: recipe for target 'v.what.strds.tmp.html' failed
Traceback (most recent call last):
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/scripts/v.what.strds", line 53, in <module>
	import grass.temporal as tgis
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/init.py", line 3, in <module>
	from .core import *
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/core.py", line 44, in <module>
	from .c_libraries_interface import *
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/c_libraries_interface.py", line 23, in <module>
	import grass.lib.vector as libvector
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/vector.py", line 23, in <module>
	_libs["grass_vector.7.3.svn"] = load_library("grass_vector.7.3.svn")
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_loader.py", line 62, in load_library
	return self.load(path)
  File "/usr/local/src/grass/dist.x86_64-pc-linux-gnu/etc/python/grass/lib/ctypes_loader.py", line 78, in load
	raise ImportError(e)
ImportError: /usr/lib/libgdal.so.1: undefined symbol: sqlite3_column_table_name
../../include/Make/Html.make:14: recipe for target 'v.what.strds.tmp.html' failed
make[3]: *** [v.what.strds.tmp.html] Error 1
ImportError...image not found...library not loaded libgis_datetime...

Change History (4)

comment:1 by wenzeslaus, 7 years ago

In 70357:

use lazy imports for the temporal package

This avoids ctypes-related issues during compilation (see #3257).

Using beginning of main function if possible.
If not adding to the if name... global part with a note
about imports being at the end of the file.
Adding pygrass imports if used (even modules import ctypes through init.py).

comment:2 by neteler, 7 years ago

Backport this...?

comment:3 by wenzeslaus, 7 years ago

In 70588:

use lazy imports for the temporal package (backport r70357, see #3257)

comment:4 by wenzeslaus, 7 years ago

Resolution: fixed
Status: newclosed

It likely fixes much more than it potentially breaks. Backported to 7.2 branch. Will be in 7.2.1.

Note: See TracTickets for help on using tickets.