yamlscript 0.1.97__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: yamlscript
3
- Version: 0.1.97
3
+ Version: 0.2.2
4
4
  Summary: Program in YAML — Code is Data
5
5
  Home-page: https://github.com/ingydotnet/yamlscript
6
6
  Author: Ingy döt Net
@@ -9,18 +9,18 @@ Add Logic to Your YAML Files
9
9
  ## Synopsis
10
10
 
11
11
  Load `file.yaml` with YS:
12
+
12
13
  ```yaml
13
14
  !YS-v0:
14
15
 
15
16
  # Get data from external sources:
16
17
  names-url =:
17
- "https://raw.githubusercontent.com/dominictarr/\
18
- random-name/master/first-names.json"
18
+ 'github:dominictarr/random-name/first-names.json'
19
19
 
20
20
  name-list =: names-url:curl:json/load
21
21
 
22
22
  # Data object with literal keys and generated values:
23
- name:: iname-list:shuffle:first
23
+ name:: name-list:shuffle:first
24
24
  aka:: name-list:rand-nth
25
25
  age:: &num 2 * 3 * 7
26
26
  color:: &hue
@@ -63,7 +63,7 @@ This makes YS a complete functional programming language right out of the box.
63
63
 
64
64
  Even though YS compiles to Clojure, and Clojure compiles to Java, there is no
65
65
  dependency on Java or the JVM.
66
- YS is compiled to a native shared library (`libyamlscript.so`) that can be used
66
+ YS is compiled to a native shared library (`libys.so`) that can be used
67
67
  by any programming language that can load shared libraries.
68
68
 
69
69
  To see the Clojure code that YS compiles to, you can use the YS
@@ -128,7 +128,7 @@ You can install this module like any other Python module:
128
128
  pip install yamlscript
129
129
  ```
130
130
 
131
- but you will need to have a system install of `libyamlscript.so`.
131
+ but you will need to have a system install of `libys.so`.
132
132
 
133
133
  One simple way to do that is with:
134
134
 
@@ -137,7 +137,7 @@ curl https://yamlscript.org/install | bash
137
137
  ```
138
138
 
139
139
  > Note: The above command will install the latest version of the YAMLScript
140
- command line utility, `ys`, and the shared library, `libyamlscript.so`, into
140
+ command line utility, `ys`, and the shared library, `libys.so`, into
141
141
  `~/local/bin` and `~/.local/lib` respectively.
142
142
 
143
143
  See <https://yamlscript.org/doc/install/> for more info.
@@ -2,10 +2,10 @@
2
2
  # This code is licensed under MIT license (See License for details)
3
3
 
4
4
  """
5
- Python binding/API for the libyamlscript shared library.
5
+ Python binding/API for the libys shared library.
6
6
 
7
7
  This module can be considered the reference implementation for YAMLScript
8
- FFI bindings to libyamlscript.
8
+ FFI bindings to libys.
9
9
 
10
10
  The current user facing API consists of a single class, `YAMLScript`, which
11
11
  has a single method: `.load(string)`.
@@ -15,8 +15,8 @@ object that the YAMLScript code evaluates to.
15
15
 
16
16
  # This value is automatically updated by 'make bump'.
17
17
  # The version number is used to find the correct shared library file.
18
- # We currently only support binding to an exact version of libyamlscript.
19
- yamlscript_version = '0.1.97'
18
+ # We currently only support binding to an exact version of libys.
19
+ yamlscript_version = '0.2.2'
20
20
 
21
21
  import os, sys
22
22
  import ctypes
@@ -26,8 +26,8 @@ import json
26
26
  assert sys.version_info >= (3, 6), \
27
27
  "Python 3.6 or greater required for 'yamlscript'."
28
28
 
29
- # Find the libyamlscript shared library file path:
30
- def find_libyamlscript_path():
29
+ # Find the libys shared library file path:
30
+ def find_libys_path():
31
31
  # We currently only support platforms that GraalVM supports.
32
32
  # And Windows is not yet implemented...
33
33
  # Confirm platform and determine file extension:
@@ -39,47 +39,47 @@ def find_libyamlscript_path():
39
39
  raise Exception(
40
40
  "Unsupported platform '%s' for yamlscript." % sys.platform)
41
41
 
42
- # We currently bind to an exact version of libyamlscript.
43
- # eg 'libyamlscript.so.0.1.97'
44
- libyamlscript_name = \
45
- "libyamlscript.%s.%s" % (so, yamlscript_version)
42
+ # We currently bind to an exact version of libys.
43
+ # eg 'libys.so.0.2.2'
44
+ libys_name = \
45
+ "libys.%s.%s" % (so, yamlscript_version)
46
46
 
47
- # Use LD_LIBRARY_PATH to find libyamlscript shared library, or default to
47
+ # Use LD_LIBRARY_PATH to find libys shared library, or default to
48
48
  # '/usr/local/lib' (where it is installed by default):
49
49
  ld_library_path = os.environ.get('LD_LIBRARY_PATH')
50
50
  ld_library_paths = ld_library_path.split(':') if ld_library_path else []
51
51
  ld_library_paths.append('/usr/local/lib')
52
52
  ld_library_paths.append(os.environ.get('HOME') + '/.local/lib')
53
53
 
54
- libyamlscript_path = None
54
+ libys_path = None
55
55
  for path in ld_library_paths:
56
- path = path + '/' + libyamlscript_name
56
+ path = path + '/' + libys_name
57
57
  if os.path.isfile(path):
58
- libyamlscript_path = path
58
+ libys_path = path
59
59
  break
60
60
 
61
- if not libyamlscript_path:
61
+ if not libys_path:
62
62
  raise Exception(
63
63
  """\
64
64
  Shared library file '%s' not found
65
65
  Try: curl https://yamlscript.org/install | VERSION=%s LIB=1 bash
66
66
  See: https://github.com/yaml/yamlscript/wiki/Installing-YAMLScript
67
- """ % (libyamlscript_name, yamlscript_version))
67
+ """ % (libys_name, yamlscript_version))
68
68
 
69
- return libyamlscript_path
69
+ return libys_path
70
70
 
71
- # Load libyamlscript shared library:
72
- libyamlscript = ctypes.CDLL(find_libyamlscript_path())
71
+ # Load libys shared library:
72
+ libys = ctypes.CDLL(find_libys_path())
73
73
 
74
74
  # Create binding to 'load_ys_to_json' function:
75
- load_ys_to_json = libyamlscript.load_ys_to_json
75
+ load_ys_to_json = libys.load_ys_to_json
76
76
  load_ys_to_json.restype = ctypes.c_char_p
77
77
 
78
78
 
79
79
  # The YAMLScript class is the main user facing API for this module.
80
80
  class YAMLScript():
81
81
  """
82
- Interface with the libyamlscript shared library.
82
+ Interface with the libys shared library.
83
83
 
84
84
  Usage:
85
85
  import yamlscript
@@ -96,7 +96,7 @@ class YAMLScript():
96
96
  self.isolatethread = ctypes.c_void_p()
97
97
 
98
98
  # Create a new GraalVM isolate:
99
- rc = libyamlscript.graal_create_isolate(
99
+ rc = libys.graal_create_isolate(
100
100
  None,
101
101
  None,
102
102
  ctypes.byref(self.isolatethread),
@@ -110,7 +110,7 @@ class YAMLScript():
110
110
  # Reset any previous error:
111
111
  self.error = None
112
112
 
113
- # Call 'load_ys_to_json' function in libyamlscript shared library:
113
+ # Call 'load_ys_to_json' function in libys shared library:
114
114
  data_json = load_ys_to_json(
115
115
  self.isolatethread,
116
116
  ctypes.c_char_p(bytes(input, "utf8")),
@@ -119,14 +119,14 @@ class YAMLScript():
119
119
  # Decode the JSON response:
120
120
  resp = json.loads(data_json)
121
121
 
122
- # Check for libyamlscript error in JSON response:
122
+ # Check for libys error in JSON response:
123
123
  self.error = resp.get('error')
124
124
  if self.error:
125
125
  raise Exception(self.error['cause'])
126
126
 
127
127
  # Get the response object from evaluating the YAMLScript string:
128
128
  if not 'data' in resp:
129
- raise Exception("Unexpected response from 'libyamlscript'")
129
+ raise Exception("Unexpected response from 'libys'")
130
130
  data = resp.get('data')
131
131
 
132
132
  # Return the response object:
@@ -135,6 +135,6 @@ class YAMLScript():
135
135
  # YAMLScript instance destructor:
136
136
  def __del__(self):
137
137
  # Tear down the isolate thread to free resources:
138
- rc = libyamlscript.graal_tear_down_isolate(self.isolatethread)
138
+ rc = libys.graal_tear_down_isolate(self.isolatethread)
139
139
  if rc != 0:
140
140
  raise Exception("Failed to tear down isolate")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: yamlscript
3
- Version: 0.1.97
3
+ Version: 0.2.2
4
4
  Summary: Program in YAML — Code is Data
5
5
  Home-page: https://github.com/ingydotnet/yamlscript
6
6
  Author: Ingy döt Net
@@ -1,4 +1,4 @@
1
- version = '0.1.97'
1
+ version = '0.2.2'
2
2
 
3
3
  from setuptools import setup
4
4
  import pathlib
File without changes
File without changes
File without changes