1
2
3 """ Paver Task Implementation Helpers.
4
5 Copyright (c) 2011 The PyroScope Project <pyroscope.project@gmail.com>
6 """
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import os
21 import sys
22 import pkg_resources
23
24 from paver import easy, tasks
25 from pyrobase import iterutil
26
27
29 """ Get the directory for virtualenv stubs, or a full executable path
30 if C{name} is provided.
31 """
32 if not hasattr(sys, "real_prefix"):
33 easy.error("ERROR: '%s' is not a virtualenv" % (sys.executable,))
34 sys.exit(1)
35
36 for bindir in ("bin", "Scripts"):
37 bindir = os.path.join(sys.prefix, bindir)
38 if os.path.exists(bindir):
39 if name:
40 return os.path.join(bindir, name + os.path.splitext(sys.executable)[1])
41 else:
42 return bindir
43
44 easy.error("ERROR: Scripts directory not found in '%s'" % (sys.prefix,))
45 sys.exit(1)
46
47
48 -def vsh(cmd, *args, **kw):
49 """ Execute a command installed into the active virtualenv.
50 """
51 args = '" "'.join(i.replace('"', r'\"') for i in args)
52 easy.sh('"%s" "%s"' % (venv_bin(cmd), args))
53
54
71
72
74 """ A task decorator that ensures a distutils dependency (or a list thereof) is met
75 before that task is executed.
76 """
77 def entangle(task):
78 "Decorator wrapper."
79 if not isinstance(task, tasks.Task):
80 task = tasks.Task(task)
81
82 def tool_task(*args, **kw):
83 "Install requirements, then call original task."
84 install_tools(dependencies)
85 return task_body(*args, **kw)
86
87
88 task_body, task.func = task.func, tool_task
89 return task
90
91 return entangle
92
93
95 """ Get package list, without sub-packages.
96 """
97 packages = set(easy.options.setup.packages)
98 for pkg in list(packages):
99 packages -= set(p for p in packages if str(p).startswith(pkg + '.'))
100 return list(sorted(packages))
101