Skip to content

Dynamic versioning for postrelease versions #465

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

Merged
merged 13 commits into from
Jun 4, 2025
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Items without prefix refer to a global change.
## [Unreleased](https://github.com/NNPDF/eko/compare/v0.15.1...HEAD)

### Changed
- data: Changed version naming for unreleased eko versions from `0.0.0` to `0.0.0-sha` ([#448](https://github.com/NNPDF/eko/pull/448))
- data: Change version naming for unreleased eko versions from `0.0.0` to `0.0.0-post.{distance}+{commit hash}` ([#448](https://github.com/NNPDF/eko/pull/448)) ([#465](https://github.com/NNPDF/eko/pull/465))

### Fixed
- py: Remove usage of `ev_op_iterations` from truncated evolution as this is an inconsistent choice ([#459](https://github.com/NNPDF/eko/pull/459))
Expand Down
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We need to ensure backward compatibility and thus we need to make some changes.
5. Also implement these changes in the old `vX.py` scripts (at the moment these are `v1.py` and `v2.py`).

> **Note**: We call the unreleased eko version `v0.0`. EKO's created with unpublished versions (`0.0.0` versions) are not part of this backward compatibility system.
> They have version `0.0.0-{commit}`, and they cannot necessarily be read by newer eko versions.
> They have version `0.0.0-{commit}` and they cannot necessarily be read by newer eko versions.

### Instructions on how to update the test assets:

Expand Down
28 changes: 25 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ classifiers = [
]
repository = "https://github.com/NNPDF/eko"
include = [
"src/eko/version.py",
"doc/source/img/Logo.png",
"src/ekobox/genpdf/templatePDF.info",
"src/ekobox/genpdf/Toy.info",
"src/ekomark/benchmark/external/LHA.yaml",
"src/ekomark/version.py",
"src/ekobox/version.py",
]
packages = [
{ include = "eko", from = "src" },
Expand Down Expand Up @@ -79,7 +82,6 @@ asv = "^0.4.2"
virtualenv = "^20.13.2"
devtools = "^0.10.0"


[tool.poetry.group.version.dependencies]
tomlkit = "^0.12.5"

Expand All @@ -92,10 +94,30 @@ enable = true
vcs = "git"
style = "semver"
dirty = true
format_jinja = "{% if distance == 0 %}{{ base }}{% else %} 0.0.0.{{ commit }}{% endif %}"
format-jinja = "{% if distance == 0 %}{{ base }}{% else %}0.0.0-post.{{ distance }}+{{ commit }}{% endif %}"

[tool.poetry-dynamic-versioning.substitution]
files = ["src/eko/version.py"]
files = ["src/eko/version.py", "src/ekomark/version.py", "src/ekobox/version.py"]
folders = [{path = "src/eko"}, {path = "src/ekomark"}, {path = "src/ekobox"}]

[tool.poetry-dynamic-versioning.files."src/eko/version.py"]
persistent-substitution = true
initial-content = """
__version__ = "0.0.0"
__data_version__ = 3
"""

[tool.poetry-dynamic-versioning.files."src/ekobox/version.py"]
persistent-substitution = true
initial-content = """
__version__ = "0.0.0"
"""

[tool.poetry-dynamic-versioning.files."src/ekomark/version.py"]
persistent-substitution = true
initial-content = """
__version__ = "0.0.0"
"""

[tool.poetry.scripts]
ekonav = "ekomark.navigator:launch_navigator"
Expand Down
19 changes: 0 additions & 19 deletions src/eko/io/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,6 @@ def load(cls, path: os.PathLike):
raw = v1.update_metadata(paths, raw)
elif version.major == 0 and version.minor == 14:
raw = v2.update_metadata(paths, raw)
elif (
version.major == 0
and version.minor == 0
and version.micro == 0
and version.is_postrelease
):
raise NotImplementedError(
"Unsupported version; use an eko from a published eko version!"
)
else:
if (
version.major == 0
and version.minor == 0
and version.micro == 0
and version.is_postrelease
):
raise NotImplementedError(
"Unsupported version; use an eko from a published eko version!"
)

# now we are ready
content = cls.from_dict(raw)
Expand Down
5 changes: 0 additions & 5 deletions src/eko/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
"""Define versions.

Both package and data versions are stored here.
"""

__version__ = "0.0.0"
__data_version__ = 3
1 change: 1 addition & 0 deletions src/ekobox/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.0"
1 change: 1 addition & 0 deletions src/ekomark/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.0"
20 changes: 20 additions & 0 deletions tests/eko/io/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
import pytest
import yaml
from packaging.version import parse

from eko import EKO, interpolation
from eko.io import struct
Expand Down Expand Up @@ -195,3 +196,22 @@ def test_load_opened(self, tmp_path: pathlib.Path, eko_factory: EKOFactory):
read_opened = EKO.read(tmp_path, extract=False)

assert read_closed.metadata == read_opened.metadata

def test_version(self, tmp_path: pathlib.Path, eko_factory: EKOFactory):
"""Test asserted version. Should either be supported version, or have a postrelease addition"""
eko = eko_factory.get()
eko.close()
eko_factory.cache = None
assert eko.access.path is not None
read_closed = EKO.read(eko.access.path, dest=tmp_path)

version = parse(read_closed.metadata.version)
assert (
version.major + version.minor + version.micro > 0
and not version.is_postrelease
) or (
version.major == 0
and version.minor == 0
and version.micro == 0
and version.is_postrelease
)
Loading