Skip to content

Commit

Permalink
Update setup.py for better handling of static libs
Browse files Browse the repository at this point in the history
  • Loading branch information
EricEngle-NOAA committed Mar 11, 2024
1 parent 93a5c1e commit 6fd8a3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include VERSION
include create_docs.sh
include requirements.txt
graft docs
graft src/ext src/grib2io
graft src/ext
graft src/grib2io
graft tests
global-exclude *.py[cod] *.c *.so
14 changes: 11 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'g2c': ['g2c'],
'aec': ['aec'],
'jasper': ['jasper'],
'jpeg': ['jpegturbo', 'jpeg'],
'jpeg': ['turbojpeg', 'jpeg'],
'openjpeg': ['openjp2'],
'png': ['png'],
'z': ['z'],}
Expand All @@ -32,12 +32,20 @@ def get_package_info(name, config, static=False):
if pkg_dir is None:
# Env var not set
pkg_dir = config.get('directories',name+'_dir',fallback=None)
if pkg_dir is None:
if static:
pkg_lib = config.get('static_libs',name+'_lib',fallback=None)
pkg_libdir = os.path.dirname(pkg_lib)
pkg_incdir = os.path.join(os.path.dirname(pkg_libdir),'include')
pkg_dir = os.path.dirname(pkg_libdir)

if pkg_dir is None:
for l in pkgname_to_libname[name]:
libname = os.path.dirname(find_library(l, static=static))
if libname is not None: break
pkg_libdir = libname
pkg_incdir = os.path.join(os.path.dirname(pkg_libdir),'include')

else:
# Env var was set
if os.path.exists(os.path.join(pkg_dir,'lib')):
Expand Down Expand Up @@ -159,9 +167,9 @@ def find_library(name, dirs=None, static=False):
if usestaticlibs:
l = pkgname_to_libname[l][0]
extra_objects.append(find_library(l, dirs=[libdir], static=usestaticlibs))

libraries = [] if usestaticlibs else list(set(libraries))
incdirs = [] if usestaticlibs else list(set(incdirs))
incdirs = list(set(incdirs))
incdirs.append(numpy.get_include())
libdirs = [] if usestaticlibs else list(set(libdirs))
extra_objects = list(set(extra_objects)) if usestaticlibs else []
Expand Down

0 comments on commit 6fd8a3b

Please sign in to comment.