build: add scripts directly to the moonraker package
Per maintainers setuptool maintainers, the use of the "shared data" path is deprecated and no longer recommended. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
1 parent
f735c04194
commit
8df98908ca
2 files changed
+11
-36
No files matched your search
+10
-31
@@ -38,17 +38,10 @@ def retrieve_git_version(source_path: pathlib.Path) -> str:
|
||||
cmd = f"git -C {source_path} describe --always --tags --long --dirty"
|
||||
return _run_git_command(cmd)
|
||||
|
||||
|
||||
def pdm_build_clean(context: Context) -> None:
|
||||
share_path: pathlib.Path = context.root.joinpath("share")
|
||||
if share_path.exists():
|
||||
shutil.rmtree(str(share_path))
|
||||
|
||||
def pdm_build_initialize(context: Context) -> None:
|
||||
context.ensure_build_dir()
|
||||
proj_name: str = context.config.metadata['name']
|
||||
build_dir = pathlib.Path(context.build_dir)
|
||||
data_path = context.root.joinpath(f"share/{proj_name}")
|
||||
pkg_path = build_dir.joinpath(__package_name__)
|
||||
pkg_path.mkdir(parents=True, exist_ok=True)
|
||||
rinfo_path: pathlib.Path = pkg_path.joinpath("release_info")
|
||||
@@ -74,30 +67,16 @@ def pdm_build_initialize(context: Context) -> None:
|
||||
# Write the release info to both the package and the data path
|
||||
rinfo_data = json.dumps(release_info, indent=4)
|
||||
rinfo_path.write_text(rinfo_data)
|
||||
else:
|
||||
rinfo_path = context.root.joinpath(f"{proj_name}/release_info")
|
||||
if rinfo_path.is_file():
|
||||
rinfo_data = rinfo_path.read_text()
|
||||
else:
|
||||
rinfo_data = ""
|
||||
data_path.mkdir(parents=True, exist_ok=True)
|
||||
if rinfo_data:
|
||||
data_path.joinpath("release_info").write_text(rinfo_data)
|
||||
scripts_path: pathlib.Path = context.root.joinpath("scripts")
|
||||
scripts_dest: pathlib.Path = data_path.joinpath("scripts")
|
||||
scripts_dest.mkdir()
|
||||
for item in scripts_path.iterdir():
|
||||
if item.name in ("__pycache__", "python_wheels"):
|
||||
continue
|
||||
if item.is_dir():
|
||||
shutil.copytree(str(item), str(scripts_dest.joinpath(item.name)))
|
||||
else:
|
||||
shutil.copy2(str(item), str(scripts_dest))
|
||||
scripts_path: pathlib.Path = context.root.joinpath("scripts")
|
||||
scripts_dest: pathlib.Path = pkg_path.joinpath("scripts")
|
||||
scripts_dest.mkdir()
|
||||
for item in scripts_path.iterdir():
|
||||
if item.name in ("__pycache__", "python_wheels"):
|
||||
continue
|
||||
if item.is_dir():
|
||||
shutil.copytree(str(item), str(scripts_dest.joinpath(item.name)))
|
||||
else:
|
||||
shutil.copy2(str(item), str(scripts_dest))
|
||||
git_ignore = build_dir.joinpath(".gitignore")
|
||||
if git_ignore.is_file():
|
||||
git_ignore.unlink()
|
||||
|
||||
def pdm_build_finalize(context: Context, artifact: pathlib.Path) -> None:
|
||||
share_path: pathlib.Path = context.root.joinpath("share")
|
||||
if share_path.exists():
|
||||
shutil.rmtree(str(share_path))
|
||||
+1
-5
@@ -67,16 +67,12 @@ write_template = "__version__ = '{}'\n"
|
||||
[tool.pdm.build]
|
||||
excludes = ["./**/.git", "moonraker/moonraker.py"]
|
||||
includes = ["moonraker"]
|
||||
source-includes = ["scripts"]
|
||||
editable-backend = "path"
|
||||
custom-hook = "pdm_build.py"
|
||||
|
||||
[tool.pdm.build.wheel-data]
|
||||
data = [{path = "share/moonraker/**/*", relative-to = "."}]
|
||||
|
||||
[project.scripts]
|
||||
moonraker = "moonraker.server:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["pdm-backend"]
|
||||
requires = ["pdm-backend==2.3.3"]
|
||||
build-backend = "pdm.backend"
|
||||
Reference in new issue
Block a user