GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

setup-virtualenv 1.22 KB
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
my $virtenv_pefile_dir = winpath("$FindBin::Bin/virtualenv-pefile");
boklm's avatar
boklm committed
17 18 19 20 21

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

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

boklm's avatar
boklm committed
30 31 32 33 34
my $virtualenv_cmd = 'virtualenv';
my $bin = 'bin';
if ($OSNAME eq 'cygwin') {
    $bin = 'Scripts';
    $virtualenv_cmd = "$FindBin::Bin/bundle/python/Scripts/virtualenv.exe";
35 36
    run("$FindBin::Bin/bundle/install_virtualenv.sh")
                                        unless -f $virtualenv_cmd;
boklm's avatar
boklm committed
37 38
}

39 40 41 42
unless (-d $virtenv_marionette_dir) {
    run($virtualenv_cmd, $virtenv_marionette_dir);
    run_from_dir('marionette', "$virtenv_marionette_dir/$bin/python", 'setup.py', 'develop');
}
boklm's avatar
boklm committed
43 44 45 46 47 48 49

if ($OSNAME eq 'cygwin') {
    unless (-d $virtenv_pefile_dir) {
        run($virtualenv_cmd, $virtenv_pefile_dir);
        run("$virtenv_pefile_dir/$bin/pip", 'install', 'pefile');
    }
}