Revision 01c1904a
Added by koszko about 1 year ago
| setup.py | ||
|---|---|---|
| 8 | 8 | import setuptools | 
| 9 | 9 |  | 
| 10 | 10 | from setuptools.command.build_py import build_py | 
| 11 | from setuptools.command.sdist import sdist | |
| 12 |  | |
| 13 | from pathlib import Path | |
| 14 |  | |
| 15 | here = Path(__file__).resolve().parent | |
| 11 | 16 |  | 
| 12 | 17 | class CustomBuildCommand(build_py): | 
| 13 | ''' | |
| 14 | The build command but runs babel before build. | |
| 15 | ''' | |
| 18 | """The build command but runs babel before build.""" | |
| 16 | 19 | def run(self, *args, **kwargs): | 
| 20 | """Wrapper around build_py's original run() method.""" | |
| 17 | 21 |         self.run_command('compile_catalog')
 | 
| 22 |  | |
| 23 | super().run(*args, **kwargs) | |
| 24 |  | |
| 25 | class CustomSdistCommand(sdist): | |
| 26 | """ | |
| 27 | The sdist command but prevents compiled message catalogs from being included | |
| 28 | in the archive. | |
| 29 | """ | |
| 30 | def run(self, *args, **kwargs): | |
| 31 | """Wrapper around sdist's original run() method.""" | |
| 32 | locales_dir = here / 'src/hydrilla/builder/locales' | |
| 33 |         locale_files = {}
 | |
| 34 |  | |
| 35 |         for path in locales_dir.rglob('*.mo'):
 | |
| 36 | locale_files[path] = path.read_bytes() | |
| 37 |  | |
| 38 | for path in locale_files: | |
| 39 | path.unlink() | |
| 40 |  | |
| 18 | 41 | super().run(*args, **kwargs) | 
| 19 | 42 |  | 
| 20 | setuptools.setup(cmdclass={'build_py': CustomBuildCommand})
 | |
| 43 | for path, contents in locale_files.items(): | |
| 44 | path.write_bytes(contents) | |
| 45 |  | |
| 46 | setuptools.setup(cmdclass = {
 | |
| 47 | 'build_py': CustomBuildCommand, | |
| 48 | 'sdist': CustomSdistCommand | |
| 49 | }) | |
Also available in: Unified diff
improve packaging of data files
This commit stops setuptools from presenting a depracetion warning.
This commit ensures .mo files will not be included in source distributions.