Skip to content

Commit d517e96

Browse files
committed
Fixed Installtion
1 parent 06a9122 commit d517e96

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*~
2+
texture_mapping/texture_mapping
23
_skbuild
34
*.egg/
45
*.egg-info/

setup.py

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import sys
77

88
from setuptools import find_packages
9-
from setuptools import setup
109

1110

1211
version = '0.0.2'
@@ -70,10 +69,43 @@
7069
)
7170

7271

73-
setup(**setup_params)
72+
# https://github.com/skvark/opencv-python/blob/master/setup.py
73+
def install_packages(*requirements):
74+
# No more convenient way until PEP 518 is implemented;
75+
# setuptools only handles eggs
76+
subprocess.check_call(
77+
[sys.executable, "-m", "pip", "install"] + list(requirements)
78+
)
7479

7580

76-
import skbuild # NOQA
81+
# https://github.com/skvark/opencv-python/blob/master/setup.py
82+
def get_or_install(name, version=None):
83+
"""If a package is already installed, build against it. If not, install
7784
85+
"""
86+
# Do not import 3rd-party modules into the current process
87+
import json
88+
js_packages = json.loads(
89+
# valid names & versions are ASCII as per PEP 440
90+
subprocess.check_output(
91+
[sys.executable,
92+
"-m", "pip", "list", "--format", "json"]).decode('ascii'))
93+
try:
94+
[package] = (package for package in js_packages
95+
if package['name'] == name)
96+
except ValueError:
97+
install_packages("%s==%s" % (name, version) if version else name)
98+
return version
99+
else:
100+
return package['version']
78101

79-
skbuild.setup(**setup_params)
102+
103+
def main():
104+
get_or_install('scikit-build')
105+
import skbuild # NOQA
106+
107+
skbuild.setup(**setup_params)
108+
109+
110+
if __name__ == '__main__':
111+
main()

0 commit comments

Comments
 (0)