-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
63 lines (51 loc) · 1.55 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
from setuptools import setup, find_packages
from setuptools.command.install import install
import subprocess
import platform
import sys
def get_virtualenv_path():
"""Used to work out path to install compiled binaries to."""
if hasattr(sys, 'real_prefix'):
return sys.prefix
if hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix:
return sys.prefix
if 'conda' in sys.prefix:
return sys.prefix
return None
def compile_and_install_software():
"""Used the subprocess module to compile/install the C software."""
src_path = 'osmgo/osmconvert/osmconvert.c'
venv = get_virtualenv_path()
if platform.system() == 'Linux':
print('Linux')
cmd = f'cc {src_path} -lz -O3 -o {venv}/bin/osmconvert'
try:
print(cmd)
subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError as e:
print(e.output)
print(cmd)
class CustomInstall(install):
"""Custom handler for the 'install' command."""
def run(self):
compile_and_install_software()
super().run()
setup(
name='osmgo',
version='0.2',
author="Chris Schierkolk",
author_email="[email protected]",
description="Mutliprocessing wrapper for pyrosm",
packages=find_packages(),
cmdclass={'install': CustomInstall},
include_package_data=True,
install_requires=[
'Click',
'Pyrosm',
'geopandas',
],
entry_points='''
[console_scripts]
osmgo=osmgo.cli.cli:cli
''',
)