iris-pex-embedded-python 3.4.4b6__py3-none-any.whl → 3.5.0b1__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 iris-pex-embedded-python might be problematic. Click here for more details.

iop/_utils.py CHANGED
@@ -1,12 +1,12 @@
1
1
  import os
2
2
  import sys
3
- import ast
4
- import inspect
5
3
  import importlib
6
4
  import importlib.util
7
5
  import importlib.resources
8
6
  import json
9
- from typing import Any, Dict, Optional, Union
7
+ import inspect
8
+ import ast
9
+ from typing import Any, Dict, Optional, Union, Tuple
10
10
 
11
11
  import xmltodict
12
12
  from pydantic import TypeAdapter
@@ -80,6 +80,31 @@ class _Utils():
80
80
  """
81
81
  _Utils.raise_on_error(_iris.get_iris().cls('IOP.Message.JSONSchema').Import(schema_str,categories,schema_name))
82
82
 
83
+ @staticmethod
84
+ def get_python_settings() -> Tuple[str,str,str]:
85
+ import iris_utils._cli
86
+
87
+ pythonlib = iris_utils._cli.find_libpython()
88
+ pythonpath = _Utils._get_python_path()
89
+ pythonversion = sys.version[:4]
90
+
91
+ if not pythonlib:
92
+ pythonlib = ""
93
+
94
+ return pythonlib, pythonpath, pythonversion
95
+
96
+ @staticmethod
97
+ def _get_python_path() -> str:
98
+
99
+ if "VIRTUAL_ENV" in os.environ:
100
+ return os.path.join(
101
+ os.environ["VIRTUAL_ENV"],
102
+ "lib",
103
+ f"python{sys.version[:4]}",
104
+ "site-packages"
105
+ )
106
+ return ""
107
+
83
108
  @staticmethod
84
109
  def register_component(module:str,classname:str,path:str,overwrite:int=1,iris_classname:str='Python'):
85
110
  """
@@ -99,8 +124,9 @@ class _Utils():
99
124
  """
100
125
  path = os.path.abspath(os.path.normpath(path))
101
126
  fullpath = _Utils.guess_path(module,path)
127
+ pythonlib, pythonpath, pythonversion = _Utils.get_python_settings()
102
128
  try:
103
- _iris.get_iris().cls('IOP.Utils').dispatchRegisterComponent(module,classname,path,fullpath,overwrite,iris_classname)
129
+ _iris.get_iris().cls('IOP.Utils').dispatchRegisterComponent(module,classname,path,fullpath,overwrite,iris_classname,pythonlib,pythonpath,pythonversion)
104
130
  except RuntimeError as e:
105
131
  # New message error : Make sure the iop package is installed in iris
106
132
  raise RuntimeError("Iris class : IOP.Utils not found. Make sure the iop package is installed in iris eg: iop --init.") from e
@@ -131,6 +131,18 @@ Storage Default
131
131
  <Value name="10">
132
132
  <Value>%traceback</Value>
133
133
  </Value>
134
+ <Value name="11">
135
+ <Value>%PythonPath</Value>
136
+ </Value>
137
+ <Value name="12">
138
+ <Value>%PythonRuntimeLibrary</Value>
139
+ </Value>
140
+ <Value name="13">
141
+ <Value>%PythonRuntimeLibraryVersion</Value>
142
+ </Value>
143
+ <Value name="14">
144
+ <Value>%Venv</Value>
145
+ </Value>
134
146
  </Data>
135
147
  <Data name="persistentProperties">
136
148
  <Attribute>persistentProperties</Attribute>
iop/cls/IOP/Common.cls CHANGED
@@ -29,6 +29,14 @@ Property %PythonInterpreterPath As %String(MAXLEN = 255);
29
29
 
30
30
  Property %traceback As %Boolean [ InitialExpression = 1 ];
31
31
 
32
+ Property %Venv As %Boolean [ InitialExpression = 0 ];
33
+
34
+ Property %PythonPath As %String(MAXLEN = 255);
35
+
36
+ Property %PythonRuntimeLibrary As %String(MAXLEN = 255);
37
+
38
+ Property %PythonRuntimeLibraryVersion As %String;
39
+
32
40
  /// Get Class
33
41
  Method GetClass() As %SYS.Python
34
42
  {
@@ -78,18 +86,51 @@ Method DisplayTraceback(ex) As %Status
78
86
  Method OnInit() As %Status
79
87
  {
80
88
  set tSC = $$$OK
89
+ set tSemName = "^PythonSettings"
90
+ if $SYSTEM.Semaphore.Open(tSemName) '= 1 {
91
+ // Create the semaphore if it does not exist
92
+ set tSC = $SYSTEM.Semaphore.Create(tSemName)
93
+ }
81
94
  try {
95
+ LOCK +^PythonSettings:5
96
+
97
+ if ..%Venv {
98
+ $$$ThrowOnError(##class(IOP.Utils).SetPythonSettings(..%PythonRuntimeLibrary, ..%PythonPath, ..%PythonRuntimeLibraryVersion))
99
+ }
100
+
101
+ do ..DisplayPythonVersion()
102
+
82
103
  do $system.Python.Debugging(..%traceback)
104
+
83
105
  $$$ThrowOnError(..Connect())
106
+ LOCK -^PythonSettings
107
+
84
108
  do ..%class."_debugpy"($this)
109
+
85
110
  do ..%class."_dispatch_on_init"($this)
86
111
  } catch ex {
87
112
 
88
113
  set tSC = ..DisplayTraceback(ex)
89
114
  }
115
+ LOCK -^PythonSettings
90
116
  quit tSC
91
117
  }
92
118
 
119
+ Method DisplayPythonVersion()
120
+ {
121
+ set sys = ##class(%SYS.Python).Import("sys")
122
+ set version = sys.version
123
+ set versionInfo = sys."version_info"
124
+ set major = versionInfo.major
125
+ set minor = versionInfo.minor
126
+ set micro = versionInfo.micro
127
+ set releaseLevel = versionInfo.releaselevel
128
+ set serial = versionInfo.serial
129
+
130
+ $$$LOGINFO("Python Version: "_ version)
131
+ $$$LOGINFO("Version Info: "_ major_ "."_ minor_ "."_ micro_" ("_ releaseLevel_ ", "_serial_ ")")
132
+ }
133
+
93
134
  ClassMethod SetPythonPath(pClasspaths)
94
135
  {
95
136
  set sys = ##class(%SYS.Python).Import("sys")
@@ -196,6 +237,11 @@ Method SetPropertyValues()
196
237
  set tSQL = tSQL _ " and name <> '%port'"
197
238
  set tSQL = tSQL _ " and name <> '%PythonInterpreterPath'"
198
239
  set tSQL = tSQL _ " and name <> '%traceback'"
240
+ set tSQL = tSQL _ " and name <> '%PythonPath'"
241
+ set tSQL = tSQL _ " and name <> '%PythonRuntimeLibrary'"
242
+ set tSQL = tSQL _ " and name <> '%PythonRuntimeLibraryVersion'"
243
+ set tSQL = tSQL _ " and name <> '%settings'"
244
+ set tSQL = tSQL _ " and name <> '%Venv'"
199
245
 
200
246
  set tStmt = ##class(%SQL.Statement).%New()
201
247
 
iop/cls/IOP/Utils.cls CHANGED
@@ -13,10 +13,13 @@ ClassMethod dispatchRegisterComponent(
13
13
  pCLASSPATHS As %String = "",
14
14
  pFullpath As %String = "",
15
15
  pOverwrite As %Boolean = 0,
16
- pProxyClassname As %String = "") As %Status
16
+ pProxyClassname As %String = "",
17
+ pPythonLib,
18
+ pPythonPath,
19
+ pPythonVersion) As %Status
17
20
  {
18
21
  set tSc = $$$OK
19
- $$$ThrowOnError(##class(IOP.Utils).RegisterComponent(pModule, pRemoteClassname, pCLASSPATHS, pFullpath, pOverwrite , pProxyClassname))
22
+ $$$ThrowOnError(##class(IOP.Utils).RegisterComponent(pModule, pRemoteClassname, pCLASSPATHS, pFullpath, pOverwrite , pProxyClassname,pPythonLib, pPythonPath, pPythonVersion))
20
23
  return tSc
21
24
  }
22
25
 
@@ -27,7 +30,10 @@ ClassMethod RegisterComponent(
27
30
  pCLASSPATHS As %String = "",
28
31
  pFullpath As %String = "",
29
32
  pOverwrite As %Boolean = 0,
30
- pProxyClassname As %String = "") As %Status
33
+ pProxyClassname As %String = "",
34
+ pPythonLib,
35
+ pPythonPath,
36
+ pPythonVersion) As %Status
31
37
  {
32
38
  #dim tSC As %Status = $$$OK
33
39
  #dim ex As %Exception.AbstractException
@@ -39,6 +45,9 @@ ClassMethod RegisterComponent(
39
45
  Quit:(""=pModule) $$$ERROR($$$EnsErrGeneral,"Must specify the module of the remote code.")
40
46
 
41
47
  Try {
48
+ LOCK +^PythonSettings:10
49
+ // Set the Python settings
50
+ do ..SetPythonSettings(pPythonLib, pPythonPath, pPythonVersion)
42
51
 
43
52
  $$$ThrowOnError(..GetRemoteClassInfo(pRemoteClassname,pModule,pCLASSPATHS,pFullpath,.tClassDetails,.tRemoteSettings))
44
53
 
@@ -47,13 +56,13 @@ ClassMethod RegisterComponent(
47
56
  Set tConnectionSettings("Classname") = pRemoteClassname
48
57
  Set:(""=pProxyClassname) pProxyClassname = "User."_pRemoteClassname
49
58
 
50
- $$$ThrowOnError(..GenerateProxyClass(pProxyClassname,.tConnectionSettings,tClassDetails,tRemoteSettings,pOverwrite))
59
+ $$$ThrowOnError(..GenerateProxyClass(pProxyClassname,.tConnectionSettings,tClassDetails,tRemoteSettings,pOverwrite, pPythonLib, pPythonPath, pPythonVersion))
51
60
 
52
61
  } Catch ex {
53
62
  set msg = $System.Status.GetOneStatusText(ex.AsStatus(),1)
54
63
  set tSC = $$$ERROR($$$EnsErrGeneral,msg)
55
64
  }
56
-
65
+ LOCK -PythonSettings
57
66
  Quit tSC
58
67
  }
59
68
 
@@ -165,7 +174,10 @@ ClassMethod GenerateProxyClass(
165
174
  ByRef pConnectionSettings,
166
175
  pClassDetails As %String = "",
167
176
  pRemoteSettings As %String = "",
168
- pOverwrite As %Boolean = 0) As %Status [ Internal, Private ]
177
+ pOverwrite As %Boolean = 0,
178
+ pPythonLib,
179
+ pPythonPath,
180
+ pPythonVersion) As %Status [ Internal, Private ]
169
181
  {
170
182
  #dim tSC As %Status = $$$OK
171
183
  #dim ex As %Exception.AbstractException
@@ -226,7 +238,9 @@ ClassMethod GenerateProxyClass(
226
238
  }
227
239
 
228
240
  #; Do not display any of the connection settings
229
- #dim tSETTINGSParamValue As %String = "%classname:Python $type,%module:Python $type,%settings:Python $type,%classpaths:Python $type,%enable:Python Debug $type,%timeout:Python Debug $type,%port:Python Debug $type,%PythonInterpreterPath:Python Debug $type,%traceback:Python Debug $type"
241
+ #dim tSETTINGSParamValue As %String = "%classname:Python $type,%module:Python $type,%settings:Python $type,%classpaths:Python $type"
242
+ set tSETTINGSParamValue = tSETTINGSParamValue_","_"%enable:Python Debug $type,%timeout:Python Debug $type,%port:Python Debug $type,%PythonInterpreterPath:Python Debug $type,%traceback:Python Debug $type"
243
+ set tSETTINGSParamValue = tSETTINGSParamValue_","_"%PythonPath:Python Settings $type,%PythonRuntimeLibrary:Python Settings $type,%PythonRuntimeLibraryVersion:Python Settings $type,%Venv:Python Settings $type"
230
244
 
231
245
  #dim tPropClassname As %Dictionary.PropertyDefinition = ##class(%Dictionary.PropertyDefinition).%New()
232
246
  Set tPropClassname.Name = "%classname"
@@ -255,6 +269,38 @@ ClassMethod GenerateProxyClass(
255
269
  Set tPropLanguage.InitialExpression = $$$quote(pConnectionSettings("Module"))
256
270
  Set tSC = tCOSClass.Properties.Insert(tPropLanguage)
257
271
  Quit:$$$ISERR(tSC)
272
+
273
+ if pPythonLib'="" {
274
+ #dim tPropPythonLib As %Dictionary.PropertyDefinition = ##class(%Dictionary.PropertyDefinition).%New()
275
+ Set tPropPythonLib.Name = "%PythonRuntimeLibrary"
276
+ Set tPropPythonLib.Type = "%String"
277
+ Set tPropPythonLib.Internal = 1
278
+ Set tSC = tPropPythonLib.Parameters.SetAt("","MAXLEN")
279
+ Quit:$$$ISERR(tSC)
280
+ Set tPropPythonLib.InitialExpression = $$$quote(pPythonLib)
281
+ Set tSC = tCOSClass.Properties.Insert(tPropPythonLib)
282
+ Quit:$$$ISERR(tSC)
283
+ }
284
+ if pPythonPath'="" {
285
+ #dim tPropPythonPath As %Dictionary.PropertyDefinition = ##class(%Dictionary.PropertyDefinition).%New()
286
+ Set tPropPythonPath.Name = "%PythonPath"
287
+ Set tPropPythonPath.Type = "%String"
288
+ Set tSC = tPropPythonPath.Parameters.SetAt("","MAXLEN")
289
+ Quit:$$$ISERR(tSC)
290
+ Set tPropPythonPath.Internal = 1
291
+ Set tPropPythonPath.InitialExpression = $$$quote(pPythonPath)
292
+ Set tSC = tCOSClass.Properties.Insert(tPropPythonPath)
293
+ Quit:$$$ISERR(tSC)
294
+ }
295
+ if pPythonVersion'="" {
296
+ #dim tPropPythonVersion As %Dictionary.PropertyDefinition = ##class(%Dictionary.PropertyDefinition).%New()
297
+ Set tPropPythonVersion.Name = "%PythonRuntimeLibraryVersion"
298
+ Set tPropPythonVersion.Type = "%String"
299
+ Set tPropPythonVersion.Internal = 1
300
+ Set tPropPythonVersion.InitialExpression = $$$quote(pPythonVersion)
301
+ Set tSC = tCOSClass.Properties.Insert(tPropPythonVersion)
302
+ Quit:$$$ISERR(tSC)
303
+ }
258
304
 
259
305
  If $Case(tSuperClass,"IOP.BusinessService":1,"IOP.BusinessOperation":1,"IOP.DuplexService":1,"IOP.DuplexOperation":1,:0) {
260
306
  set builtins = ##class(%SYS.Python).Import("builtins")
@@ -419,4 +465,39 @@ ClassMethod dispatchTestComponent(
419
465
  Quit tOutput
420
466
  }
421
467
 
468
+ ClassMethod SetPythonSettings(
469
+ pPythonLib,
470
+ pPythonPath,
471
+ pPythonVersion) As %Status
472
+ {
473
+ set currentNS = $namespace
474
+ set $NAMESPACE = "%SYS"
475
+ set tSC = $$$OK
476
+
477
+ try {
478
+ // Get Config
479
+ $$$ThrowOnError(##Class(Config.config).Get(.Properties))
480
+ // Set the Python interpreter path
481
+ if pPythonPath'="" {
482
+ set Properties("PythonPath") = pPythonPath
483
+ }
484
+
485
+ // Set the Python runtime library
486
+ if pPythonLib'="" {
487
+ set Properties("PythonRuntimeLibrary") = pPythonLib
488
+ }
489
+
490
+ // Set the Python runtime library version
491
+ if pPythonVersion'="" {
492
+ set Properties("PythonRuntimeLibraryVersion") = pPythonVersion
493
+ }
494
+ $$$ThrowOnError(##Class(Config.config).Modify(.Properties))
495
+ } catch ex {
496
+ set tSC = ex.AsStatus()
497
+ }
498
+
499
+ set $NAMESPACE = currentNS
500
+ Quit tSC
501
+ }
502
+
422
503
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.4.4b6
3
+ Version: 3.5.0b1
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -49,18 +49,18 @@ iop/_outbound_adapter.py,sha256=cN7dkZyx9ED89yUGePsUYsUhlR3ze3w1JorCG8HvDCw,723
49
49
  iop/_private_session_duplex.py,sha256=c6Q0k-qnZi_JcIOdpUx1Edu44zVbUE2Kf2aCHM8Eq80,5202
50
50
  iop/_private_session_process.py,sha256=rvZFO6nWVwZtaEWJkSHyLTV-vhzDqQhsVi7INQLLwWI,1685
51
51
  iop/_serialization.py,sha256=8N5hNH2vrLW8DhAT1oK7hsFH6rTGoG4jR6qg4QMUBFs,6652
52
- iop/_utils.py,sha256=xK18eBxHPx6OzMakGzbxI4U0asZe42OVJKLyGEjg4a8,20471
52
+ iop/_utils.py,sha256=yAvssj3O3p9mLVJ_RvDIuawyYNhOIm5WrK0SANaSIwU,21256
53
53
  iop/cls/IOP/BusinessOperation.cls,sha256=E4rnujZi3QFd3uLtZ5YjLiMU_FWoN1gkBe19kxmYO34,932
54
- iop/cls/IOP/BusinessProcess.cls,sha256=81B2ypqp4N3q2c943-hHw-Z6BIEWZqnDu-ZlHvhln6Q,3126
54
+ iop/cls/IOP/BusinessProcess.cls,sha256=XJxzbiV0xokzRm-iI2Be5UIJLE3MlXr7W3WS_LkOCYs,3363
55
55
  iop/cls/IOP/BusinessService.cls,sha256=fplKrbQgA7cQgjKIqDR2IK2iD1iNHmT-QvWrozhE4n4,1189
56
- iop/cls/IOP/Common.cls,sha256=9ARv7CbQhqrNvSFg2ThW3Pxl884g0A7rU7Aeqk37V5o,13883
56
+ iop/cls/IOP/Common.cls,sha256=XlylmkDb5I6pxGLwX8cWzz1_-zVM5KKNMAaF2kgCry4,15351
57
57
  iop/cls/IOP/Director.cls,sha256=M43LoTb6lwSr0J81RFxi1YLW1mwda09wQ7Xqr3nBtxo,2008
58
58
  iop/cls/IOP/InboundAdapter.cls,sha256=H-gZfUy8M9YxAZXfp5HVYl3uLo-7Xg9YgojioB_eYMY,619
59
59
  iop/cls/IOP/Message.cls,sha256=6_iZzQaY0cA9FjXg0qECYZC6We8soAIrUwRBrlerC4w,25373
60
60
  iop/cls/IOP/OutboundAdapter.cls,sha256=OQoGFHUy2qV_kcsShTlWGOngDrdH5dhwux4eopZyIv4,967
61
61
  iop/cls/IOP/PickleMessage.cls,sha256=S3y7AClQ8mAILjxPuHdCjGosBZYzGbUQ5WTv4mYPNMQ,1673
62
62
  iop/cls/IOP/Test.cls,sha256=gAC9PEfMZsvAEWIa241-ug2FWAhITbN1SOispZzJPnI,2094
63
- iop/cls/IOP/Utils.cls,sha256=YDONQ6AwrQ3xF0eqmqg_qLCMoahy_5a8jD6_qxveONM,15616
63
+ iop/cls/IOP/Utils.cls,sha256=vdgSAZUH6C_gPHqpfMgbspEw5uFMp12NWoqqPIass58,18528
64
64
  iop/cls/IOP/Duplex/Operation.cls,sha256=K_fmgeLjPZQbHgNrc0kd6DUQoW0fDn1VHQjJxHo95Zk,525
65
65
  iop/cls/IOP/Duplex/Process.cls,sha256=xbefZ4z84a_IUhavWN6P_gZBzqkdJ5XRTXxro6iDvAg,6986
66
66
  iop/cls/IOP/Duplex/Service.cls,sha256=sTMOQUCMBgVitmQkM8bbsrmrRtCdj91VlctJ3I7b8WU,161
@@ -72,9 +72,9 @@ iop/cls/IOP/PrivateSession/Message/Start.cls,sha256=uk-WTe66GicCshgmVy3F5ugHiAyP
72
72
  iop/cls/IOP/PrivateSession/Message/Stop.cls,sha256=7g3gKFUjNg0WXBLuWnj-VnCs5G6hSE09YTzGEp0zbGc,1390
73
73
  iop/cls/IOP/Service/WSGI.cls,sha256=VLNCXEwmHW9dBnE51uGE1nvGX6T4HjhqePT3LVhsjAE,10440
74
74
  iop/wsgi/handlers.py,sha256=NrFLo_YbAh-x_PlWhAiWkQnUUN2Ss9HoEm63dDWCBpQ,2947
75
- iris_pex_embedded_python-3.4.4b6.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
76
- iris_pex_embedded_python-3.4.4b6.dist-info/METADATA,sha256=1ndhceHwd_eQLz_FGT6mbbQCvUp5idEy3QVYy6PEHCM,4415
77
- iris_pex_embedded_python-3.4.4b6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
78
- iris_pex_embedded_python-3.4.4b6.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
79
- iris_pex_embedded_python-3.4.4b6.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
80
- iris_pex_embedded_python-3.4.4b6.dist-info/RECORD,,
75
+ iris_pex_embedded_python-3.5.0b1.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
76
+ iris_pex_embedded_python-3.5.0b1.dist-info/METADATA,sha256=4lYAD4jvEvZk0bNSdTbFUMum55TmNPZub8GjYMyJWEI,4415
77
+ iris_pex_embedded_python-3.5.0b1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
78
+ iris_pex_embedded_python-3.5.0b1.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
79
+ iris_pex_embedded_python-3.5.0b1.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
80
+ iris_pex_embedded_python-3.5.0b1.dist-info/RECORD,,