-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathsetup.py
76 lines (59 loc) · 2.66 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
import subprocess
import sys
from distutils.command.build import build as DistutilsBuild
from distutils.command.build_ext import build_ext as DistutilsBuildExt
from setuptools import setup, Extension
import build
class BuildExt(DistutilsBuildExt):
def run(self):
pass
def build_extension(self, ext):
pass
class BuildError(Exception):
pass
class Build(DistutilsBuild):
def run(self):
self.check_version()
self.build()
def check_version(self):
cmd = ['go', 'help', 'build']
try:
build_help = subprocess.check_output(cmd, stderr=subprocess.STDOUT).rstrip()
except OSError as e:
raise BuildError("""
Unable to execute '{}'. HINT: are you sure `go` is installed?
go_vncdriver requires Go version 1.5 or newer. Here are some hints for Go installation:
- Ubuntu 14.04: The default golang is too old, but you can get a modern one via: "sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable && sudo apt-get update && sudo apt-get install golang"
- Ubuntu 16:04: "sudo apt-get install golang"
- OSX, El Capitan or newer: "brew install golang"
- Other: you can obtain a recent Go build from https://golang.org/doc/install
(DETAIL: original error: {}.)""".format(' '.join(cmd), e))
else:
if 'buildmode' not in str(build_help):
raise RuntimeError("""
Your Go installation looks too old: go_vncdriver requires Go version 1.5 or newer. Here are some hints for Go installation:
- Ubuntu 14.04: The default golang is too old, but you can get a modern one via: "sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable && sudo apt-get update && sudo apt-get install golang"
- Ubuntu 16:04: "sudo apt-get install golang"
- OSX, El Capitan or newer: "brew install golang"
- Other: you can obtain a recent Go build from https://golang.org/doc/install
You can obtain a recent Go build from https://golang.org/doc/install. If on Ubuntu, you can follow: https://github.com/golang/go/wiki/Ubuntu.
(DETAIL: the output of 'go help build' did not include 'buildmode'.)
""")
def build(self):
try:
sys.stderr.write('Running new build\n')
build.build()
except build.BuildException as e:
sys.stderr.write('Could not build go_vncdriver: %s\n' % e)
raise
DistutilsBuild.run(self)
setup(name='go_vncdriver',
version='0.4.19',
cmdclass={'build': Build, 'build_ext': BuildExt},
ext_modules=[Extension('go_vncdriver', [])],
packages=['go_vncdriver'],
package_dir={'go_vncdriver': '.'},
package_data={'go_vncdriver': ['go_vncdriver.so']},
setup_requires=['numpy'],
install_requires=['numpy'],
)