forked from uber/h3-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
65 lines (54 loc) · 2.24 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import sys
import platform
import subprocess
from setuptools import setup, find_packages
from setuptools.command.build_ext import build_ext
from setuptools.dist import Distribution
from setuptools.extension import Extension
from h3_version import h3_version
from binding_version import binding_version
def install_h3(h3_version):
# Recommended by Python docs for determining the 64-bit-ness of the current
# interpreter. Needed for invoking CMake correctly on Windows.
is_64bits = sys.maxsize > 2**32
subprocess.check_call('bash ./.install.sh {} {}'.format(h3_version, is_64bits), shell=True)
class CustomBuildExtCommand(build_ext):
"""Overloads the run function of the standard `build_ext` command class"""
def run(self):
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(
name='h3',
version=binding_version,
description=
'Python bindings for H3, a hierarchical hexagonal geospatial indexing system developed by Uber Technologies',
long_description=long_description,
author='Uber Technologies',
author_email='Niel Hu <[email protected]>',
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)