pyenv-native 0.5.0__tar.gz → 0.7.0__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,7 +1,6 @@
1
1
  /target/
2
2
  /dist/
3
3
  /python-package/dist/
4
- /packaging/winget/manifests/
5
4
  /packaging/homebrew/Formula/
6
5
  /python-package/src/**/*.pyc
7
6
  /python-package/tests/**/*.pyc
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyenv-native
3
- Version: 0.5.0
3
+ Version: 0.7.0
4
4
  Summary: Python install package for the native-first pyenv-native runtime bundles.
5
5
  Project-URL: Homepage, https://github.com/imyourboyroy
6
6
  Project-URL: Repository, https://github.com/imyourboyroy/pyenv-native
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["hatchling>=1.32.0"]
2
+ requires = ["hatchling>=1.33.0"]
3
3
  build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pyenv-native"
7
- version = "0.5.0"
7
+ version = "0.7.0"
8
8
  description = "Python install package for the native-first pyenv-native runtime bundles."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -3,4 +3,4 @@
3
3
 
4
4
  __all__ = ["__version__"]
5
5
 
6
- __version__ = "0.5.0"
6
+ __version__ = "0.7.0"
@@ -17,15 +17,20 @@ from . import __version__
17
17
 
18
18
  @dataclass(frozen=True)
19
19
  class BundleManifest:
20
- """Describes a built release bundle and the scripts it carries."""
20
+ """Describes a built release bundle.
21
+
22
+ Current bundles install through the bundled binary (`<executable> self-install`) and carry no
23
+ scripts. Bundles published before that change name `install_script`/`uninstall_script`
24
+ instead; both are optional so either generation can be installed.
25
+ """
21
26
 
22
27
  bundle_name: str
23
28
  bundle_version: str
24
29
  platform: str
25
30
  architecture: str
26
31
  executable: str
27
- install_script: str
28
- uninstall_script: str
32
+ install_script: Optional[str] = None
33
+ uninstall_script: Optional[str] = None
29
34
 
30
35
 
31
36
  def sha256_file(path: Path) -> str:
@@ -94,8 +99,8 @@ def read_manifest_from_bundle(bundle_path: Path) -> BundleManifest:
94
99
  platform=payload["platform"],
95
100
  architecture=payload["architecture"],
96
101
  executable=payload["executable"],
97
- install_script=payload["install_script"],
98
- uninstall_script=payload["uninstall_script"],
102
+ install_script=payload.get("install_script"),
103
+ uninstall_script=payload.get("uninstall_script"),
99
104
  )
100
105
 
101
106
 
@@ -177,7 +177,7 @@ def build_windows_install_command(
177
177
  request: InstallRequest,
178
178
  manifest: BundleManifest,
179
179
  ) -> list[str]:
180
- """Build the PowerShell command used to invoke the bundled installer."""
180
+ """Build the PowerShell command used to invoke a legacy bundle's installer script."""
181
181
 
182
182
  install_script = extracted_dir / manifest.install_script
183
183
  executable = extracted_dir / manifest.executable
@@ -210,7 +210,7 @@ def build_posix_install_command(
210
210
  request: InstallRequest,
211
211
  manifest: BundleManifest,
212
212
  ) -> list[str]:
213
- """Build the shell command used to invoke the bundled POSIX installer."""
213
+ """Build the shell command used to invoke a legacy bundle's POSIX installer script."""
214
214
 
215
215
  install_script = extracted_dir / manifest.install_script
216
216
  executable = extracted_dir / manifest.executable
@@ -237,6 +237,37 @@ def build_posix_install_command(
237
237
  return command
238
238
 
239
239
 
240
+ def build_self_install_command(
241
+ extracted_dir: Path,
242
+ request: InstallRequest,
243
+ manifest: BundleManifest,
244
+ ) -> list[str]:
245
+ """Build the `pyenv self-install` command for a bundle that installs through its binary."""
246
+
247
+ executable = extracted_dir / manifest.executable
248
+ if os.name != "nt":
249
+ executable.chmod(executable.stat().st_mode | stat.S_IXUSR)
250
+ command = [
251
+ str(executable),
252
+ "self-install",
253
+ "--source-dir",
254
+ str(extracted_dir),
255
+ "--shell",
256
+ request.shell,
257
+ "--add-to-user-path",
258
+ str(request.add_to_user_path).lower(),
259
+ "--update-shell-profile",
260
+ str(request.update_powershell_profile).lower(),
261
+ "--refresh-shims",
262
+ str(request.refresh_shims).lower(),
263
+ ]
264
+ if request.install_root:
265
+ command.extend(["--install-root", str(request.install_root.expanduser().resolve())])
266
+ if request.force:
267
+ command.append("--force")
268
+ return command
269
+
270
+
240
271
  def plan_install(request: InstallRequest) -> InstallPlan:
241
272
  """Resolve, verify, and prepare a bundle install plan."""
242
273
 
@@ -260,7 +291,9 @@ def plan_install(request: InstallRequest) -> InstallPlan:
260
291
  f"bundle platform {manifest.platform!r} does not match the current host platform {host_target.operating_system!r}"
261
292
  )
262
293
 
263
- if manifest.platform == "windows":
294
+ if manifest.install_script is None:
295
+ install_command = build_self_install_command(extracted_dir, request, manifest)
296
+ elif manifest.platform == "windows":
264
297
  install_command = build_windows_install_command(extracted_dir, request, manifest)
265
298
  elif manifest.platform in {"linux", "macos", "android"}:
266
299
  install_command = build_posix_install_command(extracted_dir, request, manifest)
@@ -52,6 +52,25 @@ class BundleTests(unittest.TestCase):
52
52
  self.assertEqual(parsed.bundle_name, manifest["bundle_name"])
53
53
  self.assertEqual(parsed.install_script, manifest["install_script"])
54
54
 
55
+ def test_manifest_without_scripts_describes_a_self_install_bundle(self) -> None:
56
+ with tempfile.TemporaryDirectory() as temp_dir:
57
+ bundle_path = Path(temp_dir) / "bundle.zip"
58
+ manifest = {
59
+ "bundle_name": "pyenv-native-windows-x64",
60
+ "bundle_version": "0.6.0",
61
+ "platform": "windows",
62
+ "architecture": "x64",
63
+ "executable": "pyenv.exe",
64
+ "installer": "self-install",
65
+ }
66
+ with ZipFile(bundle_path, "w") as archive:
67
+ archive.writestr("bundle-manifest.json", json.dumps(manifest))
68
+
69
+ parsed = read_manifest_from_zip(bundle_path)
70
+ self.assertIsNone(parsed.install_script)
71
+ self.assertIsNone(parsed.uninstall_script)
72
+ self.assertEqual(parsed.executable, "pyenv.exe")
73
+
55
74
  def test_read_manifest_from_tar_bundle_returns_expected_fields(self) -> None:
56
75
  with tempfile.TemporaryDirectory() as temp_dir:
57
76
  bundle_path = Path(temp_dir) / "bundle.tar.gz"
@@ -15,6 +15,7 @@ from pyenv_native_bootstrap.bundle import BundleManifest
15
15
  from pyenv_native_bootstrap.installer import (
16
16
  InstallRequest,
17
17
  build_posix_install_command,
18
+ build_self_install_command,
18
19
  build_windows_install_command,
19
20
  plan_install,
20
21
  resolve_bundle_path,
@@ -129,6 +130,40 @@ class InstallerTests(unittest.TestCase):
129
130
  self.assertIn("false", command)
130
131
  self.assertIn("--force", command)
131
132
 
133
+ def test_build_self_install_command_runs_the_bundled_binary(self) -> None:
134
+ with tempfile.TemporaryDirectory() as temp_dir:
135
+ extracted_dir = Path(temp_dir)
136
+ executable = extracted_dir / "pyenv"
137
+ executable.write_text("binary", encoding="utf-8")
138
+ manifest = BundleManifest(
139
+ bundle_name="pyenv-native-linux-x64",
140
+ bundle_version="0.6.0",
141
+ platform="linux",
142
+ architecture="x64",
143
+ executable="pyenv",
144
+ )
145
+ self.assertIsNone(manifest.install_script)
146
+ command = build_self_install_command(
147
+ extracted_dir,
148
+ InstallRequest(
149
+ install_root=Path(temp_dir) / "portable",
150
+ shell="zsh",
151
+ add_to_user_path=False,
152
+ update_powershell_profile=False,
153
+ refresh_shims=True,
154
+ force=True,
155
+ ),
156
+ manifest,
157
+ )
158
+ self.assertEqual(command[0], str(executable))
159
+ self.assertEqual(command[1], "self-install")
160
+ self.assertEqual(command[command.index("--source-dir") + 1], str(extracted_dir))
161
+ self.assertEqual(command[command.index("--shell") + 1], "zsh")
162
+ self.assertEqual(command[command.index("--add-to-user-path") + 1], "false")
163
+ self.assertEqual(command[command.index("--refresh-shims") + 1], "true")
164
+ self.assertIn("--force", command)
165
+ self.assertIn("--install-root", command)
166
+
132
167
  def test_resolve_bundle_path_uses_environment_release_base_url(self) -> None:
133
168
  with tempfile.TemporaryDirectory() as temp_dir:
134
169
  bundle_path = Path(temp_dir) / "dist" / "pyenv-native-windows-x64.zip"
File without changes
File without changes