-
-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #947 from RonnyPfannschmidt/fix-938-self-reinit-fixup
correctly handle project config overrides when the version keyword is used together with pyproject.toml
- Loading branch information
Showing
13 changed files
with
173 additions
and
93 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
changelog.d/20231002_161552_opensource_fix_938_self_reinit_fixup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
### Changed | ||
|
||
- ensure the setuptools version keyword correctly load pyproject.toml configuration | ||
- add build and wheel to the test requirements for regression testing | ||
- move internal toml handling to own module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,10 @@ rich = [ | |
"rich", | ||
] | ||
test = [ | ||
"build", | ||
"pytest", | ||
"rich", | ||
"wheel", | ||
] | ||
toml = [ | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
from typing import Any | ||
from typing import Callable | ||
from typing import cast | ||
from typing import Dict | ||
from typing import TYPE_CHECKING | ||
from typing import TypedDict | ||
|
||
if sys.version_info >= (3, 11): | ||
from tomllib import loads as load_toml | ||
else: | ||
from tomli import loads as load_toml | ||
|
||
if TYPE_CHECKING: | ||
from typing_extensions import TypeAlias | ||
|
||
from .. import _log | ||
|
||
log = _log.log.getChild("toml") | ||
|
||
TOML_RESULT: TypeAlias = Dict[str, Any] | ||
TOML_LOADER: TypeAlias = Callable[[str], TOML_RESULT] | ||
|
||
|
||
def read_toml_content(path: Path, default: TOML_RESULT | None = None) -> TOML_RESULT: | ||
try: | ||
data = path.read_text(encoding="utf-8") | ||
except FileNotFoundError: | ||
if default is None: | ||
raise | ||
else: | ||
log.debug("%s missing, presuming default %r", path, default) | ||
return default | ||
else: | ||
return load_toml(data) | ||
|
||
|
||
class _CheatTomlData(TypedDict): | ||
cheat: dict[str, Any] | ||
|
||
|
||
def load_toml_or_inline_map(data: str | None) -> dict[str, Any]: | ||
""" | ||
load toml data - with a special hack if only a inline map is given | ||
""" | ||
if not data: | ||
return {} | ||
elif data[0] == "{": | ||
data = "cheat=" + data | ||
loaded: _CheatTomlData = cast(_CheatTomlData, load_toml(data)) | ||
return loaded["cheat"] | ||
return load_toml(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.