Skip to main content

CAAT: Commands as Arrow Types, a FFI that works across languages.

Project description

CAAT for Python

Commands as Arrow Types for Python

CAAT provides a way for programs to call each other regardless of the language used as if they were functions. This is the library for the Python language, it provides the required classes, functions, and variables for calling foreign code or for making your scripts callable from foreign code.

How it works

When you call a foreign command, an environment variable called CAAT_ARGS is set with a JSON string that represents the arguments passed into the function. They are also passed in via the command line arguments but this is for legacy reasons. The JSON string gets parsed into a format that the language can understand. At the same time, the caller opens up a socket at /tmp/caat_pid where pid is the pid of the caller process. This is set as the CAAT_SOCKET variable which is also passed into the callee. When the callee is done with what it is doing, it should call the function or macro that will write the return value back to the caller. This will also end the program.

Examples

Script 1

import caat

ff = caat.ForiegnFunction('python')

return_value = ff('other.py', 1, [1, 2, 3])

print(return_value)

Script 2

import caat

caat.return_caat(caat.argv[2])

Output

python script.py
[1, 2, 3]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

caat-0.2.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

caat-0.2.1-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file caat-0.2.1.tar.gz.

File metadata

  • Download URL: caat-0.2.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for caat-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4166efde0683dad35381ed32132d554528a25c140c069d1520a6bba1e73e4fc6
MD5 c02699c77a23e76aed7109a3dd9a2ca5
BLAKE2b-256 ea36788b7abb4a285285f64a08d1e1fc4ab33ea223a32de288b82599a181c817

See more details on using hashes here.

File details

Details for the file caat-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: caat-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for caat-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4e1fb8714065d587e26187f2397111eaf7fe8ad2e04dc54b8bd7f41e327020da
MD5 86aa9215e71927f521fbda3e0efab273
BLAKE2b-256 51cf9dc2494a40d2f2084a1a243b6606a9da1e849182c37a9b18865f12de942d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page