1 # |
|
2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 # Script for generating the egg-info directories for all needed plug-ins. |
|
18 # |
|
19 # This is needed, because running some of the tests from Eclipse or |
|
20 # command line requires the egg-info dirs to be present for the plug-ins |
|
21 # to be found. |
|
22 |
|
23 import sys, os, subprocess, shutil |
|
24 |
|
25 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
|
26 DEBUG = False |
|
27 |
|
28 def generate_egg_info(path): |
|
29 """Generate egg-info for the given plug-in path if possible and necessary.""" |
|
30 if not os.path.isdir(path) or "setup.py" not in os.listdir(path): |
|
31 return |
|
32 |
|
33 # Check if egg-info has already been generated |
|
34 for name in os.listdir(path): |
|
35 egg_info_path = os.path.join(path, name) |
|
36 if os.path.isdir(egg_info_path) and name.endswith('.egg-info'): |
|
37 # xxx.egg-info is present in the directory, check if it is old |
|
38 setup_py_path = os.path.join(path, 'setup.py') |
|
39 if os.stat(setup_py_path).st_mtime < os.stat(egg_info_path).st_mtime: |
|
40 if DEBUG: print "No need to generate egg-info for '%s'" % path |
|
41 return |
|
42 else: |
|
43 if DEBUG: print "egg-info for '%s' is out of date, removing old and generating new" % path |
|
44 shutil.rmtree(egg_info_path) |
|
45 |
|
46 # Run the egg-info generation command |
|
47 orig_workdir = os.getcwd() |
|
48 try: |
|
49 if DEBUG: print "Generating egg-info for '%s'..." % path |
|
50 os.chdir(path) |
|
51 p = subprocess.Popen("python setup.py egg_info", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
|
52 out, err = p.communicate() |
|
53 if p.returncode != 0: |
|
54 print >>sys.stderr, "Could not generate egg-info for '%s'!" % path |
|
55 print >>sys.stderr, "Command stdout output:" |
|
56 print >>sys.stderr, out |
|
57 print >>sys.stderr, "Command stderr output:" |
|
58 print >>sys.stderr, err |
|
59 else: |
|
60 if DEBUG: |
|
61 print "Done" |
|
62 print "Command output:" |
|
63 print out |
|
64 finally: |
|
65 os.chdir(orig_workdir) |
|