Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto set version #37

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ scipy = "^1.13.1"
cloudpickle = "^3.0.0"
nptyping = "^2.5.0"
librosa = "^0.10.2.post1"
toml = "^0.10.2"


[tool.poetry.group.docs.dependencies]
Expand Down
13 changes: 11 additions & 2 deletions src/new_fave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,17 @@

from importlib.metadata import version

# this is bugged for testing
#__version__ = version("new_fave")
from pathlib import Path
import toml

__version__ = "unknown"
# adopt path to your pyproject.toml
pyproject_toml_file = Path(__file__).parent.parent.parent / "pyproject.toml"
if pyproject_toml_file.exists() and pyproject_toml_file.is_file():
data = toml.load(pyproject_toml_file)
# check project.version
if "tool" in data and "poetry" in data["tool"] and "version" in data["tool"]["poetry"]:
__version__ = data["tool"]["poetry"]["version"]

__all__ = [
"VowelMeasurement",
Expand Down
18 changes: 18 additions & 0 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pathlib import Path
import toml
import new_fave

def test_version():
pyproject_toml_file = Path(__file__).parent.parent / "pyproject.toml"
toml_v = "unknown"
if pyproject_toml_file.exists() and pyproject_toml_file.is_file():
data = toml.load(pyproject_toml_file)
# check project.version
if "project" in data and "version" in data["project"]:
toml_v = data["project"]["version"]
# check tool.poetry.version
elif "tool" in data and "poetry" in data["tool"] and "version" in data["tool"]["poetry"]:
toml_v = data["tool"]["poetry"]["version"]

assert new_fave.__version__ == toml_v

Loading