omdev 0.0.0.dev44__py3-none-any.whl → 0.0.0.dev45__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.

Potentially problematic release.


This version of omdev might be problematic. Click here for more details.

omdev/cli/install.py CHANGED
@@ -120,7 +120,7 @@ class PipxInstallManager(InstallManager):
120
120
 
121
121
  dct = self._list_installed()
122
122
 
123
- exe = dct[opts.cli_pkg]['metadata']['main_package']['app_paths'][0]['__Path__']
123
+ exe = dct['venvs'][opts.cli_pkg]['metadata']['main_package']['app_paths'][0]['__Path__']
124
124
 
125
125
  subprocess.check_call([
126
126
  exe,
@@ -148,6 +148,8 @@ def _main() -> None:
148
148
  if not (cli := args.cli):
149
149
  raise ValueError(f'Must specify cli')
150
150
 
151
+ cli = cli.lower().replace('_', '-')
152
+
151
153
  if not (py := args.py):
152
154
  raise ValueError(f'Must specify py')
153
155
 
omdev/cli/managers.py CHANGED
@@ -7,6 +7,16 @@ import sys
7
7
  ##
8
8
 
9
9
 
10
+ def _normalize_pkg_name(s: str) -> str:
11
+ return s.lower().replace('_', '-')
12
+
13
+
14
+ CLI_PKG = _normalize_pkg_name(__name__.split('.')[0])
15
+
16
+
17
+ ##
18
+
19
+
10
20
  class ManagerType(enum.Enum):
11
21
  UVX = 'uvx'
12
22
  PIPX = 'pipx'
@@ -14,12 +24,25 @@ class ManagerType(enum.Enum):
14
24
 
15
25
  def _detect_install_manager() -> ManagerType | None:
16
26
  if os.path.isfile(fp := os.path.join(sys.prefix, 'uv-receipt.toml')):
27
+ import tomllib
28
+
29
+ with open(fp) as f:
30
+ dct = tomllib.loads(f.read())
31
+
32
+ reqs = dct.get('tool', {}).get('requirements')
33
+ main_pkg = _normalize_pkg_name(reqs[0].get('name', ''))
34
+ if reqs and main_pkg == CLI_PKG:
35
+ return ManagerType.UVX
36
+
37
+ if os.path.isfile(fp := os.path.join(sys.prefix, 'pipx_metadata.json')):
38
+ import json
39
+
17
40
  with open(fp) as f:
18
- if any(l.strip() == '[tool]' for l in f):
19
- return ManagerType.UVX
41
+ dct = json.loads(f.read())
20
42
 
21
- if os.path.isfile(os.path.join(sys.prefix, 'pipx_metadata.json')):
22
- return ManagerType.PIPX
43
+ main_pkg = _normalize_pkg_name(dct.get('main_package', {}).get('package_or_url', ''))
44
+ if main_pkg == CLI_PKG:
45
+ return ManagerType.PIPX
23
46
 
24
47
  return None
25
48
 
@@ -34,17 +57,24 @@ def detect_install_manager() -> ManagerType | None:
34
57
 
35
58
 
36
59
  ##
60
+ # Python is insistent in prepending sys.path with an empty string (translating to the current working directory),
61
+ # which leads to problems when using the cli in directories containing python packages (such as within this very
62
+ # source tree). This can't be done in cli main as the code frequently spawns other sys.executable processes which
63
+ # wouldn't know to do that, so a .pth file hack is used. Cleaning sys.path solely there is also insufficient as that
64
+ # code runs before the problematic empty string is added, so a sys.meta_path hook is prepended.
65
+ #
66
+ # See:
67
+ # https://github.com/python/cpython/blob/da1e5526aee674bb33c17a498aa3781587b9850c/Python/sysmodule.c#L3939
37
68
 
38
69
 
39
- def _ensure_correct_path() -> None:
40
- sp = site.getsitepackages()[0]
41
- if sys.path[0] != sp:
42
- sys.path.insert(0, sp)
70
+ def _remove_empty_from_sys_path() -> None:
71
+ while '' in sys.path:
72
+ sys.path.remove('')
43
73
 
44
74
 
45
75
  class _PathHackMetaFinder:
46
76
  def find_spec(self, fullname, path, target=None):
47
- _ensure_correct_path()
77
+ _remove_empty_from_sys_path()
48
78
  return None # noqa
49
79
 
50
80
 
omdev/tools/piptools.py CHANGED
@@ -66,7 +66,7 @@ class Cli(ap.Cli):
66
66
  dist_cn = canonicalize_name(dist.metadata['Name'], validate=True)
67
67
  if dist_cn in dists:
68
68
  # raise NameError(dist_cn)
69
- print(f'!! duplicate dist: {dist_cn}', file=sys.stderr)
69
+ # print(f'!! duplicate dist: {dist_cn}', file=sys.stderr)
70
70
  continue
71
71
 
72
72
  dists.add(dist_cn)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev44
3
+ Version: 0.0.0.dev45
4
4
  Summary: omdev
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,7 +12,7 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: ~=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omlish ==0.0.0.dev44
15
+ Requires-Dist: omlish ==0.0.0.dev45
16
16
  Provides-Extra: all
17
17
  Requires-Dist: pycparser ~=2.22 ; extra == 'all'
18
18
  Requires-Dist: cffi ~=1.17 ; extra == 'all'
@@ -56,9 +56,9 @@ omdev/cexts/_distutils/compilers/unixccompiler.py,sha256=o1h8QuyupLntv4F21_XjzAZ
56
56
  omdev/cli/__init__.py,sha256=V_l6VP1SZMlJbO-8CJwSuO9TThOy2S_oaPepNYgIrbE,37
57
57
  omdev/cli/__main__.py,sha256=5IeIERm-371fSI5ZvPv8eldAJBwgKwpR0R49pTsILNM,76
58
58
  omdev/cli/clicli.py,sha256=NY4MF16007Ri31rUsq868u1V9JYDb_2atBALqjjXJK4,1624
59
- omdev/cli/install.py,sha256=gKqFComs8vk4h3kjXOELBSnJ_nvmzK4SCeJxAaCJCTI,4445
59
+ omdev/cli/install.py,sha256=D-OlewQU3HJdt8F-u3C4o90Py5_XrFXhDxp_nXQvpko,4495
60
60
  omdev/cli/main.py,sha256=opoOOc_d4yCfI0_dWkwDV7O2WSnoybIH3YsylGFwqLI,2039
61
- omdev/cli/managers.py,sha256=FNfJ4G52un6tYGjr41WhRc6OAHlgiUsWejHEzqJPYuw,1669
61
+ omdev/cli/managers.py,sha256=k2IkanY-vO_zSJqMrSaak3KjAhrGAjoOLBerTrM9o-A,2855
62
62
  omdev/cli/types.py,sha256=7_Owg0P8C8oOObSuOp6aEYSjkEukVFxTT00SRy1bLHM,250
63
63
  omdev/interp/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
64
64
  omdev/interp/__main__.py,sha256=GMCqeGYltgt5dlJzHxY9gqisa8cRkrPfmZYuZnjg4WI,162
@@ -109,13 +109,13 @@ omdev/tools/__init__.py,sha256=iVJAOQ0viGTQOm0DLX4uZLro-9jOioYJGLg9s0kDx1A,78
109
109
  omdev/tools/dockertools.py,sha256=x00GV8j1KReMXwxJ641GlcsVwHoWeuzdIKVBp36BqwU,5298
110
110
  omdev/tools/gittools.py,sha256=i2WFM2pX5riDJBchFXMmegOCuLSjvTkKC1ltqShSo7E,1773
111
111
  omdev/tools/importscan.py,sha256=usF35AjdMZacpe8nfP-wfzxelExT5sEQUORNcBKqr5M,3929
112
- omdev/tools/piptools.py,sha256=lhwzGXD-v0KFEQNyvzvdO2Kw1OA_2AfGPBs_rIkz8iE,2772
112
+ omdev/tools/piptools.py,sha256=-jR5q3w4sHqntxCLExFCBNIARB788FUsAbJ62PK2sBU,2774
113
113
  omdev/tools/proftools.py,sha256=xKSm_yPoCnfsvS3iT9MblDqFMuZmGfI3_koGj8amMyU,145
114
114
  omdev/tools/rst.py,sha256=6dWk8QZHoGiLSuBw3TKsXZjjFK6wWBEtPi9krdCLKKg,977
115
115
  omdev/tools/sqlrepl.py,sha256=tmFZh80-xsGM62dyQ7_UGLebChrj7IHbIPYBWDJMgVk,5741
116
- omdev-0.0.0.dev44.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
117
- omdev-0.0.0.dev44.dist-info/METADATA,sha256=j1hrMNfOxwMRq2knkUjKyCc6E0cYg1fP3w45COF6KhU,1252
118
- omdev-0.0.0.dev44.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
119
- omdev-0.0.0.dev44.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
120
- omdev-0.0.0.dev44.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
121
- omdev-0.0.0.dev44.dist-info/RECORD,,
116
+ omdev-0.0.0.dev45.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
117
+ omdev-0.0.0.dev45.dist-info/METADATA,sha256=0VYbpYlLSNXLvBrxEpOdijqa8PlkH72pNoxql6wYM8Q,1252
118
+ omdev-0.0.0.dev45.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
119
+ omdev-0.0.0.dev45.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
120
+ omdev-0.0.0.dev45.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
121
+ omdev-0.0.0.dev45.dist-info/RECORD,,