diff options
author | John Mulligan <jmulligan@redhat.com> | 2023-08-10 15:45:42 +0200 |
---|---|---|
committer | John Mulligan <jmulligan@redhat.com> | 2023-08-30 16:10:50 +0200 |
commit | 384887ac6986122edc361c4715773dc2dea10533 (patch) | |
tree | 19e78b8b4affab98767e0d80b1b6e67a4d26ad2d /src/cephadm/build.py | |
parent | cephadm: add new, currently empty, cephadmlib package (diff) | |
download | ceph-384887ac6986122edc361c4715773dc2dea10533.tar.xz ceph-384887ac6986122edc361c4715773dc2dea10533.zip |
cephadm: include the cephadmlib package in the binary's zipapp
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Pair-programmed-with: Adam King <adking@redhat.com>
Co-authored-by: Adam King <adking@redhat.com>
Diffstat (limited to 'src/cephadm/build.py')
-rwxr-xr-x | src/cephadm/build.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/cephadm/build.py b/src/cephadm/build.py index 4264b814f1e..0680abad21a 100755 --- a/src/cephadm/build.py +++ b/src/cephadm/build.py @@ -63,12 +63,12 @@ def _build(dest, src, versioning_vars=None): if os.path.isfile("requirements.txt"): _install_deps(tempdir) log.info("Copying contents") - # TODO: currently the only file relevant to a compiled cephadm is the - # cephadm.py file. Once cephadm is broken up into multiple py files - # (and possibly other libs from python-common, etc) we'll want some - # sort organized structure to track what gets copied into the - # dir to be zipped. For now we just have a simple call to copy - # (and rename) the one file we care about. + # cephadmlib is cephadm's private library of modules + shutil.copytree( + "cephadmlib", tempdir / "cephadmlib", ignore=_ignore_cephadmlib + ) + # cephadm.py is cephadm's main script for the "binary" + # this must be renamed to __main__.py for the zipapp shutil.copy("cephadm.py", tempdir / "__main__.py") if versioning_vars: generate_version_file(versioning_vars, tempdir / "_version.py") @@ -77,6 +77,15 @@ def _build(dest, src, versioning_vars=None): shutil.rmtree(tempdir) +def _ignore_cephadmlib(source_dir, names): + # shutil.copytree callback: return the list of names *to ignore* + return [ + name + for name in names + if name.endswith(("~", ".old", ".swp", ".pyc", ".pyo", "__pycache__")) + ] + + def _compile(dest, tempdir): """Compile the zipapp.""" log.info("Byte-compiling py to pyc") |