setup-virtualenv 859 Bytes
Newer Older
boklm's avatar
boklm committed
1
2
3
4
#!/usr/bin/perl -w
use strict;
use FindBin;
use IO::CaptureOutput qw(qxx);
5
use Cwd;
boklm's avatar
boklm committed
6
use English;
boklm's avatar
boklm committed
7

boklm's avatar
boklm committed
8
9
10
11
12
13
14
15
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");
boklm's avatar
boklm committed
16
17
18
19
20

sub run {
    system(@_) == 0 || die "Error running " . join(' ', @_);
}

21
22
23
24
25
26
27
28
sub run_from_dir {
    my $old_cwd = getcwd;
    chdir shift @_;
    my $res = run(@_);
    chdir $old_cwd;
    return $res;
}

boklm's avatar
boklm committed
29
30
31
32
33
my $virtualenv_cmd = 'virtualenv';
my $bin = 'bin';
if ($OSNAME eq 'cygwin') {
    $bin = 'Scripts';
    $virtualenv_cmd = "$FindBin::Bin/bundle/python/Scripts/virtualenv.exe";
boklm's avatar
boklm committed
34
35
}

boklm's avatar
boklm committed
36
37
run($virtualenv_cmd, $virtenv_marionette_dir) unless -d $virtenv_marionette_dir;
run_from_dir('marionette', "$virtenv_marionette_dir/$bin/python", 'setup.py', 'develop');