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