-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-virtualenv
executable file
·57 lines (50 loc) · 1.57 KB
/
setup-virtualenv
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
#!/usr/bin/perl -w
use strict;
use FindBin;
use File::Copy;
use IO::CaptureOutput qw(qxx);
use Cwd;
use English;
use lib $FindBin::Bin;
use TBBTestSuite::Common qw(has_bin);
sub winpath {
return $_[0] unless $OSNAME eq 'cygwin';
my $res = `cygpath -aw $_[0]`;
chomp $res;
return $res;
}
my $virtenv_marionette_dir = winpath("$FindBin::Bin/virtualenv-marionette-5.0.0");
my $virtenv_pefile_dir = winpath("$FindBin::Bin/virtualenv-pefile");
sub run {
system(@_) == 0 || die "Error running " . join(' ', @_);
}
sub run_from_dir {
my $old_cwd = getcwd;
chdir shift @_;
my $res = run(@_);
chdir $old_cwd;
return $res;
}
my $virtualenv_cmd = has_bin('virtualenv2') ? 'virtualenv2' : 'virtualenv';
my $bin = 'bin';
my $lib = 'lib';
if ($OSNAME eq 'cygwin') {
$bin = 'Scripts';
$lib = 'Lib';
$virtualenv_cmd = "$FindBin::Bin/bundle/python/Scripts/virtualenv.exe";
run("$FindBin::Bin/bundle/install_virtualenv.sh")
unless -f $virtualenv_cmd;
}
unless (-d $virtenv_marionette_dir) {
run($virtualenv_cmd, $virtenv_marionette_dir);
# upgrade pip and setuptools
run("$virtenv_marionette_dir/$bin/pip", 'install', '--upgrade', 'pip');
run("$virtenv_marionette_dir/$bin/pip", 'install', '--upgrade', 'setuptools');
run_from_dir('marionette', "$virtenv_marionette_dir/$bin/python", 'setup.py', 'develop');
}
if ($OSNAME eq 'cygwin') {
unless (-d $virtenv_pefile_dir) {
run($virtualenv_cmd, $virtenv_pefile_dir);
run("$virtenv_pefile_dir/$bin/pip", 'install', 'pefile');
}
}