ry-tool 1.0.1__py3-none-any.whl → 1.1.0__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.
ry_tool/executor.py CHANGED
@@ -9,9 +9,12 @@ import subprocess
9
9
  import sys
10
10
  import os
11
11
  import json
12
+ import yaml
12
13
  from typing import Dict, Any, List, Optional
13
14
  from dataclasses import dataclass
14
15
  from io import StringIO
16
+ from pathlib import Path
17
+ import ry_tool.utils # Import ry_tool modules
15
18
 
16
19
 
17
20
  @dataclass
@@ -59,17 +62,19 @@ class Executor:
59
62
  Returns:
60
63
  ExecutionResult
61
64
  """
62
- # Merge environment
63
- env = step.get('env', {})
65
+ # Merge environment - extra_env takes precedence
66
+ env = {}
64
67
  if extra_env:
65
68
  env.update(extra_env)
69
+ if step.get('env'):
70
+ env.update(step['env'])
66
71
 
67
72
  if 'shell' in step:
68
73
  return self.execute_shell(step['shell'], env,
69
74
  interactive=step.get('interactive', False),
70
75
  capture_file=step.get('_capture_file'))
71
76
  elif 'python' in step:
72
- return self.execute_python(step['python'])
77
+ return self.execute_python(step['python'], extra_env=env)
73
78
  elif 'subprocess' in step:
74
79
  return self.execute_subprocess(step['subprocess'])
75
80
  elif 'ruby' in step:
@@ -203,7 +208,7 @@ class Executor:
203
208
  returncode=1
204
209
  )
205
210
 
206
- def execute_python(self, code: str) -> ExecutionResult:
211
+ def execute_python(self, code: str, extra_env: Dict[str, str] = None) -> ExecutionResult:
207
212
  """
208
213
  Execute Python code with context.
209
214
 
@@ -230,15 +235,45 @@ class Executor:
230
235
  original_env = safe_copy(self.context.get('env'), {})
231
236
  original_captured = safe_copy(self.context.get('captured'), {})
232
237
 
238
+ # Set up Python path from environment
239
+ # This allows library code to import from lib/ directories
240
+ if extra_env and 'PYTHONPATH' in extra_env:
241
+ for path in extra_env['PYTHONPATH'].split(':'):
242
+ if path and path not in sys.path:
243
+ sys.path.insert(0, path)
244
+
245
+ # Also add library directory if provided
246
+ if extra_env and 'RY_LIBRARY_DIR' in extra_env:
247
+ lib_path = os.path.join(extra_env['RY_LIBRARY_DIR'], 'lib')
248
+ if os.path.exists(lib_path) and lib_path not in sys.path:
249
+ sys.path.insert(0, lib_path)
250
+
251
+ # Add all sibling library lib/ directories for cross-library imports
252
+ # This allows e.g., uv library to import from git library
253
+ libraries_root = os.path.dirname(extra_env['RY_LIBRARY_DIR'])
254
+ if os.path.exists(libraries_root):
255
+ for item in os.listdir(libraries_root):
256
+ sibling_lib = os.path.join(libraries_root, item, 'lib')
257
+ if os.path.isdir(sibling_lib) and sibling_lib not in sys.path:
258
+ sys.path.insert(0, sibling_lib)
259
+
260
+ # Merge environment variables into env dict
261
+ merged_env = safe_copy(self.context.get('env'), {})
262
+ if extra_env:
263
+ merged_env.update(extra_env)
264
+
233
265
  # Prepare execution environment with mutable references
234
266
  exec_globals = {
235
267
  'sys': sys,
236
268
  'os': os,
237
269
  'subprocess': subprocess,
238
270
  'json': json,
271
+ 'yaml': yaml,
272
+ 'Path': Path,
273
+ 'ry_tool': ry_tool, # Make ry_tool module available
239
274
  'flags': safe_copy(self.context.get('flags'), {}),
240
275
  'arguments': safe_copy(self.context.get('arguments'), {}),
241
- 'env': safe_copy(self.context.get('env'), {}),
276
+ 'env': merged_env,
242
277
  'captured': safe_copy(self.context.get('captured'), {}),
243
278
  'remaining_args': self.context.get('remaining_args', []),
244
279
  'positionals': safe_copy(self.context.get('positionals'), []),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ry-tool
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: Pure YAML command orchestrator - CI/CD for humans
5
5
  Author: Fredrik Angelsen
6
6
  Author-email: Fredrik Angelsen <fredrikangelsen@gmail.com>
@@ -3,14 +3,14 @@ ry_tool/__main__.py,sha256=fbQGeI2WWTZrLUI7LToOfAV5JckzB_El64i0zjqOouI,138
3
3
  ry_tool/_cli.py,sha256=8gZ-c1FlerAZ5e0K4v7Mv2GafMLiGAcv-3ET8oHmMdQ,7693
4
4
  ry_tool/app.py,sha256=TjMCQDZ5QkqKiAqUViGe84T6d6Deb67jnRRFAmEk15w,15997
5
5
  ry_tool/context.py,sha256=elDiqty6Fssq-74ra8twtzKfolQ154xLj2ECwZbzcy4,9743
6
- ry_tool/executor.py,sha256=XiwWKl1YMa0zgok4C6beuxAWDVhEs2i1gL_vxPlNbcA,17199
6
+ ry_tool/executor.py,sha256=hQOnL9Ii_scsFtOzLOE1MfYA5_fDbq2H9ATsBcGymc0,18867
7
7
  ry_tool/installer.py,sha256=cFnEROvpfIjMkpZF4AzRU4bHDNneJBMk5gRXP5jJgqE,5712
8
8
  ry_tool/loader.py,sha256=Ce1-M3uJ554_H1M8j1ZFTXPE8dxSvFXR6l88utM9zHc,9809
9
9
  ry_tool/matcher.py,sha256=fg857FoF2CjLsUvJl2vaeRHHHGx6A8vraI1fnddOKN4,7458
10
10
  ry_tool/parser.py,sha256=c9cNsXf1kdWpmXH3IVdejlePIrZWmJDdnh3mQlAyPmI,9253
11
11
  ry_tool/template.py,sha256=uEvc70vA7NZ3qKemsddTnYFKhdc2sEf-5uytd2wPiBk,10094
12
12
  ry_tool/utils.py,sha256=TpJz7DSkyJewzyDPUsQXI9awDgMbE6nC__DRbUYNQpw,13762
13
- ry_tool-1.0.1.dist-info/WHEEL,sha256=Jb20R3Ili4n9P1fcwuLup21eQ5r9WXhs4_qy7VTrgPI,79
14
- ry_tool-1.0.1.dist-info/entry_points.txt,sha256=z2YdpRoOA9Kk0Sg26A6Eu6PrwdJLQ22dxdZqHnhWYNo,45
15
- ry_tool-1.0.1.dist-info/METADATA,sha256=d2x2ZdUHzX6gHW-zVhJ-4kdu9KBuziKrosqdNms29tE,2612
16
- ry_tool-1.0.1.dist-info/RECORD,,
13
+ ry_tool-1.1.0.dist-info/WHEEL,sha256=Jb20R3Ili4n9P1fcwuLup21eQ5r9WXhs4_qy7VTrgPI,79
14
+ ry_tool-1.1.0.dist-info/entry_points.txt,sha256=z2YdpRoOA9Kk0Sg26A6Eu6PrwdJLQ22dxdZqHnhWYNo,45
15
+ ry_tool-1.1.0.dist-info/METADATA,sha256=HVGbK34HUa9Pv2lbCPVWfp_p4zQxNUlDIRd41HhmoNk,2612
16
+ ry_tool-1.1.0.dist-info/RECORD,,