Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1b64406

Browse filesBrowse files
authored
builtins: fallback to package.json for uap-core version
In case where uap-core isn't a git repo (e.g. git archive), use uap-core's `package.json` as a fallback for getting a version.
1 parent ce12905 commit 1b64406
Copy full SHA for 1b64406

File tree

Expand file treeCollapse file tree

1 file changed

+15
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-9
lines changed

‎ua-parser-builtins/hatch_build.py

Copy file name to clipboardExpand all lines: ua-parser-builtins/hatch_build.py
+15-9Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import io
4+
import json
45
import os
56
import os.path
67
import tempfile
@@ -10,19 +11,24 @@
1011
import yaml
1112
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
1213
from hatchling.metadata.plugin.interface import MetadataHookInterface
13-
from versioningit import get_version
14+
from versioningit import errors, get_version
1415

1516

1617
class MetadataHook(MetadataHookInterface):
1718
def update(self, metadata: dict[str, Any]) -> None:
18-
v = get_version(
19-
os.path.join(self.root, "uap-core"),
20-
config={
21-
"format": {
22-
"distance": "{next_version}.dev{distance}",
23-
}
24-
},
25-
)
19+
try:
20+
v = get_version(
21+
os.path.join(self.root, "uap-core"),
22+
config={
23+
"format": {
24+
"distance": "{next_version}.dev{distance}",
25+
}
26+
},
27+
)
28+
except errors.NotSdistError:
29+
with open(os.path.join(self.root, "uap-core", "package.json")) as ufile:
30+
ujson = json.load(ufile)
31+
v = ujson["version"]
2632
if v in ("0.15.0", "0.16.0", "0.18.0"):
2733
v = f"{v}.post1"
2834

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.