hmd-cli-python 0.2.115__py3-none-any.whl → 0.2.116__py3-none-any.whl

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.
@@ -2,6 +2,7 @@ import os
2
2
  from pathlib import Path
3
3
  import configparser
4
4
  import shutil
5
+ import toml
5
6
  from typing import Any, Dict, List
6
7
  from urllib.parse import urlparse, urlunparse
7
8
 
@@ -13,6 +14,11 @@ from hmd_cli_tools.build_tools import build_dir
13
14
  from hmd_cli_tools.hmd_cli_tools import get_cloud_region, get_session
14
15
 
15
16
 
17
+ def is_uv_installed() -> bool:
18
+ """Check if uv is installed and available in PATH."""
19
+ return shutil.which("uv") is not None
20
+
21
+
16
22
  def publish(repo_name: str):
17
23
  with build_dir(repo_name):
18
24
  with cd("./src/python"):
@@ -62,6 +68,10 @@ def compile_requirements():
62
68
  "hmd-*",
63
69
  ]
64
70
 
71
+ # Add --uv flag only if uv is installed
72
+ if is_uv_installed():
73
+ command.insert(-2, "--uv") # Insert before "-c"
74
+
65
75
  compiled_deps, stderr, exitcode = shell.exec_cmd(command)
66
76
  if exitcode != 0:
67
77
  raise Exception(f"Error evaluating dependencies. ({stderr.decode()})")
@@ -182,6 +192,52 @@ def login(
182
192
  with open(pip_conf_name, "w") as pc:
183
193
  pip_config.write(pc)
184
194
 
195
+ # Configure uv with extra-index-url in HMD_HOME
196
+ hmd_home = os.environ.get("HMD_HOME")
197
+ if hmd_home:
198
+ uv_config_dir = Path(hmd_home) / ".config"
199
+ uv_config_dir.mkdir(parents=True, exist_ok=True)
200
+ uv_config_path = uv_config_dir / "uv.toml"
201
+
202
+ # Build uv index configuration
203
+ uv_config = {}
204
+ if uv_config_path.exists():
205
+ with open(uv_config_path, "r") as f:
206
+ uv_config = toml.load(f)
207
+
208
+ # Create index entries for each registry
209
+ uv_indexes = []
210
+ for registry, config in registries.items():
211
+ registry_type = config.get("type", None)
212
+ url_parts = urlparse(config["url"])
213
+
214
+ if registry_type == "codeartifact":
215
+ token = fetch_codeartifact_token(
216
+ hmd_region,
217
+ profile,
218
+ config["domain"],
219
+ config["account"],
220
+ config["repository"],
221
+ )
222
+ url_parts = url_parts._replace(
223
+ netloc=f"aws:{token}@{url_parts.hostname}"
224
+ )
225
+ else:
226
+ username = config["username"]
227
+ password = config["password"]
228
+ url_parts = url_parts._replace(
229
+ netloc=f"{username}:{password}@{url_parts.hostname}"
230
+ )
231
+
232
+ uv_indexes.append({"name": registry, "url": urlunparse(url_parts)})
233
+
234
+ # Update uv config with indexes
235
+ uv_config["index"] = uv_indexes
236
+
237
+ # Write uv config
238
+ with open(uv_config_path, "w") as f:
239
+ toml.dump(uv_config, f)
240
+
185
241
  if len(twine_urls) > 0:
186
242
  if not os.path.exists(Path.home() / ".pypirc"):
187
243
  with open(Path.home() / ".pypirc", "w") as twine:
@@ -204,8 +260,10 @@ def build(
204
260
  version = get_version()
205
261
  if os.name == "nt":
206
262
  py_cmd = "python"
263
+ venv_python = ".venv\\Scripts\\python.exe"
207
264
  else:
208
265
  py_cmd = "python3"
266
+ venv_python = ".venv/bin/python"
209
267
 
210
268
  repo_dir = os.getcwd()
211
269
  with build_dir(repo_name):
@@ -224,17 +282,93 @@ def build(
224
282
  if compiled_deps:
225
283
  update_setup_py(compiled_deps)
226
284
 
227
- if os.path.exists("test"):
228
- shell.exec_cmd2(["pip3", "install", "--force-reinstall", "-e", "."])
285
+ # Check for both "test" and "tests" directories
286
+ test_dir_exists = os.path.exists("test") or os.path.exists("tests")
287
+
288
+ if test_dir_exists:
289
+ use_uv = is_uv_installed()
290
+
291
+ if use_uv:
292
+ # Create virtual environment using uv
293
+ print("Creating virtual environment with uv...")
294
+ exitcode = shell.exec_cmd2(["uv", "venv"])
295
+ if exitcode != 0:
296
+ raise Exception("Error creating virtual environment with uv.")
297
+
298
+ # Install the local package in editable mode using uv with --python flag
299
+ print("Installing testing packages in virtual environment...")
300
+ exitcode = shell.exec_cmd2(
301
+ [
302
+ "uv",
303
+ "pip",
304
+ "install",
305
+ "--python",
306
+ venv_python,
307
+ "--upgrade",
308
+ "pip",
309
+ "pytest",
310
+ "pytest-cov",
311
+ ]
312
+ )
313
+ if exitcode != 0:
314
+ raise Exception(
315
+ "Error installing testing packages in virtual environment."
316
+ )
317
+
318
+ print("Installing local package in virtual environment...")
319
+ exitcode = shell.exec_cmd2(
320
+ ["uv", "pip", "install", "--python", venv_python, "-e", "."]
321
+ )
322
+ if exitcode != 0:
323
+ raise Exception(
324
+ "Error installing local package in virtual environment."
325
+ )
326
+ else:
327
+ # Create virtual environment using standard venv
328
+ print("Creating virtual environment...")
329
+ exitcode = shell.exec_cmd2([py_cmd, "-m", "venv", ".venv"])
330
+ if exitcode != 0:
331
+ raise Exception("Error creating virtual environment.")
332
+
333
+ # Install testing packages using standard pip
334
+ print("Installing testing packages in virtual environment...")
335
+ exitcode = shell.exec_cmd2(
336
+ [
337
+ venv_python,
338
+ "-m",
339
+ "pip",
340
+ "install",
341
+ "--upgrade",
342
+ "pip",
343
+ "pytest",
344
+ "pytest-cov",
345
+ ]
346
+ )
347
+ if exitcode != 0:
348
+ raise Exception(
349
+ "Error installing testing packages in virtual environment."
350
+ )
351
+
352
+ print("Installing local package in virtual environment...")
353
+ exitcode = shell.exec_cmd2(
354
+ [venv_python, "-m", "pip", "install", "-e", "."]
355
+ )
356
+ if exitcode != 0:
357
+ raise Exception(
358
+ "Error installing local package in virtual environment."
359
+ )
360
+
361
+ # Run pytest using the virtual environment's Python
229
362
  packages = find_packages()
230
363
 
231
- command = [py_cmd, "-m", "pytest"]
364
+ command = [venv_python, "-m", "pytest"]
232
365
  for pkg in packages:
233
366
  command += ["--cov", pkg]
234
367
 
235
368
  command += ["--cov-report", "term"]
236
369
  command += ["--cov-report", "html:coverage"]
237
370
 
371
+ print("Running tests...")
238
372
  exitcode = shell.exec_cmd2(command)
239
373
 
240
374
  if exitcode != 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hmd-cli-python
3
- Version: 0.2.115
3
+ Version: 0.2.116
4
4
  Summary: Implementation for python cli command
5
5
  Author: Jim Majure
6
6
  Author-email: jim.majure@hmdlabs.io
@@ -24,7 +24,7 @@ Requires-Dist: docutils==0.21.2
24
24
  Requires-Dist: durationpy==0.10
25
25
  Requires-Dist: google-auth==2.9.1
26
26
  Requires-Dist: hmd-cli-app~=1.2.616
27
- Requires-Dist: hmd-cli-tools~=1.2.242
27
+ Requires-Dist: hmd-cli-tools~=1.2.243
28
28
  Requires-Dist: id==1.5.0
29
29
  Requires-Dist: idna==3.10
30
30
  Requires-Dist: importlib-metadata==8.7.0
@@ -71,6 +71,7 @@ Requires-Dist: rsa==4.8
71
71
  Requires-Dist: s3transfer==0.11.2
72
72
  Requires-Dist: secretstorage==3.3.3
73
73
  Requires-Dist: six==1.16.0
74
+ Requires-Dist: toml==0.10.2
74
75
  Requires-Dist: tomli==2.2.1
75
76
  Requires-Dist: toposort==1.10
76
77
  Requires-Dist: twine==6.1.0
@@ -0,0 +1,7 @@
1
+ hmd_cli_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ hmd_cli_python/controller.py,sha256=GOi6QDDC0d42eG6ohwWifCYlgkFzoFzIwzjPrW1jqiM,3675
3
+ hmd_cli_python/hmd_cli_python.py,sha256=qAKd8Z3m2GhLzdnSNInVAdOTqBOvEJ-konrYC4QGZp8,14632
4
+ hmd_cli_python-0.2.116.dist-info/METADATA,sha256=nAsIlEHY4niIGjsgsvsjOK0VSMp4B_bcPhyBEr6Cg2I,2641
5
+ hmd_cli_python-0.2.116.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
6
+ hmd_cli_python-0.2.116.dist-info/top_level.txt,sha256=i2ZCGVJeOkzYWeWmczts0Y8Yv2QsTWcueX0_qWGbs7M,15
7
+ hmd_cli_python-0.2.116.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- hmd_cli_python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- hmd_cli_python/controller.py,sha256=GOi6QDDC0d42eG6ohwWifCYlgkFzoFzIwzjPrW1jqiM,3675
3
- hmd_cli_python/hmd_cli_python.py,sha256=6crcYGArjGZXSGpIImDfOBTUC_6y8SCFaBSyACWctNk,9276
4
- hmd_cli_python-0.2.115.dist-info/METADATA,sha256=vyJtzqdz7ThWDeY61mE7v3f8IAyCi5OuXkiMh3VRYjc,2613
5
- hmd_cli_python-0.2.115.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
6
- hmd_cli_python-0.2.115.dist-info/top_level.txt,sha256=i2ZCGVJeOkzYWeWmczts0Y8Yv2QsTWcueX0_qWGbs7M,15
7
- hmd_cli_python-0.2.115.dist-info/RECORD,,