build: use uv for project management
Switch to "uv" for package and project management. Currently the pdm backend is still used to perform the build due to its built-in scm versioning and flexible build hooks. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
7 files changed
+4132
-9
No files matched your search
@@ -18,3 +18,7 @@ share
|
||||
.mypy_cache
|
||||
.pdm-build
|
||||
.pytest_cache
|
||||
|
||||
# Sometimes uv lock generates the version file and places it in
|
||||
# the repo. We don't want to commit this, so ignore it
|
||||
moonraker/__version__.py
|
||||
@@ -1,4 +1,4 @@
|
||||
mkdocs-material==9.5.50
|
||||
pymdown-extensions~=10.14.1
|
||||
compact_tables@git+https://github.com/Arksine/markdown-compact-tables@v1.1.0
|
||||
./docs/pymdown-extras
|
||||
./docs/pymdown-extras
|
||||
@@ -69,6 +69,8 @@ def pdm_build_initialize(context: Context) -> None:
|
||||
rinfo_path.write_text(rinfo_data)
|
||||
scripts_path: pathlib.Path = context.root.joinpath("scripts")
|
||||
scripts_dest: pathlib.Path = pkg_path.joinpath("scripts")
|
||||
if scripts_dest.is_dir():
|
||||
shutil.rmtree(str(scripts_dest))
|
||||
scripts_dest.mkdir()
|
||||
for item in scripts_path.iterdir():
|
||||
if item.name in ("__pycache__", "python_wheels"):
|
||||
|
||||
+20
-2
@@ -47,6 +47,15 @@ repository = "https://github.com/Arksine/moonraker"
|
||||
documentation = "https://moonraker.readthedocs.io"
|
||||
changelog = "https://moonraker.readthedocs.io/en/latest/changelog/"
|
||||
|
||||
[dependency-groups]
|
||||
dev = ["pre-commit", "mypy", "ruff", "build"]
|
||||
docs = [
|
||||
"mkdocs-material==9.5.50",
|
||||
"pymdown-extensions~=10.14.1",
|
||||
"compact_tables",
|
||||
"pymdown_extras"
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
msgspec = ["msgspec>=0.18.4 ; python_version>='3.8'"]
|
||||
uvloop = ["uvloop>=0.17.0"]
|
||||
@@ -54,7 +63,16 @@ speedups = [
|
||||
"msgspec>=0.18.4 ; python_version>='3.8'",
|
||||
"uvloop>=0.17.0"
|
||||
]
|
||||
dev = ["pre-commit", "build", "mypy", "ruff", "twine"]
|
||||
|
||||
[tool.uv]
|
||||
extra-build-variables = { zeroconf = { SKIP_CYTHON = "1" } }
|
||||
|
||||
[tool.uv.sources]
|
||||
compact_tables = { git = "https://github.com/Arksine/markdown-compact-tables", tag = "v1.1.0" }
|
||||
pymdown_extras = { path = "./docs/pymdown-extras" }
|
||||
|
||||
[tool.uv.dependency-groups]
|
||||
docs = {requires-python = ">=3.9"}
|
||||
|
||||
[tool.pdm.version]
|
||||
source = "scm"
|
||||
@@ -71,5 +89,5 @@ custom-hook = "pdm_build.py"
|
||||
moonraker = "moonraker.server:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["pdm-backend<=2.4.4"]
|
||||
requires = ["pdm-backend<=2.4.7"]
|
||||
build-backend = "pdm.backend"
|
||||
@@ -1,5 +1,4 @@
|
||||
pre-commit
|
||||
build
|
||||
mypy
|
||||
ruff
|
||||
twine
|
||||
build
|
||||
@@ -12,10 +12,11 @@ import tomllib
|
||||
import json
|
||||
import ast
|
||||
from io import StringIO, TextIOBase
|
||||
from typing import Dict, List, Iterator
|
||||
from typing import Dict, List, Iterator, Any
|
||||
|
||||
MAX_LINE_LENGTH = 88
|
||||
SCRIPTS_PATH = pathlib.Path(__file__).parent
|
||||
DOCS_PATH = SCRIPTS_PATH.parent.joinpath("docs")
|
||||
INST_PKG_HEADER = "# *** AUTO GENERATED OS PACKAGE SCRIPT START ***"
|
||||
INST_PKG_FOOTER = "# *** AUTO GENERATED OS PACKAGE SCRIPT END ***"
|
||||
DEPS_HEADER = "# *** SYSTEM DEPENDENCIES START ***"
|
||||
@@ -129,6 +130,28 @@ def check_reqs_changed(reqs_file: pathlib.Path, new_reqs: List[str]) -> bool:
|
||||
req_list.append(requirement)
|
||||
return set(new_reqs) != set(req_list)
|
||||
|
||||
def process_requirement_sources(reqs: List[str], data: Dict[str, Any]) -> List[str]:
|
||||
try:
|
||||
sources: Dict[str, Any] = data["tool"]["uv"]["sources"]
|
||||
except KeyError:
|
||||
return reqs
|
||||
new_reqs: List[str] = []
|
||||
for req in reqs:
|
||||
src_info = sources.get(req, None)
|
||||
if src_info is not None:
|
||||
if "path" in src_info:
|
||||
# replace named requirement with path
|
||||
req = src_info["path"]
|
||||
elif "git" in src_info:
|
||||
url = src_info["git"]
|
||||
req = f"{req}@git+{url}"
|
||||
if "tag" in src_info:
|
||||
tag = src_info["tag"]
|
||||
req = f"{req}@{tag}"
|
||||
new_reqs.append(req)
|
||||
return new_reqs
|
||||
|
||||
|
||||
def sync_requirements() -> int:
|
||||
ret: int = 0
|
||||
src_path = SCRIPTS_PATH.parent
|
||||
@@ -158,18 +181,30 @@ def sync_requirements() -> int:
|
||||
for requirement in speedup_deps:
|
||||
req_file.write(f"{requirement}\n")
|
||||
else:
|
||||
print("Speedup sequirements match")
|
||||
print("Speedup requirements match")
|
||||
# sync dev dependencies
|
||||
dev_reqs_path = SCRIPTS_PATH.joinpath("moonraker-dev-reqs.txt")
|
||||
dev_deps = optional_deps["dev"]
|
||||
dev_deps = data["dependency-groups"]["dev"]
|
||||
if check_reqs_changed(dev_reqs_path, dev_deps):
|
||||
print("Syncing dev requirements")
|
||||
ret = 1
|
||||
with dev_reqs_path.open("r+") as req_file:
|
||||
with dev_reqs_path.open("w+") as req_file:
|
||||
for requirement in dev_deps:
|
||||
req_file.write(f"{requirement}\n")
|
||||
else:
|
||||
print("Dev requirements match")
|
||||
# sync doc dependencies
|
||||
doc_reqs_path = DOCS_PATH.joinpath("doc-requirements.txt")
|
||||
doc_deps = data["dependency-groups"]["docs"]
|
||||
doc_deps = process_requirement_sources(doc_deps, data)
|
||||
if check_reqs_changed(doc_reqs_path, doc_deps):
|
||||
print("Syncing documenation requirements")
|
||||
ret = 1
|
||||
with doc_reqs_path.open("w+") as req_file:
|
||||
for requirement in doc_deps:
|
||||
req_file.write(f"{requirement}\n")
|
||||
else:
|
||||
print("Doc requirements match")
|
||||
return ret
|
||||
|
||||
def main() -> int:
|
||||
|
||||
Reference in new issue
Block a user