python3Packages.h3: 3.7.0 -> 3.7.1 (#112091)

Co-authored-by: Robert T. McGibbon <rmcgibbo@gmail.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

authored by

Wael Nasreddine
Robert T. McGibbon
Sandro
and committed by
GitHub
28430d1e 35c35e48

+50 -76
+50 -16
pkgs/development/python-modules/h3/default.nix
··· 1 - { lib, stdenv 1 + { autoPatchelfHook 2 2 , buildPythonPackage 3 3 , cmake 4 - , fetchPypi 4 + , cython 5 + , fetchFromGitHub 5 6 , h3 6 - , python 7 + , lib 8 + , numpy 9 + , pytestCheckHook 10 + , scikit-build 11 + , stdenv 7 12 }: 8 13 9 14 buildPythonPackage rec { 10 15 pname = "h3"; 11 - version = "3.7.0"; 16 + version = "3.7.1"; 12 17 13 - src = fetchPypi { 14 - inherit pname version; 15 - sha256 = "cd27fc8ecd9183f93934079b7c986401f499030ff2e2171eace9de462fab561d"; 18 + # pypi version does not include tests 19 + src = fetchFromGitHub { 20 + owner = "uber"; 21 + repo = "h3-py"; 22 + rev = "v${version}"; 23 + sha256 = "sha256-MIVV3kZGsIsaJ/ccJOK3+j1VwkUsZGHS5d1sGOBa1Ec="; 16 24 }; 17 25 18 - patches = [ 19 - ./disable-custom-install.patch 20 - ./hardcode-h3-path.patch 26 + dontConfigure = true; 27 + 28 + checkInputs = [ pytestCheckHook ]; 29 + 30 + nativeBuildInputs = [ 31 + scikit-build cmake cython 32 + ] ++ lib.optionals stdenv.hostPlatform.isLinux [ 33 + # On Linux the .so files ends up referring to libh3.so instead of the full 34 + # Nix store path. I'm not sure why this is happening! On Darwin it works 35 + # fine. 36 + autoPatchelfHook 21 37 ]; 22 38 23 - preBuild = '' 24 - substituteInPlace h3/h3.py \ 25 - --subst-var-by libh3_path ${h3}/lib/libh3${stdenv.hostPlatform.extensions.sharedLibrary} 26 - ''; 39 + # This is not needed per-se, it's only added for autoPatchelfHook to work 40 + # correctly. See the note above ^^ 41 + buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ h3 ]; 42 + 43 + propagatedBuildInputs = [ numpy ]; 44 + 45 + # The following prePatch replaces the h3lib compilation with using the h3 packaged in nixpkgs. 46 + # 47 + # - Remove the h3lib submodule. 48 + # - Patch CMakeLists to avoid building h3lib, and use h3 instead. 49 + prePatch = 50 + let 51 + cmakeCommands = '' 52 + include_directories(${h3}/include/h3) 53 + link_directories(${h3}/lib) 54 + ''; 55 + in '' 56 + rm -r src/h3lib 57 + substituteInPlace CMakeLists.txt --replace "add_subdirectory(src/h3lib)" "${cmakeCommands}" 58 + ''; 59 + 60 + # Extra check to make sure we can import it from Python 61 + pythonImportsCheck = [ "h3" ]; 27 62 28 63 meta = with lib; { 29 64 homepage = "https://github.com/uber/h3-py"; 30 - description = "This library provides Python bindings for the H3 Core Library."; 65 + description = "Hierarchical hexagonal geospatial indexing system"; 31 66 license = licenses.asl20; 32 - platforms = platforms.unix ++ platforms.darwin; 33 67 maintainers = [ maintainers.kalbasit ]; 34 68 }; 35 69 }
-41
pkgs/development/python-modules/h3/disable-custom-install.patch
··· 1 - diff --git a/setup.py b/setup.py 2 - index 8e1c220..45297b6 100644 3 - --- a/setup.py 4 - +++ b/setup.py 5 - @@ -25,20 +25,6 @@ class CustomBuildExtCommand(build_ext): 6 - install_h3(h3_version) 7 - 8 - 9 - -# Tested with wheel v0.29.0 10 - -class BinaryDistribution(Distribution): 11 - - def __init__(self, attrs=None): 12 - - Distribution.__init__(self, attrs) 13 - - # The values used for the name and sources in the Extension below are 14 - - # not important, because we override the build_ext command above. 15 - - # The normal C extension building logic is never invoked, and is 16 - - # replaced with our own custom logic. However, ext_modules cannot be 17 - - # empty, because this signals to other parts of distutils that our 18 - - # package contains C extensions and thus needs to be built for 19 - - # different platforms separately. 20 - - self.ext_modules = [Extension('h3c', [])] 21 - - 22 - - 23 - long_description = open('README.rst').read() 24 - 25 - setup( 26 - @@ -52,14 +38,10 @@ setup( 27 - url='https://github.com/uber/h3-py.git', 28 - packages=find_packages(exclude=['tests', 'tests.*']), 29 - install_requires=[], 30 - - cmdclass={ 31 - - 'build_ext': CustomBuildExtCommand, 32 - - }, 33 - package_data={ 34 - 'h-py': 35 - ['out/*.dylib' if platform.system() == 'Darwin' else ( 36 - 'out/*.dll' if platform.system() == 'Windows' else 37 - 'out/*.so.*')] 38 - }, 39 - - license='Apache License 2.0', 40 - - distclass=BinaryDistribution) 41 - + license='Apache License 2.0')
-19
pkgs/development/python-modules/h3/hardcode-h3-path.patch
··· 1 - diff --git a/h3/h3.py b/h3/h3.py 2 - index 18cf168..2cc7812 100644 3 - --- a/h3/h3.py 4 - +++ b/h3/h3.py 5 - @@ -34,13 +34,7 @@ from ctypes import ( 6 - POINTER, 7 - ) 8 - 9 - -_dirname = os.path.dirname(__file__) 10 - -libh3_path = ('{}/{}'.format(_dirname, 'out/libh3.1.dylib') 11 - - if platform.system() == 'Darwin' else ( 12 - - '{}/{}'.format(_dirname, 'out/h3.dll') if platform.system() == 'Windows' else 13 - - '{}/{}'.format(_dirname, 'out/libh3.so.1'))) 14 - - 15 - -libh3 = cdll.LoadLibrary(libh3_path) 16 - +libh3 = cdll.LoadLibrary('@libh3_path@') 17 - 18 - # Type of an H3 index 19 - H3Index = c_ulonglong