omdev 0.0.0.dev175__py3-none-any.whl → 0.0.0.dev177__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
omdev/interp/pyenv.py CHANGED
@@ -1,3 +1,4 @@
1
+ # ruff: noqa: UP006 UP007
1
2
  """
2
3
  TODO:
3
4
  - custom tags
@@ -9,7 +10,6 @@ TODO:
9
10
  - optionally install / upgrade pyenv itself
10
11
  - new vers dont need these custom mac opts, only run on old vers
11
12
  """
12
- # ruff: noqa: UP006 UP007
13
13
  import abc
14
14
  import dataclasses as dc
15
15
  import itertools
@@ -319,11 +319,11 @@ class PyenvVersionInstaller:
319
319
  full_args = [
320
320
  os.path.join(check.not_none(await self._pyenv.root()), 'plugins', 'python-build', 'bin', 'python-build'), # noqa
321
321
  *conf_args,
322
- self.install_dir(),
322
+ await self.install_dir(),
323
323
  ]
324
324
  else:
325
325
  full_args = [
326
- self._pyenv.exe(),
326
+ await self._pyenv.exe(),
327
327
  'install',
328
328
  *conf_args,
329
329
  ]
@@ -1,3 +1,4 @@
1
+ # ruff: noqa: UP006 UP007
1
2
  """
2
3
  TODO:
3
4
  - ~/.cache/omlish/interp/standalone/...
@@ -20,7 +21,6 @@ TODO:
20
21
  # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
22
  # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23
  # https://github.com/tusharsadhwani/yen/blob/8d1bb0c1232c7b0159caefb1bf3a5348b93f7b43/src/yen/github.py
23
- # ruff: noqa: UP006 UP007
24
24
  import json
25
25
  import os.path
26
26
  import platform
@@ -91,6 +91,7 @@ class StandalonePythons:
91
91
 
92
92
  def fallback_release_data(self) -> GitHubReleaseData:
93
93
  """Returns the fallback release data, for when GitHub API gives an error."""
94
+
94
95
  log.warning('GitHub unreachable. Using fallback release data.')
95
96
  data_file = os.path.join(os.path.dirname(__file__), 'fallback_release_data.json')
96
97
  with open(data_file) as data:
@@ -101,6 +102,7 @@ class StandalonePythons:
101
102
 
102
103
  def get_latest_python_releases(self, is_linux_i686: bool) -> GitHubReleaseData:
103
104
  """Returns the list of python download links from the latest github release."""
105
+
104
106
  # They stopped shipping for 32 bit linux since after the 20230826 tag
105
107
  if is_linux_i686:
106
108
  data_file = os.path.join(os.path.dirname(__file__), 'linux_i686_release.json')
@@ -120,6 +122,7 @@ class StandalonePythons:
120
122
  @cached_nullary
121
123
  def list_pythons(self) -> ta.Mapping[str, str]:
122
124
  """Returns available python versions for your machine and their download links."""
125
+
123
126
  system, machine = platform.system(), platform.machine()
124
127
  download_link_suffixes = self.MACHINE_SUFFIX[system][machine]
125
128
  # linux suffixes are nested under glibc or musl builds
omdev/interp/system.py CHANGED
@@ -1,9 +1,9 @@
1
+ # ruff: noqa: UP006 UP007
1
2
  """
2
3
  TODO:
3
4
  - python, python3, python3.12, ...
4
5
  - check if path py's are venvs: sys.prefix != sys.base_prefix
5
6
  """
6
- # ruff: noqa: UP006 UP007
7
7
  import dataclasses as dc
8
8
  import os
9
9
  import re
omdev/interp/uv.py ADDED
@@ -0,0 +1,21 @@
1
+ # ruff: noqa: UP006 UP007
2
+ """
3
+ uv run pip
4
+ uv run --python 3.11.6 pip
5
+ uv venv --python 3.11.6 --seed barf
6
+ python3 -m venv barf && barf/bin/pip install uv && barf/bin/uv venv --python 3.11.6 --seed barf2
7
+ """
8
+ import typing as ta
9
+
10
+ from .providers import InterpProvider
11
+ from .types import Interp
12
+ from .types import InterpSpecifier
13
+ from .types import InterpVersion
14
+
15
+
16
+ class PyenvInterpProvider(InterpProvider):
17
+ def get_installed_versions(self, spec: InterpSpecifier) -> ta.Awaitable[ta.Sequence[InterpVersion]]:
18
+ raise NotImplementedError
19
+
20
+ def get_installed_version(self, version: InterpVersion) -> ta.Awaitable[Interp]:
21
+ raise NotImplementedError
omdev/scripts/interp.py CHANGED
@@ -3156,11 +3156,11 @@ class PyenvVersionInstaller:
3156
3156
  full_args = [
3157
3157
  os.path.join(check.not_none(await self._pyenv.root()), 'plugins', 'python-build', 'bin', 'python-build'), # noqa
3158
3158
  *conf_args,
3159
- self.install_dir(),
3159
+ await self.install_dir(),
3160
3160
  ]
3161
3161
  else:
3162
3162
  full_args = [
3163
- self._pyenv.exe(),
3163
+ await self._pyenv.exe(),
3164
3164
  'install',
3165
3165
  *conf_args,
3166
3166
  ]
@@ -3916,6 +3916,18 @@ class FieldsObjMarshaler(ObjMarshaler):
3916
3916
  })
3917
3917
 
3918
3918
 
3919
+ @dc.dataclass(frozen=True)
3920
+ class SingleFieldObjMarshaler(ObjMarshaler):
3921
+ ty: type
3922
+ fld: str
3923
+
3924
+ def marshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
3925
+ return getattr(o, self.fld)
3926
+
3927
+ def unmarshal(self, o: ta.Any, ctx: 'ObjMarshalContext') -> ta.Any:
3928
+ return self.ty(**{self.fld: o})
3929
+
3930
+
3919
3931
  @dc.dataclass(frozen=True)
3920
3932
  class PolymorphicObjMarshaler(ObjMarshaler):
3921
3933
  class Impl(ta.NamedTuple):
@@ -3990,7 +4002,7 @@ _DEFAULT_OBJ_MARSHALERS: ta.Dict[ta.Any, ObjMarshaler] = {
3990
4002
  **{t: IterableObjMarshaler(t, DynamicObjMarshaler()) for t in (list, tuple, set, frozenset)},
3991
4003
  **{t: MappingObjMarshaler(t, DynamicObjMarshaler(), DynamicObjMarshaler()) for t in (dict,)},
3992
4004
 
3993
- ta.Any: DynamicObjMarshaler(),
4005
+ **{t: DynamicObjMarshaler() for t in (ta.Any, object)},
3994
4006
 
3995
4007
  **{t: DatetimeObjMarshaler(t) for t in (datetime.date, datetime.time, datetime.datetime)},
3996
4008
  decimal.Decimal: DecimalObjMarshaler(),
@@ -4015,6 +4027,16 @@ _OBJ_MARSHALER_GENERIC_ITERABLE_TYPES: ta.Dict[ta.Any, type] = {
4015
4027
  ##
4016
4028
 
4017
4029
 
4030
+ _REGISTERED_OBJ_MARSHALERS_BY_TYPE: ta.MutableMapping[type, ObjMarshaler] = weakref.WeakKeyDictionary()
4031
+
4032
+
4033
+ def register_type_obj_marshaler(ty: type, om: ObjMarshaler) -> None:
4034
+ _REGISTERED_OBJ_MARSHALERS_BY_TYPE[ty] = om
4035
+
4036
+
4037
+ ##
4038
+
4039
+
4018
4040
  class ObjMarshalerManager:
4019
4041
  def __init__(
4020
4042
  self,
@@ -4024,6 +4046,8 @@ class ObjMarshalerManager:
4024
4046
  default_obj_marshalers: ta.Dict[ta.Any, ObjMarshaler] = _DEFAULT_OBJ_MARSHALERS, # noqa
4025
4047
  generic_mapping_types: ta.Dict[ta.Any, type] = _OBJ_MARSHALER_GENERIC_MAPPING_TYPES, # noqa
4026
4048
  generic_iterable_types: ta.Dict[ta.Any, type] = _OBJ_MARSHALER_GENERIC_ITERABLE_TYPES, # noqa
4049
+
4050
+ registered_obj_marshalers: ta.Mapping[type, ObjMarshaler] = _REGISTERED_OBJ_MARSHALERS_BY_TYPE,
4027
4051
  ) -> None:
4028
4052
  super().__init__()
4029
4053
 
@@ -4032,6 +4056,7 @@ class ObjMarshalerManager:
4032
4056
  self._obj_marshalers = dict(default_obj_marshalers)
4033
4057
  self._generic_mapping_types = generic_mapping_types
4034
4058
  self._generic_iterable_types = generic_iterable_types
4059
+ self._registered_obj_marshalers = registered_obj_marshalers
4035
4060
 
4036
4061
  self._lock = threading.RLock()
4037
4062
  self._marshalers: ta.Dict[ta.Any, ObjMarshaler] = dict(_DEFAULT_OBJ_MARSHALERS)
@@ -4047,6 +4072,9 @@ class ObjMarshalerManager:
4047
4072
  non_strict_fields: bool = False,
4048
4073
  ) -> ObjMarshaler:
4049
4074
  if isinstance(ty, type):
4075
+ if (reg := self._registered_obj_marshalers.get(ty)) is not None:
4076
+ return reg
4077
+
4050
4078
  if abc.ABC in ty.__bases__:
4051
4079
  impls = [ity for ity in deep_subclasses(ty) if abc.ABC not in ity.__bases__] # type: ignore
4052
4080
  if all(ity.__qualname__.endswith(ty.__name__) for ity in impls):
@@ -4111,9 +4139,15 @@ class ObjMarshalerManager:
4111
4139
 
4112
4140
  #
4113
4141
 
4114
- def register_opj_marshaler(self, ty: ta.Any, m: ObjMarshaler) -> None:
4142
+ def set_obj_marshaler(
4143
+ self,
4144
+ ty: ta.Any,
4145
+ m: ObjMarshaler,
4146
+ *,
4147
+ override: bool = False,
4148
+ ) -> None:
4115
4149
  with self._lock:
4116
- if ty in self._obj_marshalers:
4150
+ if not override and ty in self._obj_marshalers:
4117
4151
  raise KeyError(ty)
4118
4152
  self._obj_marshalers[ty] = m
4119
4153
 
@@ -4204,7 +4238,7 @@ class ObjMarshalContext:
4204
4238
 
4205
4239
  OBJ_MARSHALER_MANAGER = ObjMarshalerManager()
4206
4240
 
4207
- register_opj_marshaler = OBJ_MARSHALER_MANAGER.register_opj_marshaler
4241
+ set_obj_marshaler = OBJ_MARSHALER_MANAGER.set_obj_marshaler
4208
4242
  get_obj_marshaler = OBJ_MARSHALER_MANAGER.get_obj_marshaler
4209
4243
 
4210
4244
  marshal_obj = OBJ_MARSHALER_MANAGER.marshal_obj
@@ -6326,11 +6360,11 @@ class PyenvVersionInstaller:
6326
6360
  full_args = [
6327
6361
  os.path.join(check.not_none(await self._pyenv.root()), 'plugins', 'python-build', 'bin', 'python-build'), # noqa
6328
6362
  *conf_args,
6329
- self.install_dir(),
6363
+ await self.install_dir(),
6330
6364
  ]
6331
6365
  else:
6332
6366
  full_args = [
6333
- self._pyenv.exe(),
6367
+ await self._pyenv.exe(),
6334
6368
  'install',
6335
6369
  *conf_args,
6336
6370
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omdev
3
- Version: 0.0.0.dev175
3
+ Version: 0.0.0.dev177
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.dev175
15
+ Requires-Dist: omlish==0.0.0.dev177
16
16
  Provides-Extra: all
17
17
  Requires-Dist: black~=24.10; extra == "all"
18
18
  Requires-Dist: pycparser~=2.22; extra == "all"
@@ -85,11 +85,12 @@ omdev/interp/__main__.py,sha256=GMCqeGYltgt5dlJzHxY9gqisa8cRkrPfmZYuZnjg4WI,162
85
85
  omdev/interp/cli.py,sha256=kgqA-Pc2RVkvkEpAKde30R5JKemgwurUcG6uPaNJyFc,2234
86
86
  omdev/interp/inspect.py,sha256=ORfO90xfGftyvEJHuEOD5yPk-9mxdxn27SYHwZywWFI,2888
87
87
  omdev/interp/providers.py,sha256=yHZQ6gYjkvSmMBvrKy3I77D7PnW67Bf3igTKY8DD9K4,1839
88
- omdev/interp/pyenv.py,sha256=8SromtT5y6f5q0hT__-r5PZSOHg-PQc-6t-ITdS5eo4,14302
88
+ omdev/interp/pyenv.py,sha256=KgsAwVNdse8UAR_6Lt4V4Zxqgm-kteOpJHxiD5vKc4M,14314
89
89
  omdev/interp/resolvers.py,sha256=_xxmf9KrWg5Zpi4UjAMKMB8UgrXLq_sJ2Y5qpNhLjqw,3091
90
- omdev/interp/standalone.py,sha256=As4sDe9_Iq0b00Q28BaiEjnk9pRR6qq1fjSKnveqgfc,7722
91
- omdev/interp/system.py,sha256=-ihkrZbUFpnZu0Au4kQbl5oqQSXDtGabTTmn7fhTBts,3561
90
+ omdev/interp/standalone.py,sha256=jJnncea4PIuaW-KwD2YiWDn8zTmwmsJNUKpF-qC2bwo,7725
91
+ omdev/interp/system.py,sha256=-sIbIPgmDU9jKw_nw-zTgOertDJTJ6BwJ-i6fU81KsY,3561
92
92
  omdev/interp/types.py,sha256=5dFGYyaCrXN-VL43PhBvlEti97fYW3EzfBmK9N4Wmdo,2496
93
+ omdev/interp/uv.py,sha256=6EF5i_n530F9KUa99xT6RB8vF6FSqElDHu3lbk1ppBo,662
93
94
  omdev/magic/__init__.py,sha256=CBzRB71RLyylkrj8dph6JUEddA8KSMJvDgriHqFfJGU,478
94
95
  omdev/magic/find.py,sha256=tTmpWXAleaXG3_kNOsRF7s8D0CpYMXbdz6-HbCNBW90,7070
95
96
  omdev/magic/magic.py,sha256=h1nxoW6CV1MRCiHjDt3sO4kmG0qTtTRbkDNiPLGo2BE,224
@@ -134,8 +135,8 @@ omdev/scripts/bumpversion.py,sha256=Kn7fo73Hs8uJh3Hi3EIyLOlzLPWAC6dwuD_lZ3cIzuY,
134
135
  omdev/scripts/execrss.py,sha256=mR0G0wERBYtQmVIn63lCIIFb5zkCM6X_XOENDFYDBKc,651
135
136
  omdev/scripts/exectime.py,sha256=sFb376GflU6s9gNX-2-we8hgH6w5MuQNS9g6i4SqJIo,610
136
137
  omdev/scripts/importtrace.py,sha256=oa7CtcWJVMNDbyIEiRHej6ICfABfErMeo4_haIqe18Q,14041
137
- omdev/scripts/interp.py,sha256=Bdtcovhk8Sa8-LmbGyz5TLty7RI3W_DAjxjGQJUvR6s,100905
138
- omdev/scripts/pyproject.py,sha256=oe2zzPZRMnvIpZVRc9pg3ihXuhWy0q7fZerzGR0ZmB0,206497
138
+ omdev/scripts/interp.py,sha256=ReEfpyIB5UfJXFdnOLylO1czk51ZoskoNkSQkjaQ4CA,100917
139
+ omdev/scripts/pyproject.py,sha256=y-E70h9al-ijgogYqTlCqmMT53o0iW8D2F2MjPFuKuU,207462
139
140
  omdev/scripts/slowcat.py,sha256=lssv4yrgJHiWfOiHkUut2p8E8Tq32zB-ujXESQxFFHY,2728
140
141
  omdev/scripts/tmpexec.py,sha256=WTYcf56Tj2qjYV14AWmV8SfT0u6Y8eIU6cKgQRvEK3c,1442
141
142
  omdev/toml/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
@@ -164,9 +165,9 @@ omdev/tools/json/rendering.py,sha256=jNShMfCpFR9-Kcn6cUFuOChXHjg71diuTC4x7Ofmz-o
164
165
  omdev/tools/pawk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
165
166
  omdev/tools/pawk/__main__.py,sha256=VCqeRVnqT1RPEoIrqHFSu4PXVMg4YEgF4qCQm90-eRI,66
166
167
  omdev/tools/pawk/pawk.py,sha256=Eckymn22GfychCQcQi96BFqRo_LmiJ-EPhC8TTUJdB4,11446
167
- omdev-0.0.0.dev175.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
168
- omdev-0.0.0.dev175.dist-info/METADATA,sha256=e0d6AF8lWfqrpDr6If32qrD6JO06ObWzezSYXu1-K9E,1760
169
- omdev-0.0.0.dev175.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
170
- omdev-0.0.0.dev175.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
171
- omdev-0.0.0.dev175.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
172
- omdev-0.0.0.dev175.dist-info/RECORD,,
168
+ omdev-0.0.0.dev177.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
169
+ omdev-0.0.0.dev177.dist-info/METADATA,sha256=Kg8GR5oTBzACAwXukDJ3oLe71RG42r87qe_3H8R1M64,1760
170
+ omdev-0.0.0.dev177.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
171
+ omdev-0.0.0.dev177.dist-info/entry_points.txt,sha256=dHLXFmq5D9B8qUyhRtFqTGWGxlbx3t5ejedjrnXNYLU,33
172
+ omdev-0.0.0.dev177.dist-info/top_level.txt,sha256=1nr7j30fEWgLYHW3lGR9pkdHkb7knv1U1ES1XRNVQ6k,6
173
+ omdev-0.0.0.dev177.dist-info/RECORD,,