{"id":20563613,"url":"https://github.com/gooofy/py-xsb","last_synced_at":"2026-03-01T02:33:28.081Z","repository":{"id":57458661,"uuid":"115678195","full_name":"gooofy/py-xsb","owner":"gooofy","description":"py-xsb is a Python - XSB bridge enabling querying XSB in your Python programs. It features a ctypes mapping of XSB's C-Interface as well as some higher level convenience wrappers.","archived":false,"fork":false,"pushed_at":"2018-12-04T22:48:54.000Z","size":47,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-29T09:06:06.240Z","etag":null,"topics":["prolog","python","wrapper-api","xsb"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gooofy.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-29T02:32:59.000Z","updated_at":"2022-05-27T01:04:22.000Z","dependencies_parsed_at":"2022-09-09T23:01:16.925Z","dependency_job_id":null,"html_url":"https://github.com/gooofy/py-xsb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gooofy/py-xsb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gooofy%2Fpy-xsb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gooofy%2Fpy-xsb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gooofy%2Fpy-xsb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gooofy%2Fpy-xsb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gooofy","download_url":"https://codeload.github.com/gooofy/py-xsb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gooofy%2Fpy-xsb/sbom","scorecard":{"id":441157,"data":{"date":"2025-08-11","repo":{"name":"github.com/gooofy/py-xsb","commit":"1601174fc0ee82b1f1b3db5a1124222711692835"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T05:36:34.644Z","repository_id":57458661,"created_at":"2025-08-19T05:36:34.644Z","updated_at":"2025-08-19T05:36:34.644Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29959124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prolog","python","wrapper-api","xsb"],"created_at":"2024-11-16T04:19:48.235Z","updated_at":"2026-03-01T02:33:28.060Z","avatar_url":"https://github.com/gooofy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"py-xsb\n------\n\nA Python - XSB bridge enabling querying XSB in your Python programs. It\nfeatures a ctypes mapping of XSB's C-Interface as well as some higher level\nconvenience wrappers.\n\nConstructive comments, patches and pull-requests are very welcome.\n\nExamples\n~~~~~~~~\n\nHigh Level Wrappers (demo_highlevel.py)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSetup XSB engine:\n\n[source,python]\n----\nfrom pyxsb import pyxsb_start_session, pyxsb_end_session, pyxsb_command, \\\n                  pyxsb_query, XSBFunctor, XSBVariable, xsb_to_json, json_to_xsb\n\npyxsb_start_session()\n# in case auto-detection fails, you can pass the XSB arch dir here like so:\n# pyxsb_start_session('/opt/xsb-3.8.0/config/x86_64-redhat-linux-gnu')\n#\n# to determine the location of the XSB arch dir on your machine, run this query in XSB:\n# xsb_configuration:xsb_configuration(config_dir,Dir).\n----\n\nrun a string XSB command:\n[source,python]\n----\npyxsb_command('consult(ft).')\n----\n\nrun a string query:\n[source,python]\n----\nfor row in pyxsb_query('label(X, L).'):\n    print u\"label of %s is %s\" % (row[0], row[1])\n----\n\nqueries and commands can also be constructed structurally:\n\n[source,python]\n----\nfor row in pyxsb_query(XSBFunctor('descend', [XSBVariable('X'), XSBVariable('Y')])):\n    print u\"decendant of %s is %s\" % (row[0], row[1])\n----\n\nthe wrappers (XSBFunctor, XSBVariable, XSBString, XSBAtom) are the same ones used to represent the query results. \nFor integers, floats and lists primitive python types are used:\n\n[source,python]\n----\nfor row in pyxsb_query(u'A = 1, B = 0.5, C = \"hello\", D = yes, E = foo(bar), F = [1.1,2.2], G = \\'günter\\'.'):\n    for i, r in enumerate(row):\n        print u\"#%d: %-10s (type: %-20s, class: %-20s)\" % (i, r, type(r), r.__class__)\n----\n\nthe wrappers can also converted to and from JSON:\n\n[source,python]\n----\n    js = xsb_to_json(row)\n    print \"json: %s\" % js\n\n    row2 = json_to_xsb(js)\n    print \"restored: %s\" % str(row2)\n----\n\nclose the session:\n[source,python]\n----\npyxsb_end_session()\n----\n\nXSB Low Level API (demo_lowlevel.py)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nFirst, import xsb and init the library:\n[source,python]\n----\nfrom pyxsb import pyxsb_start_session\npyxsb_start_session()\n\nfrom pyxsb import *\n----\n\nexecute an XSB command:\n\n[source,python]\n----\nc2p_functor(\"consult\", 1, reg_term(1))\nc2p_string(\"ctest\",p2p_arg(reg_term(1),1))\nif xsb_command():\n    raise Exception (\"Error consulting ctest\")\n----\n\nsame thing using the string interface:\n[source,python]\n----\nif xsb_command_string(\"consult(basics).\"):\n    raise Exception (\"Error (string) consulting basics.\")\n----\n\nrun a query:\n[source,python]\n----\n# Create the query p(300,X,Y) and send it.\nc2p_functor(\"p\",3,reg_term(1))\nc2p_int(300,p2p_arg(reg_term(1),1))\n\nrcode = xsb_query()\n\n# Print out answer and retrieve next one.\nwhile not rcode:\n    if not is_string(p2p_arg(reg_term(2),1)) and is_string(p2p_arg(reg_term(2),2)):\n        print \"2nd and 3rd subfields must be atoms\"\n    else:\n        print \"Answer: %d, %s(%s), %s(%s)\" % ( p2c_int(p2p_arg(reg_term(1),1)),\n                                               p2c_string(p2p_arg(reg_term(1),2)),\n                                               xsb_var_string(1),\n                                               p2c_string(p2p_arg(reg_term(1),3)),\n                                               xsb_var_string(2))\n    rcode = xsb_next()\n----\n\nrun a string query:\n[source,python]\n----\nxsb_make_vars(3)\nxsb_set_var_int(300,1)\nrcode = xsb_query_string(\"p(X,Y,Z).\")\n\n# Print out answer and retrieve next one.\nwhile not rcode:\n    if not is_string(p2p_arg(reg_term(2),2)) and is_string(p2p_arg(reg_term(2),3)):\n        print \"2nd and 3rd subfields must be atoms\"\n    else:\n        print \"Answer: %d, %s, %s\" % (xsb_var_int(1),\n                                      xsb_var_string(2),\n                                      xsb_var_string(3))\n    rcode = xsb_next()\n----\n\nclose the connection:\n[source,python]\n----\npyxsb_end_session()\n----\n\nInstallation Notes\n~~~~~~~~~~~~~~~~~~\n\n`py-xsb` needs the XSB dynamic library to work: First, follow the standard XSB build instructions:\n\n[source,bash]\n----\ntar xfvz XSB.tar.gz \ncd XSB/build\n./configure\n./makexsb \n----\n\nnow, in order to build `libxsb.so`, execute this command:\n\n[source,bash]\n----\n[guenter@dagobert build]$ ./makexsb dynmodule\n----\n\nLinks\n~~~~~\n\n* http://xsb.sourceforge.net/ [XSB]\n\nRequirements\n~~~~~~~~~~~~\n\n* Python 2.7 or Python 3.6 \n* libxsb.so shared library installed and in ld's path\n\nLicense\n~~~~~~~\n\nMy own code is Apache-2.0 licensed unless otherwise noted in the script's copyright\nheaders.\n\nAuthors\n~~~~~~~\n\n* Guenter Bartsch \u003cguenter@zamia.org\u003e\n* Many improvements and bugfixes by Michael Kifer, Annie Liu, David Warren (XSB team at Stony Brook University of New York)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooofy%2Fpy-xsb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooofy%2Fpy-xsb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooofy%2Fpy-xsb/lists"}