|
6 | 6 | skipped if any of the dependencies did fail or has been skipped.
|
7 | 7 | """
|
8 | 8 |
|
| 9 | +__version__ = "0.2" |
| 10 | + |
9 | 11 | import sys
|
10 | 12 | if sys.version_info < (2, 7):
|
11 | 13 | raise RuntimeError("You are using Python %s.\n"
|
12 | 14 | "Please apply python2_6.patch first."
|
13 | 15 | % sys.version.split()[0])
|
| 16 | +import os |
| 17 | +import os.path |
| 18 | +import re |
14 | 19 | from setuptools import setup
|
| 20 | +import setuptools.command.sdist as st_sdist |
| 21 | + |
| 22 | + |
| 23 | +def _filter_file(src, dest, subst): |
| 24 | + """Copy src to dest doing substitutions on the fly. |
| 25 | + """ |
| 26 | + substre = re.compile(r'\$(%s)' % '|'.join(subst.keys())) |
| 27 | + def repl(m): |
| 28 | + return subst[m.group(1)] |
| 29 | + with open(src, "rt") as sf, open(dest, "wt") as df: |
| 30 | + while True: |
| 31 | + l = sf.readline() |
| 32 | + if not l: |
| 33 | + break |
| 34 | + df.write(re.sub(substre, repl, l)) |
| 35 | + |
| 36 | +class sdist(st_sdist.sdist): |
| 37 | + def make_release_tree(self, base_dir, files): |
| 38 | + st_sdist.sdist.make_release_tree(self, base_dir, files) |
| 39 | + if not self.dry_run: |
| 40 | + src = "pytest_dependency.py" |
| 41 | + dest = os.path.join(base_dir, src) |
| 42 | + if hasattr(os, 'link') and os.path.exists(dest): |
| 43 | + os.unlink(dest) |
| 44 | + subst = {'DOC': __doc__, 'VERSION': __version__} |
| 45 | + _filter_file(src, dest, subst) |
15 | 46 |
|
16 | 47 |
|
17 | 48 | setup(
|
18 | 49 | name='pytest-dependency',
|
19 |
| - version='0.2', |
| 50 | + version=__version__, |
20 | 51 | description='Manage dependencies of tests',
|
21 | 52 | author='Rolf Krahl',
|
22 | 53 |
|
|
51 | 82 | 'dependency = pytest_dependency',
|
52 | 83 | ],
|
53 | 84 | },
|
| 85 | + cmdclass = {'sdist': sdist}, |
54 | 86 | )
|
0 commit comments