Files
OctoPrint/setup.py
Gina Häußge cfb6213acc ♻️ Move as much as possible into setup.cfg
That should allow us to use dependabot and other tooling and also future
proof the setup.

In theory we could get everything to work without a setup.py at all, however
the Python environmements encountered in the field might not yet support
all features of setup.cfg yet (see comments).

pyproject.toml would be even nicer, alas, there the support in the field looks
even less good, so setup.cfg it is.

TODO: check this installs under all supported environments
2023-03-20 13:51:26 +01:00

63 lines
1.9 KiB
Python

import os
import shutil
from setuptools import setup
from setuptools.command.build_py import build_py as _build_py
class custom_build_py(_build_py):
FILES = {
"octoprint/templates/_data": [
"AUTHORS.md",
"SUPPORTERS.md",
"THIRDPARTYLICENSES.md",
]
}
def run(self):
self._copy_files(self.FILES)
super().run()
self._run_versioneer()
def _copy_files(self, files):
for directory, entries in files.items():
target_dir = os.path.join(self.build_lib, directory)
self.mkpath(target_dir)
for entry in entries:
if isinstance(entry, tuple):
if len(entry) != 2:
continue
source, dest = entry[0], os.path.join(target_dir, entry[1])
else:
source = entry
dest = os.path.join(target_dir, source)
print("copying {} -> {}".format(source, dest))
shutil.copy2(source, dest)
def _run_versioneer(self):
from versioneer import (
get_config_from_root,
get_root,
get_versions,
write_to_version_file,
)
root = get_root()
cfg = get_config_from_root(root)
versions = get_versions()
if cfg.versionfile_build:
target_versionfile = os.path.join(self.build_lib, cfg.versionfile_build)
print("UPDATING {}".format(target_versionfile))
write_to_version_file(target_versionfile, versions)
if __name__ == "__main__":
setup(
# supported in setup.cfg from setuptools 54, not yet on OctoPi
entry_points={"console_scripts": ["octoprint = octoprint:main"]},
# supported in setup.cfg from setuptools 51, not yet on OctoPi
cmdclass={"build_py": custom_build_py},
)