ivaldi 0.3.4__tar.gz → 0.3.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ivaldi
3
- Version: 0.3.4
3
+ Version: 0.3.6
4
4
  Summary: Create a portable version of your Python Project
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -156,7 +156,7 @@ All default settings and flags are visible in [the ivaldi settings dataclass](ht
156
156
  type: Literal[true, false, 'install', 'run']
157
157
  [nuitka]:
158
158
  description: Nuitka metadata is passed as `--company-name`, `--product-name`, and `--file-description`.
159
- note: Relative icon paths are resolved from the wrapped project and translated to the platform-specific Nuitka icon option.
159
+ note: Relative icon paths are resolved from the wrapped project and translated to the platform-specific Nuitka icon option. On Windows, setting `company-name` also passes the wrapped project's version as Nuitka's file and product versions. Ivaldi checks `[project].version`, legacy `[tool.poetry].version`, and built wheel metadata before falling back to `[app].version`. If no version is configured, Ivaldi warns and uses the implicit `0.0.1` fallback. The resolved version must contain one to four numbers between 0 and 65535.
160
160
  name:
161
161
  description: The name to give your executable program
162
162
  type: str
@@ -136,7 +136,7 @@ All default settings and flags are visible in [the ivaldi settings dataclass](ht
136
136
  type: Literal[true, false, 'install', 'run']
137
137
  [nuitka]:
138
138
  description: Nuitka metadata is passed as `--company-name`, `--product-name`, and `--file-description`.
139
- note: Relative icon paths are resolved from the wrapped project and translated to the platform-specific Nuitka icon option.
139
+ note: Relative icon paths are resolved from the wrapped project and translated to the platform-specific Nuitka icon option. On Windows, setting `company-name` also passes the wrapped project's version as Nuitka's file and product versions. Ivaldi checks `[project].version`, legacy `[tool.poetry].version`, and built wheel metadata before falling back to `[app].version`. If no version is configured, Ivaldi warns and uses the implicit `0.0.1` fallback. The resolved version must contain one to four numbers between 0 and 65535.
140
140
  name:
141
141
  description: The name to give your executable program
142
142
  type: str
@@ -4,8 +4,10 @@ import shutil
4
4
  import subprocess
5
5
  import sys
6
6
  import tomllib
7
+ from email.parser import BytesParser
7
8
  from pathlib import Path
8
9
  from types import SimpleNamespace
10
+ from zipfile import ZipFile
9
11
 
10
12
  from build import ProjectBuilder
11
13
  from build.env import DefaultIsolatedEnv
@@ -107,6 +109,35 @@ def get_executable_name(settings) -> str:
107
109
  return name
108
110
 
109
111
 
112
+ def get_project_version(settings) -> str:
113
+ """Resolve the wrapped project's version, with app.version as fallback."""
114
+ pyproject = settings.dirs.project / "pyproject.toml"
115
+ if pyproject.is_file():
116
+ with open(pyproject, "rb") as file:
117
+ config = tomllib.load(file)
118
+ version = config.get("project", {}).get("version")
119
+ if version is None:
120
+ version = config.get("tool", {}).get("poetry", {}).get("version")
121
+ if version is not None:
122
+ return str(version)
123
+
124
+ manifest = settings.dirs.dist / IVALDI.WHEEL_MANIFEST
125
+ if manifest.is_file():
126
+ wheel = settings.dirs.dist / manifest.read_text(encoding="utf-8").strip()
127
+ if wheel.is_file():
128
+ with ZipFile(wheel) as archive:
129
+ metadata_files = [name for name in archive.namelist() if name.endswith(".dist-info/METADATA")]
130
+ if len(metadata_files) == 1:
131
+ version = BytesParser().parsebytes(archive.read(metadata_files[0])).get("Version")
132
+ if version:
133
+ return version
134
+
135
+ version = str(settings.app.version)
136
+ if version == "0.0.1":
137
+ logger.warning("No application version metadata found; using the implicit fallback version 0.0.1")
138
+ return version
139
+
140
+
110
141
  def get_nuitka_metadata_args(settings) -> list[str]:
111
142
  """Build Nuitka metadata and platform-specific icon arguments."""
112
143
  arguments = []
@@ -118,6 +149,13 @@ def get_nuitka_metadata_args(settings) -> list[str]:
118
149
  if value:
119
150
  arguments.append(f"--{option}={value}")
120
151
 
152
+ if platform.system() == "Windows" and settings.nuitka.company_name:
153
+ version = get_project_version(settings)
154
+ version_parts = version.split(".")
155
+ if not 1 <= len(version_parts) <= 4 or any(not part.isdigit() or int(part) > 65535 for part in version_parts):
156
+ raise ValueError("The application version must contain one to four numbers between 0 and 65535 for Windows builds")
157
+ arguments.extend((f"--file-version={version}", f"--product-version={version}"))
158
+
121
159
  if settings.nuitka.icon:
122
160
  icon = Path(settings.nuitka.icon)
123
161
  if not icon.is_absolute():
@@ -23,6 +23,7 @@ class App:
23
23
  if isinstance(self.install, dict):
24
24
  self.install = AppInstall(**self.install)
25
25
 
26
+ version: str = "0.0.1"
26
27
  entrypoint: str = None
27
28
  include: list[str] = field(default_factory=list)
28
29
  exclude: list[str] = field(
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ivaldi"
3
- version = "0.3.4"
3
+ version = "0.3.6"
4
4
  description = "Create a portable version of your Python Project"
5
5
  authors = [
6
6
  {name = "Fionn Tolster (@FionnT)"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes