pyevaljs4 0.2.1__tar.gz → 0.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyevaljs4
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A high-performance Python library that relies on nodejs to execute JavaScript
5
5
  Home-page: https://github.com/Smawexi/PyEvalJS4
6
6
  Author: Samwe
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
15
16
  Classifier: Programming Language :: Python :: Implementation :: CPython
16
17
  Classifier: License :: OSI Approved :: MIT License
17
18
  Requires-Python: >=3.7.0
@@ -4,12 +4,13 @@ from .pyevaljs import RunTime, JSException, RunTimeNotFoundException
4
4
  from .__version__ import version
5
5
 
6
6
 
7
- def compile_(js_code: str = None, mode: str = None):
7
+ def compile_(js_code: str = None, mode: str = None, cwd: str = None):
8
8
  """
9
9
  Compile js code
10
10
  :param js_code: js source code
11
11
  :param mode: Execution mode, the default is '.js', meaning it will execute with '.js' behavior.
12
12
  Other optional values include '.cjs' and '.mjs', etc.
13
+ :param cwd: Working directory path
13
14
  :return: RunTime
14
15
  """
15
16
  if js_code is None:
@@ -18,4 +19,4 @@ def compile_(js_code: str = None, mode: str = None):
18
19
  if mode is None:
19
20
  mode = ".js"
20
21
 
21
- return RunTime._compile(js_code, mode)
22
+ return RunTime._compile(js_code, mode, cwd)
@@ -0,0 +1 @@
1
+ version = ".".join(map(str, (0, 2, 2)))
@@ -31,6 +31,7 @@ class RunTime:
31
31
  self._node = None
32
32
  self._node_env = get_node_env()
33
33
  self._path = None
34
+ self._cwd = None
34
35
  self._initialize = False
35
36
  self._finalizer = None
36
37
  self._lock = threading.Lock()
@@ -44,7 +45,8 @@ class RunTime:
44
45
  stdout=subprocess.PIPE,
45
46
  stderr=subprocess.STDOUT,
46
47
  universal_newlines=True,
47
- encoding='utf-8'
48
+ encoding='utf-8',
49
+ cwd=self._cwd
48
50
  )
49
51
  except Exception as e:
50
52
  os.remove(self._path)
@@ -54,11 +56,18 @@ class RunTime:
54
56
  self._initialize = True
55
57
 
56
58
  @classmethod
57
- def _compile(cls, source: str, suffix: str):
59
+ def _compile(cls, source: str, suffix: str, cwd: str = None):
58
60
  self = cls()
59
- fd, path = tempfile.mkstemp(suffix=suffix, dir='.')
61
+ self._cwd = cwd
62
+ if self._cwd is None:
63
+ _dir = "."
64
+ else:
65
+ _dir = self._cwd
66
+
67
+ fd, path = tempfile.mkstemp(suffix=suffix, dir=_dir)
60
68
  with open(fd, 'w', encoding='utf-8') as fp:
61
69
  fp.write(NODE_PROGRAM.format(source=json.dumps(source)))
70
+
62
71
  self._path = path
63
72
  self._init()
64
73
  return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyevaljs4
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: A high-performance Python library that relies on nodejs to execute JavaScript
5
5
  Home-page: https://github.com/Smawexi/PyEvalJS4
6
6
  Author: Samwe
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
13
  Classifier: Programming Language :: Python :: 3.12
14
14
  Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
15
16
  Classifier: Programming Language :: Python :: Implementation :: CPython
16
17
  Classifier: License :: OSI Approved :: MIT License
17
18
  Requires-Python: >=3.7.0
@@ -28,6 +28,7 @@ setup(
28
28
  'Programming Language :: Python :: 3.11',
29
29
  'Programming Language :: Python :: 3.12',
30
30
  'Programming Language :: Python :: 3.13',
31
+ 'Programming Language :: Python :: 3.14',
31
32
  'Programming Language :: Python :: Implementation :: CPython',
32
33
  'License :: OSI Approved :: MIT License'
33
34
  ],
@@ -1 +0,0 @@
1
- version = ".".join(map(str, (0, 2, 1)))
File without changes
File without changes
File without changes