~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to build/virtualenv/populate_virtualenv.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This Source Code Form is subject to the terms of the Mozilla Public
2
 
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
 
# You can obtain one at http://mozilla.org/MPL/2.0/.
4
 
 
5
 
# This file contains code for populating the virtualenv environment for
6
 
# Mozilla's build system. It is typically called as part of configure.
7
 
 
8
 
from __future__ import with_statement
9
 
import os.path
10
 
import subprocess
11
 
import sys
12
 
import distutils.sysconfig
13
 
 
14
 
def populate_virtualenv(top_source_directory, manifest_filename):
15
 
    """Populate the virtualenv from the contents of a manifest.
16
 
 
17
 
    The manifest file consists of colon-delimited fields. The first field
18
 
    specifies the action. The remaining fields are arguments to that action.
19
 
    The following actions are supported:
20
 
 
21
 
      setup.py -- Invoke setup.py for a package. Expects the arguments:
22
 
        1. relative path directory containing setup.py.
23
 
        2. argument(s) to setup.py. e.g. "develop". Each program argument is
24
 
           delimited by a colon. Arguments with colons are not yet supported.
25
 
 
26
 
    Note that the Python interpreter running this function should be the one
27
 
    from the virtualenv. If it is the system Python or if the environment is
28
 
    not configured properly, packages could be installed into the wrong place.
29
 
    This is how virtualenv's work.
30
 
    """
31
 
    packages = []
32
 
    fh = open(manifest_filename, 'rU')
33
 
    for line in fh:
34
 
        packages.append(line.rstrip().split(':'))
35
 
    fh.close()
36
 
 
37
 
    for package in packages:
38
 
        if package[0] == 'setup.py':
39
 
            assert len(package) >= 2
40
 
 
41
 
            call_setup(os.path.join(top_source_directory, package[1]),
42
 
                package[2:])
43
 
        if package[0].endswith('.pth'):
44
 
            assert len(package) == 2
45
 
 
46
 
            with open(os.path.join(distutils.sysconfig.get_python_lib(), package[0]), 'a') as f:
47
 
                f.write("%s\n" % os.path.join(top_source_directory, package[1]))
48
 
 
49
 
def call_setup(directory, arguments):
50
 
    """Calls setup.py in a directory."""
51
 
    setup = os.path.join(directory, 'setup.py')
52
 
 
53
 
    program = [sys.executable, setup]
54
 
    program.extend(arguments)
55
 
 
56
 
    # We probably could call the contents of this file inside the context of
57
 
    # this interpreter using execfile() or similar. However, if global
58
 
    # variables like sys.path are adjusted, this could cause all kinds of
59
 
    # havoc. While this may work, invoking a new process is safer.
60
 
    result = subprocess.call(program, cwd=directory)
61
 
 
62
 
    if result != 0:
63
 
        raise Exception('Error installing package: %s' % directory)
64
 
 
65
 
# configure invokes us with /path/to/topsrcdir and /path/to/manifest
66
 
if __name__ == '__main__':
67
 
    assert len(sys.argv) == 3
68
 
 
69
 
    populate_virtualenv(sys.argv[1], sys.argv[2])
70
 
    sys.exit(0)