real-ladybug 0.0.1.dev1__cp311-cp311-win_amd64.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 real-ladybug might be problematic. Click here for more details.

Files changed (114) hide show
  1. real_ladybug/__init__.py +83 -0
  2. real_ladybug/_lbug.cp311-win_amd64.pyd +0 -0
  3. real_ladybug/_lbug.exp +0 -0
  4. real_ladybug/_lbug.lib +0 -0
  5. real_ladybug/async_connection.py +226 -0
  6. real_ladybug/connection.py +323 -0
  7. real_ladybug/constants.py +7 -0
  8. real_ladybug/database.py +307 -0
  9. real_ladybug/prepared_statement.py +51 -0
  10. real_ladybug/py.typed +0 -0
  11. real_ladybug/query_result.py +511 -0
  12. real_ladybug/torch_geometric_feature_store.py +185 -0
  13. real_ladybug/torch_geometric_graph_store.py +131 -0
  14. real_ladybug/torch_geometric_result_converter.py +282 -0
  15. real_ladybug/types.py +39 -0
  16. real_ladybug-0.0.1.dev1.dist-info/METADATA +88 -0
  17. real_ladybug-0.0.1.dev1.dist-info/RECORD +114 -0
  18. real_ladybug-0.0.1.dev1.dist-info/WHEEL +5 -0
  19. real_ladybug-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
  20. real_ladybug-0.0.1.dev1.dist-info/top_level.txt +3 -0
  21. real_ladybug-0.0.1.dev1.dist-info/zip-safe +1 -0
  22. real_ladybug-source/scripts/antlr4/hash.py +2 -0
  23. real_ladybug-source/scripts/antlr4/keywordhandler.py +47 -0
  24. real_ladybug-source/scripts/collect-extensions.py +68 -0
  25. real_ladybug-source/scripts/collect-single-file-header.py +126 -0
  26. real_ladybug-source/scripts/export-dbs.py +101 -0
  27. real_ladybug-source/scripts/export-import-test.py +345 -0
  28. real_ladybug-source/scripts/extension/purge-beta.py +34 -0
  29. real_ladybug-source/scripts/generate-cpp-docs/collect_files.py +122 -0
  30. real_ladybug-source/scripts/generate-tinysnb.py +34 -0
  31. real_ladybug-source/scripts/get-clangd-diagnostics.py +233 -0
  32. real_ladybug-source/scripts/migrate-lbug-db.py +308 -0
  33. real_ladybug-source/scripts/multiplatform-test-helper/collect-results.py +71 -0
  34. real_ladybug-source/scripts/multiplatform-test-helper/notify-discord.py +68 -0
  35. real_ladybug-source/scripts/pip-package/package_tar.py +90 -0
  36. real_ladybug-source/scripts/pip-package/setup.py +130 -0
  37. real_ladybug-source/scripts/run-clang-format.py +408 -0
  38. real_ladybug-source/scripts/setup-extension-repo.py +67 -0
  39. real_ladybug-source/scripts/test-simsimd-dispatch.py +45 -0
  40. real_ladybug-source/scripts/update-nightly-build-version.py +81 -0
  41. real_ladybug-source/third_party/brotli/scripts/dictionary/step-01-download-rfc.py +16 -0
  42. real_ladybug-source/third_party/brotli/scripts/dictionary/step-02-rfc-to-bin.py +34 -0
  43. real_ladybug-source/third_party/brotli/scripts/dictionary/step-03-validate-bin.py +35 -0
  44. real_ladybug-source/third_party/brotli/scripts/dictionary/step-04-generate-java-literals.py +85 -0
  45. real_ladybug-source/third_party/pybind11/tools/codespell_ignore_lines_from_errors.py +35 -0
  46. real_ladybug-source/third_party/pybind11/tools/libsize.py +36 -0
  47. real_ladybug-source/third_party/pybind11/tools/make_changelog.py +63 -0
  48. real_ladybug-source/tools/python_api/build/real_ladybug/__init__.py +83 -0
  49. real_ladybug-source/tools/python_api/build/real_ladybug/async_connection.py +226 -0
  50. real_ladybug-source/tools/python_api/build/real_ladybug/connection.py +323 -0
  51. real_ladybug-source/tools/python_api/build/real_ladybug/constants.py +7 -0
  52. real_ladybug-source/tools/python_api/build/real_ladybug/database.py +307 -0
  53. real_ladybug-source/tools/python_api/build/real_ladybug/prepared_statement.py +51 -0
  54. real_ladybug-source/tools/python_api/build/real_ladybug/py.typed +0 -0
  55. real_ladybug-source/tools/python_api/build/real_ladybug/query_result.py +511 -0
  56. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_feature_store.py +185 -0
  57. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_graph_store.py +131 -0
  58. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_result_converter.py +282 -0
  59. real_ladybug-source/tools/python_api/build/real_ladybug/types.py +39 -0
  60. real_ladybug-source/tools/python_api/src_py/__init__.py +83 -0
  61. real_ladybug-source/tools/python_api/src_py/async_connection.py +226 -0
  62. real_ladybug-source/tools/python_api/src_py/connection.py +323 -0
  63. real_ladybug-source/tools/python_api/src_py/constants.py +7 -0
  64. real_ladybug-source/tools/python_api/src_py/database.py +307 -0
  65. real_ladybug-source/tools/python_api/src_py/prepared_statement.py +51 -0
  66. real_ladybug-source/tools/python_api/src_py/py.typed +0 -0
  67. real_ladybug-source/tools/python_api/src_py/query_result.py +511 -0
  68. real_ladybug-source/tools/python_api/src_py/torch_geometric_feature_store.py +185 -0
  69. real_ladybug-source/tools/python_api/src_py/torch_geometric_graph_store.py +131 -0
  70. real_ladybug-source/tools/python_api/src_py/torch_geometric_result_converter.py +282 -0
  71. real_ladybug-source/tools/python_api/src_py/types.py +39 -0
  72. real_ladybug-source/tools/python_api/test/conftest.py +230 -0
  73. real_ladybug-source/tools/python_api/test/disabled_test_extension.py +73 -0
  74. real_ladybug-source/tools/python_api/test/ground_truth.py +430 -0
  75. real_ladybug-source/tools/python_api/test/test_arrow.py +694 -0
  76. real_ladybug-source/tools/python_api/test/test_async_connection.py +159 -0
  77. real_ladybug-source/tools/python_api/test/test_blob_parameter.py +145 -0
  78. real_ladybug-source/tools/python_api/test/test_connection.py +49 -0
  79. real_ladybug-source/tools/python_api/test/test_database.py +234 -0
  80. real_ladybug-source/tools/python_api/test/test_datatype.py +372 -0
  81. real_ladybug-source/tools/python_api/test/test_df.py +564 -0
  82. real_ladybug-source/tools/python_api/test/test_dict.py +112 -0
  83. real_ladybug-source/tools/python_api/test/test_exception.py +54 -0
  84. real_ladybug-source/tools/python_api/test/test_fsm.py +227 -0
  85. real_ladybug-source/tools/python_api/test/test_get_header.py +49 -0
  86. real_ladybug-source/tools/python_api/test/test_helper.py +8 -0
  87. real_ladybug-source/tools/python_api/test/test_issue.py +147 -0
  88. real_ladybug-source/tools/python_api/test/test_iteration.py +96 -0
  89. real_ladybug-source/tools/python_api/test/test_networkx.py +437 -0
  90. real_ladybug-source/tools/python_api/test/test_parameter.py +340 -0
  91. real_ladybug-source/tools/python_api/test/test_prepared_statement.py +117 -0
  92. real_ladybug-source/tools/python_api/test/test_query_result.py +54 -0
  93. real_ladybug-source/tools/python_api/test/test_query_result_close.py +44 -0
  94. real_ladybug-source/tools/python_api/test/test_scan_pandas.py +676 -0
  95. real_ladybug-source/tools/python_api/test/test_scan_pandas_pyarrow.py +714 -0
  96. real_ladybug-source/tools/python_api/test/test_scan_polars.py +165 -0
  97. real_ladybug-source/tools/python_api/test/test_scan_pyarrow.py +167 -0
  98. real_ladybug-source/tools/python_api/test/test_timeout.py +11 -0
  99. real_ladybug-source/tools/python_api/test/test_torch_geometric.py +640 -0
  100. real_ladybug-source/tools/python_api/test/test_torch_geometric_remote_backend.py +111 -0
  101. real_ladybug-source/tools/python_api/test/test_udf.py +207 -0
  102. real_ladybug-source/tools/python_api/test/test_version.py +6 -0
  103. real_ladybug-source/tools/python_api/test/test_wal.py +80 -0
  104. real_ladybug-source/tools/python_api/test/type_aliases.py +10 -0
  105. real_ladybug-source/tools/rust_api/update_version.py +47 -0
  106. real_ladybug-source/tools/shell/test/conftest.py +218 -0
  107. real_ladybug-source/tools/shell/test/test_helper.py +60 -0
  108. real_ladybug-source/tools/shell/test/test_shell_basics.py +325 -0
  109. real_ladybug-source/tools/shell/test/test_shell_commands.py +656 -0
  110. real_ladybug-source/tools/shell/test/test_shell_control_edit.py +438 -0
  111. real_ladybug-source/tools/shell/test/test_shell_control_search.py +468 -0
  112. real_ladybug-source/tools/shell/test/test_shell_esc_edit.py +232 -0
  113. real_ladybug-source/tools/shell/test/test_shell_esc_search.py +162 -0
  114. real_ladybug-source/tools/shell/test/test_shell_flags.py +645 -0
@@ -0,0 +1,45 @@
1
+ import gdb
2
+ import subprocess
3
+
4
+
5
+ def get_machine_architecture():
6
+ output = subprocess.check_output(["cat", "/proc/cpuinfo"])
7
+ flags_str = ""
8
+ for line in output.decode("utf-8").split("\n"):
9
+ line = line.strip()
10
+ if line.startswith("flags"):
11
+ flags_str = line
12
+ break
13
+ assert len(line) > 0
14
+
15
+ # Uses the same way as _simsimd_capabilities_x86() in simsimd.h to detect supported features
16
+ # The only simsimd functions we use in the vector index are cos/l2/l2_sq/dot which only branch for the targets 'skylake', 'haswell', and 'serial' so we only test for those
17
+ if "avx512f" in flags_str:
18
+ return "skylake"
19
+ elif "avx2" in flags_str and "f16c" in flags_str and "fma" in flags_str:
20
+ return "haswell"
21
+ else:
22
+ return "serial"
23
+
24
+
25
+ bp = gdb.Breakpoint(f"simsimd_l2_f32_{get_machine_architecture()}")
26
+
27
+ gdb.execute("run < scripts/simd-dispatch-test.cypher")
28
+
29
+ try:
30
+ gdb.execute("continue")
31
+ # we only care if the breakpoint is hit at all
32
+ # disable it now to prevent the test from needing to execute 'continue' many times to reach completion
33
+ bp.enabled = False
34
+ except gdb.error:
35
+ # the program has terminated
36
+ pass
37
+
38
+ # Check if the breakpoint was hit
39
+ if bp.hit_count == 0:
40
+ print(
41
+ f"Error: did not hit the expected simsimd function for machine architecture '{get_machine_architecture()}'"
42
+ )
43
+ gdb.execute("quit 1")
44
+
45
+ gdb.execute("quit")
@@ -0,0 +1,81 @@
1
+ PYPI_URL = "https://pypi.org/pypi/real_ladybug/json"
2
+ CMAKE_KEYWORD = "project(Lbug VERSION "
3
+ CMAKE_SUFFIX = " LANGUAGES CXX C)\n"
4
+ EXTENSION_KEYWORD = 'add_definitions(-DLBUG_EXTENSION_VERSION="'
5
+ EXTENSION_SUFFIX = '")\n'
6
+ EXTENSION_DEV_VERSION = "dev"
7
+
8
+ import urllib.request
9
+ import urllib.error
10
+ import json
11
+ import os
12
+ import sys
13
+
14
+ def main():
15
+ try:
16
+ from packaging.version import Version
17
+ except ImportError:
18
+ from distutils.version import LooseVersion as Version
19
+ try:
20
+ with urllib.request.urlopen(PYPI_URL) as url:
21
+ data = json.loads(url.read().decode())
22
+ except urllib.error.HTTPError as e:
23
+ if e.code == 404:
24
+ data = {"releases": {}}
25
+ else:
26
+ raise
27
+ releases = data["releases"]
28
+ versions = list(releases.keys())
29
+ versions.sort(key=Version)
30
+ dev_versions = [v for v in versions if "dev" in v]
31
+ stable_versions = [v for v in versions if not "dev" in v]
32
+ latest_dev_version = dev_versions[-1] if len(dev_versions) > 0 else None
33
+ latest_stable_version = stable_versions[-1] if len(stable_versions) > 0 else None
34
+ print("Latest dev version: %s." % str(latest_dev_version))
35
+ print("Latest stable version: %s." % str(latest_stable_version))
36
+ if latest_dev_version is None and latest_stable_version is None:
37
+ print("No versions found. Defaulting to 0.0.1.dev1.")
38
+ dev_version = "0.0.1.dev1"
39
+ elif latest_dev_version is None or Version(latest_dev_version) < Version(latest_stable_version):
40
+ print("The latest stable version is newer than dev version or no dev version exists. Bumping dev version from stable version.")
41
+ latest_stable_version_split = latest_stable_version.split(".")
42
+ latest_stable_version_split[-1] = str(int(latest_stable_version_split[-1]) + 1)
43
+ latest_stable_version_split.append("dev1")
44
+ dev_version = ".".join(latest_stable_version_split)
45
+ else:
46
+ print("The latest dev version is newer than stable version. Bumping dev version from dev version.")
47
+ latest_dev_version_split = latest_dev_version.split(".")
48
+ latest_dev_version_split[-1] = "dev" + str(int(latest_dev_version_split[-1][3:]) + 1)
49
+ dev_version = ".".join(latest_dev_version_split)
50
+ print("New Python dev version: %s." % dev_version)
51
+ cmake_version = dev_version.replace("dev", "")
52
+ print("New CMake version: %s." % cmake_version)
53
+ cmake_lists_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "CMakeLists.txt"))
54
+ print("Updating %s..." % cmake_lists_path)
55
+ with open(cmake_lists_path, "r") as cmake_lists_file:
56
+ cmake_lists = cmake_lists_file.readlines()
57
+ counter = 2
58
+ for i, line in enumerate(cmake_lists):
59
+ if CMAKE_KEYWORD in line:
60
+ cmake_lists[i] = CMAKE_KEYWORD + cmake_version + CMAKE_SUFFIX
61
+ counter -= 1
62
+ if EXTENSION_KEYWORD in line:
63
+ cmake_lists[i] = EXTENSION_KEYWORD + EXTENSION_DEV_VERSION + EXTENSION_SUFFIX
64
+ counter -= 1
65
+ if counter == 0:
66
+ break
67
+ with open(cmake_lists_path, "w") as cmake_lists_file:
68
+ cmake_lists_file.writelines(cmake_lists)
69
+ print("Committing changes...")
70
+ sys.stdout.flush()
71
+ os.system("git config user.email ci@lbugdb.com")
72
+ os.system("git config user.name \"Lbug CI\"")
73
+ os.system("git add %s" % cmake_lists_path)
74
+ os.system("git commit -m \"Update CMake version to %s and change extension version to dev.\"" % cmake_version)
75
+ sys.stdout.flush()
76
+ sys.stderr.flush()
77
+ print("All done!")
78
+ sys.stdout.flush()
79
+
80
+ if __name__ == "__main__":
81
+ main()
@@ -0,0 +1,16 @@
1
+ # Step 01 - download RFC7932.
2
+ #
3
+ # RFC is the ultimate source for brotli format and constants, including
4
+ # static dictionary.
5
+
6
+ import urllib2
7
+
8
+ response = urllib2.urlopen("https://tools.ietf.org/rfc/rfc7932.txt")
9
+
10
+ text = response.read()
11
+ path = "rfc7932.txt"
12
+
13
+ with open(path, "w") as rfc:
14
+ rfc.write(text)
15
+
16
+ print("Downloaded and saved " + str(len(text)) + " bytes to " + path)
@@ -0,0 +1,34 @@
1
+ # Step 02 - parse RFC.
2
+ #
3
+ # Static dictionary is described in "Appendix A" section in a hexadecimal form.
4
+ # This tool locates dictionary data in RFC and converts it to raw binary format.
5
+
6
+ import re
7
+
8
+ rfc_path = "rfc7932.txt"
9
+
10
+ with open(rfc_path, "r") as rfc:
11
+ lines = rfc.readlines()
12
+
13
+ re_data_line = re.compile("^ [0-9a-f]{64}$")
14
+
15
+ appendix_a_found = False
16
+ dictionary = []
17
+ for line in lines:
18
+ if appendix_a_found:
19
+ if re_data_line.match(line) is not None:
20
+ data = line.strip()
21
+ for i in range(32):
22
+ dictionary.append(int(data[2 * i:2 * i + 2], 16))
23
+ if len(dictionary) == 122784:
24
+ break
25
+ else:
26
+ if line.startswith("Appendix A."):
27
+ appendix_a_found = True
28
+
29
+ bin_path = "dictionary.bin"
30
+
31
+ with open(bin_path, "wb") as output:
32
+ output.write(bytearray(dictionary))
33
+
34
+ print("Parsed and saved " + str(len(dictionary)) + " bytes to " + bin_path)
@@ -0,0 +1,35 @@
1
+ # Step 03 - validate raw dictionary file.
2
+ #
3
+ # CRC32, MD5, SHA1 and SHA256 checksums for raw binary dictionary are checked.
4
+
5
+ import hashlib
6
+ import zlib
7
+
8
+ bin_path = "dictionary.bin"
9
+
10
+ with open(bin_path, "rb") as raw:
11
+ data = raw.read()
12
+
13
+
14
+ def check_digest(name, expected, actual):
15
+ if expected == actual:
16
+ print("[OK] " + name)
17
+ else:
18
+ print("[ERROR] " + name + " | " + expected + " != " + actual)
19
+
20
+
21
+ check_digest(
22
+ "CRC32", # This is the only checksum provided in RFC.
23
+ "0x5136cb04",
24
+ hex(zlib.crc32(data)))
25
+
26
+ check_digest("MD5", "96cecd2ee7a666d5aa3627d74735b32a",
27
+ hashlib.md5(data).hexdigest())
28
+
29
+ check_digest("SHA1", "72b41051cb61a9281ba3c4414c289da50d9a7640",
30
+ hashlib.sha1(data).hexdigest())
31
+
32
+ check_digest(
33
+ "SHA256",
34
+ "20e42eb1b511c21806d4d227d07e5dd06877d8ce7b3a817f378f313653f35c70",
35
+ hashlib.sha256(data).hexdigest())
@@ -0,0 +1,85 @@
1
+ # Step 04 - generate Java literals.
2
+ #
3
+ # Java byte-code has severe restrictions. There is no such thing as
4
+ # "array literal" - those are implemented as series of data[x] = y;
5
+ # as a consequence N-byte array will use 7N bytes in class, plus N bytes
6
+ # in instantiated variable. Also no literal could be longer than 64KiB.
7
+ #
8
+ # To keep dictionary data compact both in source code and in compiled format
9
+ # we use the following tricks:
10
+ # * use String as a data container
11
+ # * store only lowest 7 bits; i.e. all characters fit ASCII table; this allows
12
+ # efficient conversion to byte array; also ASCII characters use only 1 byte
13
+ #. of memory (UTF-8 encoding)
14
+ # * RLE-compress sequence of 8-th bits
15
+ #
16
+ # This script generates literals used in Java code.
17
+
18
+ try:
19
+ unichr # Python 2
20
+ except NameError:
21
+ unichr = chr # Python 3
22
+
23
+ bin_path = "dictionary.bin"
24
+
25
+ with open(bin_path, "rb") as raw:
26
+ data = raw.read()
27
+
28
+ low = []
29
+ hi = []
30
+ is_skip = True
31
+ skip_flip_offset = 36
32
+ cntr = skip_flip_offset
33
+ for b in data:
34
+ value = ord(b)
35
+ low.append(chr(value & 0x7F))
36
+ if is_skip:
37
+ if value < 0x80:
38
+ cntr += 1
39
+ else:
40
+ is_skip = False
41
+ hi.append(unichr(cntr))
42
+ cntr = skip_flip_offset + 1
43
+ else:
44
+ if value >= 0x80:
45
+ cntr += 1
46
+ else:
47
+ is_skip = True
48
+ hi.append(unichr(cntr))
49
+ cntr = skip_flip_offset + 1
50
+ hi.append(unichr(cntr))
51
+
52
+ low0 = low[0:len(low) // 2]
53
+ low1 = low[len(low) // 2:len(low)]
54
+
55
+
56
+ def escape(chars):
57
+ result = []
58
+ for c in chars:
59
+ if "\r" == c:
60
+ result.append("\\r")
61
+ elif "\n" == c:
62
+ result.append("\\n")
63
+ elif "\t" == c:
64
+ result.append("\\t")
65
+ elif "\"" == c:
66
+ result.append("\\\"")
67
+ elif "\\" == c:
68
+ result.append("\\\\")
69
+ elif ord(c) < 32 or ord(c) >= 127:
70
+ result.append("\\u%04X" % ord(c))
71
+ else:
72
+ result.append(c)
73
+ return result
74
+
75
+
76
+ source_code = [
77
+ " private static final String DATA0 = \"", "".join(escape(low0)), "\";\n",
78
+ " private static final String DATA1 = \"", "".join(escape(low1)), "\";\n",
79
+ " private static final String SKIP_FLIP = \"", "".join(escape(hi)), "\";\n"
80
+ ]
81
+
82
+ src_path = "DictionaryData.inc.java"
83
+
84
+ with open(src_path, "w") as source:
85
+ source.write("".join(source_code))
@@ -0,0 +1,35 @@
1
+ """Simple script for rebuilding .codespell-ignore-lines
2
+
3
+ Usage:
4
+
5
+ cat < /dev/null > .codespell-ignore-lines
6
+ pre-commit run --all-files codespell >& /tmp/codespell_errors.txt
7
+ python3 tools/codespell_ignore_lines_from_errors.py /tmp/codespell_errors.txt > .codespell-ignore-lines
8
+
9
+ git diff to review changes, then commit, push.
10
+ """
11
+
12
+ import sys
13
+ from typing import List
14
+
15
+
16
+ def run(args: List[str]) -> None:
17
+ assert len(args) == 1, "codespell_errors.txt"
18
+ cache = {}
19
+ done = set()
20
+ for line in sorted(open(args[0]).read().splitlines()):
21
+ i = line.find(" ==> ")
22
+ if i > 0:
23
+ flds = line[:i].split(":")
24
+ if len(flds) >= 2:
25
+ filename, line_num = flds[:2]
26
+ if filename not in cache:
27
+ cache[filename] = open(filename).read().splitlines()
28
+ supp = cache[filename][int(line_num) - 1]
29
+ if supp not in done:
30
+ print(supp)
31
+ done.add(supp)
32
+
33
+
34
+ if __name__ == "__main__":
35
+ run(args=sys.argv[1:])
@@ -0,0 +1,36 @@
1
+ import os
2
+ import sys
3
+
4
+ # Internal build script for generating debugging test .so size.
5
+ # Usage:
6
+ # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the
7
+ # size in it, then overwrites save.txt with the new size for future runs.
8
+
9
+ if len(sys.argv) != 3:
10
+ sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt")
11
+
12
+ lib = sys.argv[1]
13
+ save = sys.argv[2]
14
+
15
+ if not os.path.exists(lib):
16
+ sys.exit(f"Error: requested file ({lib}) does not exist")
17
+
18
+ libsize = os.path.getsize(lib)
19
+
20
+ print("------", os.path.basename(lib), "file size:", libsize, end="")
21
+
22
+ if os.path.exists(save):
23
+ with open(save) as sf:
24
+ oldsize = int(sf.readline())
25
+
26
+ if oldsize > 0:
27
+ change = libsize - oldsize
28
+ if change == 0:
29
+ print(" (no change)")
30
+ else:
31
+ print(f" (change of {change:+} bytes = {change / oldsize:+.2%})")
32
+ else:
33
+ print()
34
+
35
+ with open(save, "w") as sf:
36
+ sf.write(str(libsize))
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import re
4
+
5
+ import ghapi.all
6
+ from rich import print
7
+ from rich.syntax import Syntax
8
+
9
+ ENTRY = re.compile(
10
+ r"""
11
+ Suggested \s changelog \s entry:
12
+ .*
13
+ ```rst
14
+ \s*
15
+ (.*?)
16
+ \s*
17
+ ```
18
+ """,
19
+ re.DOTALL | re.VERBOSE,
20
+ )
21
+
22
+ print()
23
+
24
+
25
+ api = ghapi.all.GhApi(owner="pybind", repo="pybind11")
26
+
27
+ issues_pages = ghapi.page.paged(
28
+ api.issues.list_for_repo, labels="needs changelog", state="closed"
29
+ )
30
+ issues = (issue for page in issues_pages for issue in page)
31
+ missing = []
32
+
33
+ for issue in issues:
34
+ changelog = ENTRY.findall(issue.body)
35
+ if changelog:
36
+ (msg,) = changelog
37
+ if not msg.startswith("* "):
38
+ msg = "* " + msg
39
+ if not msg.endswith("."):
40
+ msg += "."
41
+
42
+ msg += f"\n `#{issue.number} <{issue.html_url}>`_"
43
+
44
+ print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
45
+ print()
46
+
47
+ else:
48
+ missing.append(issue)
49
+
50
+ if missing:
51
+ print()
52
+ print("[blue]" + "-" * 30)
53
+ print()
54
+
55
+ for issue in missing:
56
+ print(f"[red bold]Missing:[/red bold][red] {issue.title}")
57
+ print(f"[red] {issue.html_url}\n")
58
+
59
+ print("[bold]Template:\n")
60
+ msg = "## Suggested changelog entry:\n\n```rst\n\n```"
61
+ print(Syntax(msg, "md", theme="ansi_light"))
62
+
63
+ print()
@@ -0,0 +1,83 @@
1
+ """
2
+ # Lbug Python API bindings.
3
+
4
+ This package provides a Python API for Lbug graph database management system.
5
+
6
+ To install the package, run:
7
+ ```
8
+ python3 -m pip install real_ladybug
9
+ ```
10
+
11
+ Example usage:
12
+ ```python
13
+ import real_ladybug as lb
14
+
15
+ db = lb.Database("./test")
16
+ conn = lb.Connection(db)
17
+
18
+ # Define the schema
19
+ conn.execute("CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))")
20
+ conn.execute("CREATE NODE TABLE City(name STRING, population INT64, PRIMARY KEY (name))")
21
+ conn.execute("CREATE REL TABLE Follows(FROM User TO User, since INT64)")
22
+ conn.execute("CREATE REL TABLE LivesIn(FROM User TO City)")
23
+
24
+ # Load some data
25
+ conn.execute('COPY User FROM "user.csv"')
26
+ conn.execute('COPY City FROM "city.csv"')
27
+ conn.execute('COPY Follows FROM "follows.csv"')
28
+ conn.execute('COPY LivesIn FROM "lives-in.csv"')
29
+
30
+ # Query the data
31
+ results = conn.execute("MATCH (u:User) RETURN u.name, u.age;")
32
+ while results.has_next():
33
+ print(results.get_next())
34
+ ```
35
+
36
+ The dataset used in this example can be found [here](https://github.com/LadybugDB/ladybug/tree/master/dataset/demo-db/csv).
37
+
38
+ """
39
+
40
+ from __future__ import annotations
41
+
42
+ import os
43
+ import sys
44
+
45
+ # Set RTLD_GLOBAL and RTLD_LAZY flags on Linux to fix the issue with loading
46
+ # extensions
47
+ if sys.platform == "linux":
48
+ original_dlopen_flags = sys.getdlopenflags()
49
+ sys.setdlopenflags(os.RTLD_GLOBAL | os.RTLD_LAZY)
50
+
51
+ from .async_connection import AsyncConnection
52
+ from .connection import Connection
53
+ from .database import Database
54
+ from .prepared_statement import PreparedStatement
55
+ from .query_result import QueryResult
56
+ from .types import Type
57
+
58
+
59
+ def __getattr__(name: str) -> str | int:
60
+ if name in ("version", "__version__"):
61
+ return Database.get_version()
62
+ elif name == "storage_version":
63
+ return Database.get_storage_version()
64
+ else:
65
+ msg = f"module {__name__!r} has no attribute {name!r}"
66
+ raise AttributeError(msg)
67
+
68
+
69
+ # Restore the original dlopen flags
70
+ if sys.platform == "linux":
71
+ sys.setdlopenflags(original_dlopen_flags)
72
+
73
+ __all__ = [
74
+ "AsyncConnection",
75
+ "Connection",
76
+ "Database",
77
+ "PreparedStatement",
78
+ "QueryResult",
79
+ "Type",
80
+ "__version__", # noqa: F822
81
+ "storage_version", # noqa: F822
82
+ "version", # noqa: F822
83
+ ]