Skip to content

Commit

Permalink
Put prez module's pyproject.toml _inside_ the built prez module in th…
Browse files Browse the repository at this point in the history
…e wheel package, this allows the config builder to find it when prez is installed as a system module.

Modify the config builder to search inside the prez module for pyproject.toml if there is not one in the project top directory (enables the above functionality).
Also explicitly list all the files to include in a sdist, because should be different than the wheel bdist.
  • Loading branch information
ashleysommer committed Apr 21, 2024
1 parent e026403 commit 5128d68
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
21 changes: 18 additions & 3 deletions prez/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,24 @@ def get_version(cls, values):
values["prez_version"] = version

if version is None or version == "":
values["prez_version"] = toml.load(
Path(Path(__file__).parent.parent) / "pyproject.toml"
)["tool"]["poetry"]["version"]
possible_locations = (
# dir above /prez, this is present in dev environments
# this is also used by derived projects to override the app version
Path(__file__).parent.parent,
# _inside_ /prez module, this is present in wheel builds
Path(__file__).parent,
)
p: Path
for p in possible_locations:
if (p / "pyproject.toml").exists():
values["prez_version"] = toml.load(p / "pyproject.toml")["tool"][
"poetry"
]["version"]
break
else:
raise RuntimeError(
"PREZ_VERSION not set, and cannot find a pyproject.toml to extract the version."
)

return values

Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ name = "prez"
version = "0.1.0.dev0"
description = "A python application for displaying linked data on the web"
authors = ["Jamie Feiss <jamie.feiss@gmail.com>", "Nicholas Car <nick@kurrawong.net>", "David Habgood <dcchabgood@gmail.com>"]
packages = [
{ include = "prez" },
{ include = "pyproject.toml", format = "wheel", to="prez" },
]
include = [
{ path = "./*.md", format = "sdist" },
{ path = "LICENSE", format = "sdist" },
{ path = "demo", format = "sdist" },
{ path = "dev", format = "sdist" },
{ path = "tests", format = "sdist" },
{ path = "poetry.lock", format = "sdist" },
{ path = "./*.whl", format = "sdist" },
{ path = "*.toml", format = "sdist" }
]

[tool.poetry.dependencies]
python = "^3.11"
Expand Down

0 comments on commit 5128d68

Please sign in to comment.