-
Notifications
You must be signed in to change notification settings - Fork 7
/
wscript
69 lines (56 loc) · 2.85 KB
/
wscript
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
#!/usr/bin/env python
# coding: utf-8
from waflib.Build import POST_LAZY
import socket
# See: https://stackoverflow.com/questions/20913411/test-if-an-internet-connection-is-present-in-python
REMOTE_SERVER = "www.google.com"
def is_connected(hostname):
try:
# see if we can resolve the host name -- tells us if there is
# a DNS listening
host = socket.gethostbyname(hostname)
# connect to the host -- tells us if the host is actually
# reachable
s = socket.create_connection((host, 80), 2)
return True
except:
pass
def build(ctx):
if ctx.cmd == 'install':
if not ctx.env.BUILD_CONDA:
raise Exception('not building conda package; Conda (https://www.anaconda.com/download/) is missing')
if not is_connected(REMOTE_SERVER):
raise Exception('Internet connection required to build the conda package. Please check your connection.')
ctx.add_group('group1')
ctx.add_group('group2')
ctx.add_group('group3')
ctx.add_group('group4')
ctx.add_group('group5')
ctx.add_group('group6')
ctx.add_group('group7')
ctx.post_mode = POST_LAZY
top = ctx.srcnode.abspath()
install_dir = ctx.env.EXEC_PREFIX
cmd1 = "echo Building the conda package, this takes several minutes..."
cmd2 = '%s install -y anaconda-client conda-build || echo "Tried to install the anaconda-client and the conda-build package"' % (ctx.env.get_flat('CONDA'))
cmd3 = 'export WITHOUT_WAF=' + str(int(not ctx.env.EMBED_LATNET_CONDA)) + \
' && export LATNETBUILDER_INSTALL_DIR=' + install_dir + \
' && %s config --add channels conda-forge && %s build python-wrapper/conda_recipe' % (ctx.env.get_flat('CONDA'), ctx.env.get_flat('CONDA'))
cmd4 = 'echo Installing the conda package, this could take a few minutes...'
cmd5 = 'conda create -y -n latnetbuilder || echo "Tried to create latnetbuilder environment"'
cmd6 = 'conda remove -y latnetbuilder -n latnetbuilder || echo "Tried to remove package latnetbuilder from environment latnetbuilder"'
cmd7 = 'conda install -y --use-local latnetbuilder -n latnetbuilder'
ctx.set_group('group1')
ctx(rule = cmd1, source = 'wscript', cwd = top, always = True)
ctx.set_group('group2')
ctx(rule = cmd2, source = 'wscript', cwd = top, always = True)
ctx.set_group('group3')
ctx(rule = cmd3, source = 'wscript', cwd = top, always = True)
ctx.set_group('group4')
ctx(rule = cmd4, source = 'wscript', always = True)
ctx.set_group('group5')
ctx(rule = cmd5, source = 'wscript', always = True)
ctx.set_group('group6')
ctx(rule = cmd6, source = 'wscript', always = True)
ctx.set_group('group7')
ctx(rule = cmd7, source = 'wscript', always = True)