-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.py
111 lines (91 loc) · 3.03 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from __future__ import print_function
import distutils.spawn
import shlex
import subprocess
import sys
from setuptools import find_packages
version = '0.0.8'
if sys.argv[-1] == 'release':
if not distutils.spawn.find_executable('twine'):
print(
'Please install twine:\n\n\tpip install twine\n',
file=sys.stderr,
)
sys.exit(1)
commands = [
'git tag v{:s}'.format(version),
'git push origin master --tag',
'python setup.py sdist',
'twine upload dist/texture-mapping-{:s}.tar.gz'.format(version),
]
for cmd in commands:
print('+ {}'.format(cmd))
subprocess.check_call(shlex.split(cmd))
sys.exit(0)
setup_requires = [
]
install_requires = [
'scikit-build',
'pillow',
]
setup_params = dict(
name="texture-mapping",
version=version,
description="PCL Texture Mapping Wrapper of Python",
author='iory',
author_email='[email protected]',
url='https://github.com/iory/texture-mapping',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
license="MIT",
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
],
packages=find_packages(),
setup_requires=setup_requires,
install_requires=install_requires,
entry_points={
'console_scripts':
['texture-mapping=texture_mapping.apps.mapping:main']}
)
# https://github.com/skvark/opencv-python/blob/master/setup.py
def install_packages(*requirements):
# No more convenient way until PEP 518 is implemented;
# setuptools only handles eggs
subprocess.check_call(
[sys.executable, "-m", "pip", "install"] + list(requirements)
)
# https://github.com/skvark/opencv-python/blob/master/setup.py
def get_or_install(name, version=None):
"""If a package is already installed, build against it. If not, install
"""
# Do not import 3rd-party modules into the current process
import json
js_packages = json.loads(
# valid names & versions are ASCII as per PEP 440
subprocess.check_output(
[sys.executable,
"-m", "pip", "list", "--format", "json"]).decode('ascii'))
try:
[package] = (package for package in js_packages
if package['name'] == name)
except ValueError:
install_packages("%s==%s" % (name, version) if version else name)
return version
else:
return package['version']
def main():
get_or_install('scikit-build')
import skbuild # NOQA
skbuild.setup(**setup_params)
if __name__ == '__main__':
main()