Skip to content

Commit

Permalink
fix loading on lnx/win
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Sep 19, 2019
1 parent 8a9f48d commit 4ecb31d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 20 deletions.
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
include LICENSE
include pyproject.toml
include geodiff/CMakeLists.txt
include geodiff/src/*
include geodiff/src/*.cpp
include geodiff/src/*.hpp
include geodiff/src/*.h
include pygeodiff/*.py
20 changes: 14 additions & 6 deletions geodiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,17 @@ ENDIF(ENABLE_TESTS)


# install
IF(WIN32)
INSTALL(TARGETS ${GEODIFF_NAME} RUNTIME DESTINATION lib)
ELSE(WIN32)
INSTALL(TARGETS ${GEODIFF_NAME} LIBRARY DESTINATION lib)
ENDIF(WIN32)
INSTALL(FILES src/geodiff.h DESTINATION include)
IF(SKBUILD)
IF(WIN32)
INSTALL(TARGETS ${GEODIFF_NAME} RUNTIME DESTINATION pygeodiff)
ELSE(WIN32)
INSTALL(TARGETS ${GEODIFF_NAME} LIBRARY DESTINATION pygeodiff)
ENDIF(WIN32)
ELSE(SKBUILD)
IF(WIN32)
INSTALL(TARGETS ${GEODIFF_NAME} RUNTIME DESTINATION lib)
ELSE(WIN32)
INSTALL(TARGETS ${GEODIFF_NAME} LIBRARY DESTINATION lib)
ENDIF(WIN32)
INSTALL(FILES src/geodiff.h DESTINATION include)
ENDIF(SKBUILD)
2 changes: 1 addition & 1 deletion geodiff/src/geodiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

const char *GEODIFF_version()
{
return "0.2.3";
return "0.2.6";
}

void _errorLogCallback( void *pArg, int iErrCode, const char *zMsg )
Expand Down
2 changes: 1 addition & 1 deletion pygeodiff/__about__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__title__ = 'PyGeoDiff'
__description__ = 'Diff tool for geo-spatial data'
__url__ = 'https://github.com/lutraconsulting/geodiff'
__version__ = '0.2.3'
__version__ = '0.2.6'
__author__ = 'Peter Petrik'
__author_email__ = '[email protected]'
__maintainer__ = 'Peter Petrik'
Expand Down
26 changes: 21 additions & 5 deletions pygeodiff/geodifflib.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
'''

import ctypes
import os
import platform
from ctypes.util import find_library
from .__about__ import __version__

Expand Down Expand Up @@ -42,14 +44,28 @@ def _parse_return_code(rc, msg):
class GeoDiffLib:
def __init__(self, name):
if name is None:
# try one distributed from wheel
self.libname = find_library('pygeodiff-' + __version__ + '-python')
if self.libname is None:
# try system one
self.libname = find_library('geodiff')
# ok lets assume that the package is installed through PIP
if platform.system() == 'Windows':
prefix = ""
suffix = ".dll"
elif platform.system() == 'Darwin':
prefix = "lib"
suffix = ".dylib"
else:
prefix = "lib"
suffix = ".so"
whl_lib = prefix + 'pygeodiff-' + __version__ + '-python' + suffix
dir_path = os.path.dirname(os.path.realpath(__file__))
self.libname = os.path.join(dir_path, whl_lib)
if not os.path.exists(self.libname):
# not found, try system library
self.libname = find_library("geodiff")
else:
self.libname = name

if self.libname is None:
raise GeoDiffLibVersionError("Unable to locate geodiff library")

self.lib = ctypes.CDLL(self.libname, use_errno=True)
self.init()
self.check_version()
Expand Down
8 changes: 8 additions & 0 deletions pygeodiff/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,11 @@ def apply_changeset(self, base, patched, changeset):
"""
def list_changes(self, changeset):
return self.clib.list_changes(changeset)

def version(self):
return self.clib.version()


def main():
diff_lib = GeoDiff()
print("pygeodiff " + diff_lib.version())
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
#from setuptools import setup
from skbuild import setup

EXCLUDE_FROM_PACKAGES = ["contrib", "docs", "tests*"]
CURDIR = os.path.abspath(os.path.dirname(__file__))

VERSION = '0.2.3'
VERSION = '0.2.6'

setup(
name="pygeodiff",
Expand All @@ -28,15 +25,15 @@
description="Python wrapper around GeoDiff library",
long_description="Python wrapper around GeoDiff library",
url="https://github.com/lutraconsulting/geodiff",
packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES),
packages=["pygeodiff"],
include_package_data=True,
keywords=["diff", "gis", "geo", "geopackage", "merge"],
scripts=[],
entry_points={"console_scripts": ["pygeodiff=pygeodiff.main:main"]},
zip_safe=False,
cmake_args=['-DENABLE_TESTS:BOOL=OFF', '-DENABLE_COVERAGE:BOOL=OFF', '-DBUILD_TOOLS:BOOL=OFF', '-DPYGEODIFFVERSION='+str(VERSION)],
cmake_source_dir="geodiff",
cmake_with_sdist=True,
cmake_with_sdist=False,
test_suite="tests.test_project",
python_requires=">=3.6",
# license and classifier list:
Expand Down

0 comments on commit 4ecb31d

Please sign in to comment.