Skip to content

Commit

Permalink
Preserve dependencies in pyproject.toml for hatch and flit backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed May 15, 2024
1 parent 2fa4010 commit 910db0c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion repo_helper/files/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import posixpath
import re
import textwrap
from typing import Any, Dict, List, Mapping, Tuple, TypeVar
from typing import Any, Dict, List, Mapping, Optional, Tuple, TypeVar

# 3rd party
import dom_toml
Expand Down Expand Up @@ -210,6 +210,12 @@ def make_pyproject(repo_path: pathlib.Path, templates: Environment) -> List[str]
data["build-system"]["requires"] = list(map(str, build_requirements))
data["build-system"]["build-backend"] = build_backend

existing_dependencies: Optional[List[str]]
if "dependencies" in data.get("project", {}):
existing_dependencies = data["project"]["dependencies"]
else:
existing_dependencies = None

data["project"] = {}
data["project"]["name"] = templates.globals["pypi_name"]
data["project"]["version"] = templates.globals["version"]
Expand Down Expand Up @@ -243,6 +249,9 @@ def make_pyproject(repo_path: pathlib.Path, templates: Environment) -> List[str]
elif "classifiers" in data["project"]:
del data["project"]["classifiers"]

if existing_dependencies is not None:
data["project"]["dependencies"] = existing_dependencies

data["project"]["dynamic"] = dynamic
data["project"]["license"] = {"file": "LICENSE"}
data["project"]["authors"] = [{"name": templates.globals["author"], "email": templates.globals["email"]}]
Expand Down

0 comments on commit 910db0c

Please sign in to comment.