Create a command class with the given optional prerelease class. Parameters ---------- prerelease_cmd: (name, Command) tuple, optional The command to run before releasing. package_data_spec: dict, optional A dictionary whose keys are the dotted package names and
(prerelease_cmd=None, package_data_spec=None,
data_files_spec=None)
| 138 | |
| 139 | |
| 140 | def create_cmdclass(prerelease_cmd=None, package_data_spec=None, |
| 141 | data_files_spec=None): |
| 142 | """Create a command class with the given optional prerelease class. |
| 143 | |
| 144 | Parameters |
| 145 | ---------- |
| 146 | prerelease_cmd: (name, Command) tuple, optional |
| 147 | The command to run before releasing. |
| 148 | package_data_spec: dict, optional |
| 149 | A dictionary whose keys are the dotted package names and |
| 150 | whose values are a list of glob patterns. |
| 151 | data_files_spec: list, optional |
| 152 | A list of (path, dname, pattern) tuples where the path is the |
| 153 | `data_files` install path, dname is the source directory, and the |
| 154 | pattern is a glob pattern. |
| 155 | |
| 156 | Notes |
| 157 | ----- |
| 158 | We use specs so that we can find the files *after* the build |
| 159 | command has run. |
| 160 | |
| 161 | The package data glob patterns should be relative paths from the package |
| 162 | folder containing the __init__.py file, which is given as the package |
| 163 | name. |
| 164 | e.g. `dict(foo=['./bar/*', './baz/**'])` |
| 165 | |
| 166 | The data files directories should be absolute paths or relative paths |
| 167 | from the root directory of the repository. Data files are specified |
| 168 | differently from `package_data` because we need a separate path entry |
| 169 | for each nested folder in `data_files`, and this makes it easier to |
| 170 | parse. |
| 171 | e.g. `('share/foo/bar', 'pkgname/bizz, '*')` |
| 172 | """ |
| 173 | wrapped = [prerelease_cmd] if prerelease_cmd else [] |
| 174 | if package_data_spec or data_files_spec: |
| 175 | wrapped.append('handle_files') |
| 176 | wrapper = functools.partial(_wrap_command, wrapped) |
| 177 | handle_files = _get_file_handler(package_data_spec, data_files_spec) |
| 178 | |
| 179 | if 'bdist_egg' in sys.argv: |
| 180 | egg = wrapper(bdist_egg, strict=True) |
| 181 | else: |
| 182 | egg = bdist_egg_disabled |
| 183 | |
| 184 | cmdclass = dict( |
| 185 | build_py=wrapper(build_py, strict=is_repo), |
| 186 | bdist_egg=egg, |
| 187 | sdist=wrapper(sdist, strict=True), |
| 188 | handle_files=handle_files, |
| 189 | ) |
| 190 | |
| 191 | if bdist_wheel: |
| 192 | cmdclass['bdist_wheel'] = wrapper(bdist_wheel, strict=True) |
| 193 | |
| 194 | cmdclass['develop'] = wrapper(develop, strict=True) |
| 195 | return cmdclass |
| 196 | |
| 197 |
no test coverage detected