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.57 KB
Newer Older
boklm's avatar
boklm committed
1 2 3
#!/usr/bin/perl -w
use strict;
use FindBin;
4
use File::Copy;
boklm's avatar
boklm committed
5
use IO::CaptureOutput qw(qxx);
6
use Cwd;
boklm's avatar
boklm committed
7
use English;
8 9
use lib $FindBin::Bin;
use TBBTestSuite::Common qw(has_bin);
boklm's avatar
boklm committed
10

boklm's avatar
boklm committed
11 12 13 14 15 16 17
sub winpath {
    return $_[0] unless $OSNAME eq 'cygwin';
    my $res = `cygpath -aw $_[0]`;
    chomp $res;
    return $res;
}

18
my $virtenv_marionette_dir = winpath("$FindBin::Bin/virtualenv-marionette-5.0.0");
boklm's avatar
boklm committed
19
my $virtenv_pefile_dir = winpath("$FindBin::Bin/virtualenv-pefile");
boklm's avatar
boklm committed
20 21 22 23 24

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

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

33
my $virtualenv_cmd = has_bin('virtualenv2') ? 'virtualenv2' : 'virtualenv';
boklm's avatar
boklm committed
34
my $bin = 'bin';
35
my $lib = 'lib';
boklm's avatar
boklm committed
36 37
if ($OSNAME eq 'cygwin') {
    $bin = 'Scripts';
38
    $lib = 'Lib';
boklm's avatar
boklm committed
39
    $virtualenv_cmd = "$FindBin::Bin/bundle/python/Scripts/virtualenv.exe";
40 41
    run("$FindBin::Bin/bundle/install_virtualenv.sh")
                                        unless -f $virtualenv_cmd;
boklm's avatar
boklm committed
42 43
}

44 45
unless (-d $virtenv_marionette_dir) {
    run($virtualenv_cmd, $virtenv_marionette_dir);
46 47 48
    # upgrade pip and setuptools
    run("$virtenv_marionette_dir/$bin/pip", 'install', '--upgrade', 'pip');
    run("$virtenv_marionette_dir/$bin/pip", 'install', '--upgrade', 'setuptools');
49 50
    run_from_dir('marionette', "$virtenv_marionette_dir/$bin/python", 'setup.py', 'develop');
}
boklm's avatar
boklm committed
51 52 53 54 55 56 57

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