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.66 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;
boklm's avatar
boklm committed
8

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

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

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

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

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

42 43 44
unless (-d $virtenv_marionette_dir) {
    run($virtualenv_cmd, $virtenv_marionette_dir);
    run_from_dir('marionette', "$virtenv_marionette_dir/$bin/python", 'setup.py', 'develop');
45 46 47 48
    # Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1345274
    my $marionette_runner_dir = "$virtenv_marionette_dir/$lib/python2.7/site-packages/marionette_harness-4.0.0-py2.7.egg/marionette_harness/runner/";
    copy "$FindBin::Bin/data/marionette_certs/test.cert", $marionette_runner_dir;
    copy "$FindBin::Bin/data/marionette_certs/test.key", $marionette_runner_dir;
49
}
boklm's avatar
boklm committed
50 51 52 53 54 55 56

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