|
5 | 5 |
|
6 | 6 | from setuptools import setup, find_packages
|
7 | 7 |
|
8 |
| -from distutils.util import convert_path |
9 |
| -from fnmatch import fnmatchcase |
10 |
| - |
11 |
| -import os |
12 |
| -import sys |
13 |
| - |
14 |
| -############################################################################## |
15 |
| -# find_package_data is an Ian Bicking creation. |
16 |
| - |
17 |
| -# Provided as an attribute, so you can append to these instead |
18 |
| -# of replicating them: |
19 |
| -standard_exclude = ('*.py', '*.pyc', '*~', '.*', '*.bak', '*.swp*') |
20 |
| -standard_exclude_directories = ('.*', 'CVS', '_darcs', './build', |
21 |
| - './dist', 'EGG-INFO', '*.egg-info') |
22 |
| - |
23 |
| - |
24 |
| -def find_package_data( |
25 |
| - where='.', package='', |
26 |
| - exclude=standard_exclude, |
27 |
| - exclude_directories=standard_exclude_directories, |
28 |
| - only_in_packages=True, |
29 |
| - show_ignored=False): |
30 |
| - """ |
31 |
| - Return a dictionary suitable for use in ``package_data`` |
32 |
| - in a distutils ``setup.py`` file. |
33 |
| -
|
34 |
| - The dictionary looks like:: |
35 |
| -
|
36 |
| - {'package': [files]} |
37 |
| -
|
38 |
| - Where ``files`` is a list of all the files in that package that |
39 |
| - don't match anything in ``exclude``. |
40 |
| -
|
41 |
| - If ``only_in_packages`` is true, then top-level directories that |
42 |
| - are not packages won't be included (but directories under packages |
43 |
| - will). |
44 |
| -
|
45 |
| - Directories matching any pattern in ``exclude_directories`` will |
46 |
| - be ignored; by default directories with leading ``.``, ``CVS``, |
47 |
| - and ``_darcs`` will be ignored. |
48 |
| -
|
49 |
| - If ``show_ignored`` is true, then all the files that aren't |
50 |
| - included in package data are shown on stderr (for debugging |
51 |
| - purposes). |
52 |
| -
|
53 |
| - Note patterns use wildcards, or can be exact paths (including |
54 |
| - leading ``./``), and all searching is case-insensitive. |
55 |
| -
|
56 |
| - This function is by Ian Bicking. |
57 |
| - """ |
58 |
| - |
59 |
| - out = {} |
60 |
| - stack = [(convert_path(where), '', package, only_in_packages)] |
61 |
| - while stack: |
62 |
| - where, prefix, package, only_in_packages = stack.pop(0) |
63 |
| - for name in os.listdir(where): |
64 |
| - fn = os.path.join(where, name) |
65 |
| - if os.path.isdir(fn): |
66 |
| - bad_name = False |
67 |
| - for pattern in exclude_directories: |
68 |
| - if (fnmatchcase(name, pattern) |
69 |
| - or fn.lower() == pattern.lower()): |
70 |
| - bad_name = True |
71 |
| - if show_ignored: |
72 |
| - print >> sys.stderr, ( |
73 |
| - "Directory %s ignored by pattern %s" |
74 |
| - % (fn, pattern)) |
75 |
| - break |
76 |
| - if bad_name: |
77 |
| - continue |
78 |
| - if os.path.isfile(os.path.join(fn, '__init__.py')): |
79 |
| - if not package: |
80 |
| - new_package = name |
81 |
| - else: |
82 |
| - new_package = package + '.' + name |
83 |
| - stack.append((fn, '', new_package, False)) |
84 |
| - else: |
85 |
| - stack.append((fn, prefix + name + '/', package, only_in_packages)) |
86 |
| - elif package or not only_in_packages: |
87 |
| - # is a file |
88 |
| - bad_name = False |
89 |
| - for pattern in exclude: |
90 |
| - if (fnmatchcase(name, pattern) |
91 |
| - or fn.lower() == pattern.lower()): |
92 |
| - bad_name = True |
93 |
| - if show_ignored: |
94 |
| - print >> sys.stderr, ( |
95 |
| - "File %s ignored by pattern %s" |
96 |
| - % (fn, pattern)) |
97 |
| - break |
98 |
| - if bad_name: |
99 |
| - continue |
100 |
| - out.setdefault(package, []).append(prefix+name) |
101 |
| - return out |
102 |
| -############################################################################## |
103 |
| - |
104 | 8 | setup(
|
105 | 9 | name=PROJECT,
|
106 | 10 | version=VERSION,
|
@@ -130,13 +34,6 @@ def find_package_data(
|
130 | 34 |
|
131 | 35 | packages=find_packages(),
|
132 | 36 | include_package_data=True,
|
133 |
| - # Scan the input for package information |
134 |
| - # to grab any data files (text, images, etc.) |
135 |
| - # associated with sub-packages. |
136 |
| - package_data=find_package_data('mytemplates', |
137 |
| - package='mytemplates', |
138 |
| - only_in_packages=False, |
139 |
| - ), |
140 | 37 |
|
141 | 38 | entry_points={
|
142 | 39 | 'virtualenvwrapper.project.template': [
|
|
0 commit comments