pkl-python 0.1.15__tar.gz → 0.1.17__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.
Files changed (31) hide show
  1. {pkl_python-0.1.15/src/pkl_python.egg-info → pkl_python-0.1.17}/PKG-INFO +11 -8
  2. {pkl_python-0.1.15 → pkl_python-0.1.17}/README.md +7 -6
  3. {pkl_python-0.1.15 → pkl_python-0.1.17}/pyproject.toml +1 -0
  4. pkl_python-0.1.17/src/pkl/VERSION +1 -0
  5. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/__init__.py +35 -15
  6. {pkl_python-0.1.15 → pkl_python-0.1.17/src/pkl_python.egg-info}/PKG-INFO +11 -8
  7. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl_python.egg-info/requires.txt +1 -0
  8. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_load.py +5 -0
  9. pkl_python-0.1.15/src/pkl/VERSION +0 -1
  10. {pkl_python-0.1.15 → pkl_python-0.1.17}/LICENSE +0 -0
  11. {pkl_python-0.1.15 → pkl_python-0.1.17}/setup.cfg +0 -0
  12. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/binary_manager.py +0 -0
  13. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/evaluator_manager.py +0 -0
  14. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/evaluator_options.py +0 -0
  15. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/msgapi.py +0 -0
  16. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/parser.py +0 -0
  17. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/reader.py +0 -0
  18. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/server.py +0 -0
  19. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl/utils.py +0 -0
  20. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl_gen_python.py +0 -0
  21. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl_python.egg-info/SOURCES.txt +0 -0
  22. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl_python.egg-info/dependency_links.txt +0 -0
  23. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl_python.egg-info/entry_points.txt +0 -0
  24. {pkl_python-0.1.15 → pkl_python-0.1.17}/src/pkl_python.egg-info/top_level.txt +0 -0
  25. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_binary.py +0 -0
  26. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_evaluator_manager.py +0 -0
  27. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_fixtures.py +0 -0
  28. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_parser.py +0 -0
  29. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_readers.py +0 -0
  30. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_server.py +0 -0
  31. {pkl_python-0.1.15 → pkl_python-0.1.17}/tests/test_trace.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pkl-python
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: Python library for Apple's PKL.
5
5
  Author-email: Jungwoo Yang <jwyang0213@gmail.com>
6
6
  License: MIT License
@@ -35,6 +35,7 @@ Requires-Python: >=3.8
35
35
  Description-Content-Type: text/markdown
36
36
  License-File: LICENSE
37
37
  Requires-Dist: msgpack>=1.0.8
38
+ Requires-Dist: requests>=2.31.0
38
39
  Provides-Extra: dev
39
40
  Requires-Dist: pre-commit; extra == "dev"
40
41
  Requires-Dist: black; extra == "dev"
@@ -44,6 +45,7 @@ Requires-Dist: pylint; extra == "dev"
44
45
  Requires-Dist: pytest; extra == "dev"
45
46
  Requires-Dist: pytest-cov; extra == "dev"
46
47
  Requires-Dist: tox; extra == "dev"
48
+ Dynamic: license-file
47
49
 
48
50
  > [!CAUTION]
49
51
  >
@@ -68,6 +70,7 @@ Here's how you can start using `pkl-python` to load a PKL module:
68
70
  import pkl
69
71
 
70
72
  config = pkl.load("path/to/pkl/example_module.pkl")
73
+ config = pkl.loads("a: Int = 1 + 1")
71
74
  ```
72
75
 
73
76
  ### Code Generation
@@ -78,10 +81,6 @@ However, codegen lets you expect contents of pkl files within Python modules.
78
81
  pkl-gen-python path/to/pkl/example_module.pkl
79
82
  ```
80
83
 
81
- ### Status
82
- * Evaluator API: functional
83
- * Code Generation: functional, but needs refining
84
-
85
84
  ### TODO
86
85
  * [x] (codgen) pip binary installation
87
86
  * [ ] (codgen) gatherer depth-first ordering
@@ -89,7 +88,6 @@ pkl-gen-python path/to/pkl/example_module.pkl
89
88
 
90
89
 
91
90
  ## Advanced Features
92
- For details on the parameters, refer [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).
93
91
 
94
92
  ```python
95
93
  import pkl
@@ -100,6 +98,11 @@ config = pkl.load(None, module_text="a: Int = 1 + 1")
100
98
  config = pkl.load("./tests/types.pkl", debug=True)
101
99
  ```
102
100
 
101
+ ### `pkl.load` Parameters Detail
102
+ For details on the parameters, refer
103
+ * [`pkl eval`](https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval)
104
+ * [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).
105
+
103
106
  ### Custom Readers
104
107
  It is possible to add module or resource or module readers:
105
108
  ```python
@@ -123,7 +126,7 @@ opts = PreconfiguredOptions(
123
126
  moduleReaders=[TestModuleReader("customfs", True, True, True)]
124
127
  )
125
128
  opts.allowedModules.append("customfs:")
126
- config = pkl.load("./tests/myModule.pkl", evaluator_options=opts)
129
+ config = pkl.load("./tests/pkls/myModule.pkl", evaluator_options=opts)
127
130
  ```
128
131
 
129
132
  ## Appendix
@@ -21,6 +21,7 @@ Here's how you can start using `pkl-python` to load a PKL module:
21
21
  import pkl
22
22
 
23
23
  config = pkl.load("path/to/pkl/example_module.pkl")
24
+ config = pkl.loads("a: Int = 1 + 1")
24
25
  ```
25
26
 
26
27
  ### Code Generation
@@ -31,10 +32,6 @@ However, codegen lets you expect contents of pkl files within Python modules.
31
32
  pkl-gen-python path/to/pkl/example_module.pkl
32
33
  ```
33
34
 
34
- ### Status
35
- * Evaluator API: functional
36
- * Code Generation: functional, but needs refining
37
-
38
35
  ### TODO
39
36
  * [x] (codgen) pip binary installation
40
37
  * [ ] (codgen) gatherer depth-first ordering
@@ -42,7 +39,6 @@ pkl-gen-python path/to/pkl/example_module.pkl
42
39
 
43
40
 
44
41
  ## Advanced Features
45
- For details on the parameters, refer [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).
46
42
 
47
43
  ```python
48
44
  import pkl
@@ -53,6 +49,11 @@ config = pkl.load(None, module_text="a: Int = 1 + 1")
53
49
  config = pkl.load("./tests/types.pkl", debug=True)
54
50
  ```
55
51
 
52
+ ### `pkl.load` Parameters Detail
53
+ For details on the parameters, refer
54
+ * [`pkl eval`](https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval)
55
+ * [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).
56
+
56
57
  ### Custom Readers
57
58
  It is possible to add module or resource or module readers:
58
59
  ```python
@@ -76,7 +77,7 @@ opts = PreconfiguredOptions(
76
77
  moduleReaders=[TestModuleReader("customfs", True, True, True)]
77
78
  )
78
79
  opts.allowedModules.append("customfs:")
79
- config = pkl.load("./tests/myModule.pkl", evaluator_options=opts)
80
+ config = pkl.load("./tests/pkls/myModule.pkl", evaluator_options=opts)
80
81
  ```
81
82
 
82
83
  ## Appendix
@@ -19,6 +19,7 @@ classifiers = [
19
19
  ]
20
20
  dependencies = [
21
21
  "msgpack >= 1.0.8",
22
+ "requests >= 2.31.0",
22
23
  ]
23
24
 
24
25
  [tool.setuptools]
@@ -0,0 +1 @@
1
+ 0.1.17
@@ -14,23 +14,15 @@ with open(os.path.join(os.path.dirname(__file__), "VERSION"), "r") as _f:
14
14
  __version__ = _f.read().strip()
15
15
 
16
16
 
17
- class PklDefaultType:
18
- def __repr__(self):
19
- return "<PklDefault>"
20
-
21
-
22
- PKL_DEFAULT = PklDefaultType()
23
-
24
-
25
17
  def _search_project_dir(module_path: str) -> str:
26
18
  cur_path = Path(module_path).parent.absolute()
19
+ root_path = cur_path.root
20
+
27
21
  while not (cur_path / "PklProject").exists():
28
- cur_path = cur_path.parent
29
- if str(cur_path) == "/":
22
+ if cur_path == cur_path.parent or cur_path == root_path:
30
23
  break
24
+ cur_path = cur_path.parent
31
25
 
32
- if str(cur_path) == "/":
33
- cur_path = Path(module_path).parent
34
26
  return str(cur_path.absolute())
35
27
 
36
28
 
@@ -54,7 +46,7 @@ def load(
54
46
  *,
55
47
  module_text: Optional[str] = None,
56
48
  expr: Optional[str] = None,
57
- project_dir: str = PKL_DEFAULT,
49
+ project_dir: Optional[str] = None,
58
50
  evaluator_options: EvaluatorOptions = PreconfiguredOptions(),
59
51
  parser=None,
60
52
  debug=False,
@@ -69,7 +61,7 @@ def load(
69
61
  If None, the module is loaded from the specified URI.
70
62
  expr (Optional[str], None): Optionally, a Pkl expression to be evaluated
71
63
  within the loaded module. If None, the entire module is evaluated.
72
- project_dir (str, PKL_DEFAULT): The project directory to use for this command.
64
+ project_dir (Optional[str], None): The project directory to use for this command.
73
65
  By default, searches up from the working directory for a PklProject file.
74
66
  evaluator_options (EvaluatorOptions, PreconfiguredOptions()):
75
67
  extra options for evaluator
@@ -88,7 +80,7 @@ def load(
88
80
 
89
81
  source = _parse_module_uri(module_uri, module_text)
90
82
 
91
- if project_dir is PKL_DEFAULT:
83
+ if project_dir is None:
92
84
  project_dir = _search_project_dir(str(module_uri))
93
85
 
94
86
  with EvaluatorManager(debug=debug) as manager:
@@ -102,8 +94,36 @@ def load(
102
94
  return config
103
95
 
104
96
 
97
+ def loads(
98
+ module_text: Optional[str],
99
+ *,
100
+ expr: Optional[str] = None,
101
+ project_dir: Optional[str] = None,
102
+ evaluator_options: EvaluatorOptions = PreconfiguredOptions(),
103
+ parser=None,
104
+ debug=False,
105
+ **kwargs,
106
+ ):
107
+ """
108
+ This function is a specialized version of `load` that defaults `module_uri` to None.
109
+
110
+ {load.__doc__}
111
+ """
112
+ return load(
113
+ module_uri=None,
114
+ module_text=module_text,
115
+ expr=expr,
116
+ project_dir=project_dir,
117
+ evaluator_options=evaluator_options,
118
+ parser=parser,
119
+ debug=debug,
120
+ **kwargs,
121
+ )
122
+
123
+
105
124
  __all__ = [
106
125
  "load",
126
+ "loads",
107
127
  "Evaluator",
108
128
  "EvaluatorManager",
109
129
  "EvaluatorOptions",
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pkl-python
3
- Version: 0.1.15
3
+ Version: 0.1.17
4
4
  Summary: Python library for Apple's PKL.
5
5
  Author-email: Jungwoo Yang <jwyang0213@gmail.com>
6
6
  License: MIT License
@@ -35,6 +35,7 @@ Requires-Python: >=3.8
35
35
  Description-Content-Type: text/markdown
36
36
  License-File: LICENSE
37
37
  Requires-Dist: msgpack>=1.0.8
38
+ Requires-Dist: requests>=2.31.0
38
39
  Provides-Extra: dev
39
40
  Requires-Dist: pre-commit; extra == "dev"
40
41
  Requires-Dist: black; extra == "dev"
@@ -44,6 +45,7 @@ Requires-Dist: pylint; extra == "dev"
44
45
  Requires-Dist: pytest; extra == "dev"
45
46
  Requires-Dist: pytest-cov; extra == "dev"
46
47
  Requires-Dist: tox; extra == "dev"
48
+ Dynamic: license-file
47
49
 
48
50
  > [!CAUTION]
49
51
  >
@@ -68,6 +70,7 @@ Here's how you can start using `pkl-python` to load a PKL module:
68
70
  import pkl
69
71
 
70
72
  config = pkl.load("path/to/pkl/example_module.pkl")
73
+ config = pkl.loads("a: Int = 1 + 1")
71
74
  ```
72
75
 
73
76
  ### Code Generation
@@ -78,10 +81,6 @@ However, codegen lets you expect contents of pkl files within Python modules.
78
81
  pkl-gen-python path/to/pkl/example_module.pkl
79
82
  ```
80
83
 
81
- ### Status
82
- * Evaluator API: functional
83
- * Code Generation: functional, but needs refining
84
-
85
84
  ### TODO
86
85
  * [x] (codgen) pip binary installation
87
86
  * [ ] (codgen) gatherer depth-first ordering
@@ -89,7 +88,6 @@ pkl-gen-python path/to/pkl/example_module.pkl
89
88
 
90
89
 
91
90
  ## Advanced Features
92
- For details on the parameters, refer [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).
93
91
 
94
92
  ```python
95
93
  import pkl
@@ -100,6 +98,11 @@ config = pkl.load(None, module_text="a: Int = 1 + 1")
100
98
  config = pkl.load("./tests/types.pkl", debug=True)
101
99
  ```
102
100
 
101
+ ### `pkl.load` Parameters Detail
102
+ For details on the parameters, refer
103
+ * [`pkl eval`](https://pkl-lang.org/main/current/pkl-cli/index.html#command-eval)
104
+ * [Message Passing API](https://pkl-lang.org/main/current/bindings-specification/message-passing-api.html).
105
+
103
106
  ### Custom Readers
104
107
  It is possible to add module or resource or module readers:
105
108
  ```python
@@ -123,7 +126,7 @@ opts = PreconfiguredOptions(
123
126
  moduleReaders=[TestModuleReader("customfs", True, True, True)]
124
127
  )
125
128
  opts.allowedModules.append("customfs:")
126
- config = pkl.load("./tests/myModule.pkl", evaluator_options=opts)
129
+ config = pkl.load("./tests/pkls/myModule.pkl", evaluator_options=opts)
127
130
  ```
128
131
 
129
132
  ## Appendix
@@ -1,4 +1,5 @@
1
1
  msgpack>=1.0.8
2
+ requests>=2.31.0
2
3
 
3
4
  [dev]
4
5
  pre-commit
@@ -5,6 +5,11 @@ def test_load():
5
5
  _ = pkl.load("./tests/pkls/types.pkl")
6
6
 
7
7
 
8
+ def test_loads():
9
+ config = pkl.loads("a: Int = 1 + 1")
10
+ assert config.a == 2
11
+
12
+
8
13
  def test_load_expr():
9
14
  config = pkl.load("./tests/pkls/types.pkl", expr="datasize")
10
15
  assert config.__class__.__name__ == "DataSize"
@@ -1 +0,0 @@
1
- 0.1.15
File without changes
File without changes