pythonPackages.h3: init at 3.4.3

This commit is contained in:
Wael M. Nasreddine 2019-07-16 17:39:52 -07:00 committed by Jon
parent 9d9bba120f
commit ba3aeb1ca1
4 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,35 @@
{ stdenv
, buildPythonPackage
, cmake
, fetchPypi
, h3
, python
}:
buildPythonPackage rec {
pname = "h3";
version = "3.4.3";
src = fetchPypi {
inherit pname version;
sha256 = "07dlqpr1r4kzb3gci395plpss8gxvvrij40l6w0mylyg7fkab4m2";
};
patches = [
./disable-custom-install.patch
./hardcode-h3-path.patch
];
preBuild = ''
substituteInPlace h3/h3.py \
--subst-var-by libh3_path ${h3}/lib/libh3${stdenv.hostPlatform.extensions.sharedLibrary}
'';
meta = with stdenv.lib; {
homepage = "https://github.com/uber/h3-py";
description = "This library provides Python bindings for the H3 Core Library.";
license = licenses.asl20;
platforms = platforms.unix ++ platforms.darwin;
maintainers = [ maintainers.kalbasit ];
};
}

View File

@ -0,0 +1,41 @@
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')

View File

@ -0,0 +1,19 @@
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

View File

@ -717,6 +717,8 @@ in {
gumath = callPackage ../development/python-modules/gumath { }; gumath = callPackage ../development/python-modules/gumath { };
h3 = callPackage ../development/python-modules/h3 { inherit (pkgs) h3; };
h5py = callPackage ../development/python-modules/h5py { h5py = callPackage ../development/python-modules/h5py {
hdf5 = pkgs.hdf5; hdf5 = pkgs.hdf5;
}; };