{"id":26084152,"url":"https://github.com/capeprivacy/pycape","last_synced_at":"2025-04-12T00:43:21.264Z","repository":{"id":58939483,"uuid":"501029085","full_name":"capeprivacy/pycape","owner":"capeprivacy","description":"The Cape Privacy Python SDK","archived":false,"fork":false,"pushed_at":"2023-10-05T13:42:09.000Z","size":301,"stargazers_count":23,"open_issues_count":0,"forks_count":3,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-25T20:32:54.684Z","etag":null,"topics":["confidential-computing","nitro","nitro-enclaves","python"],"latest_commit_sha":null,"homepage":"https://pydocs.capeprivacy.com","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/capeprivacy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-07T22:58:12.000Z","updated_at":"2023-11-28T22:00:27.000Z","dependencies_parsed_at":"2023-09-26T20:16:29.418Z","dependency_job_id":"e1c727de-d252-4462-930d-4e5c0fe81047","html_url":"https://github.com/capeprivacy/pycape","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capeprivacy%2Fpycape","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capeprivacy%2Fpycape/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capeprivacy%2Fpycape/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/capeprivacy%2Fpycape/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/capeprivacy","download_url":"https://codeload.github.com/capeprivacy/pycape/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248062329,"owners_count":21041543,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["confidential-computing","nitro","nitro-enclaves","python"],"created_at":"2025-03-09T04:50:36.999Z","updated_at":"2025-04-12T00:43:21.236Z","avatar_url":"https://github.com/capeprivacy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyCape\n\nThe Cape SDK for Python is a library that provides a simple way to interact with the Cape Privacy API.\n\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n## Installation\n\n### Prerequisites\n\n* Python 3.7+\n* [pip](https://pip.pypa.io/en/stable/installing/)\n* [Make](https://www.gnu.org/software/make/) (if installing from source)\n\nWe recommend that you use a [Python \"Virtual Environment\"](https://packaging.python.org/tutorials/installing-packages/#creating-virtual-environments) when installing `pycape`.\n\n### Install via pip\nYou can install the current release with:\n```sh\npip install pycape\n```\n\n### Install from source\n\nTo install the library from source and all of its dependencies, run:\n```sh\ngit clone https://github.com/capeprivacy/pycape.git\ncd pycape\nmake install-release\n```\n\n## Usage\n\nTo run a function, you need to first deploy a function and generate a [personal access token](https://docs.capeprivacy.com/reference/user-tokens). You can deploy a function with the [Cape CLI](https://github.com/capeprivacy/cli) by running `cape deploy`. `cape deploy` will return a function ID and a checksum. Non-CLI users can still consume the deployed function from the SDK as long as they have a copy of the deployer's personal access token. You can checkout the [examples repository](https://github.com/capeprivacy/pycape/blob/main/examples/) to see the process end to end.\n\n### `run`\n\nRun is used to invoke a function once with a single input. A connection to a Cape function is created, then terminated upon completion (no set up or tear down is required). If you wish to invoke the same function multiple times without terminating the connection between calls, please see [invoke](#invoke). By default, inputs and outputs are expected to be bytes.\n\n\u003e Note: You can optionally use [Serdio](https://github.com/capeprivacy/pycape/tree/main/serdio) to help with serialization and deserialization of inputs and outputs. To learn more, please check out [this example](https://pydocs.capeprivacy.com/walkthrough.html#mean-v2-running-functions-on-python-types-with-serdio).\n\nExample [run_echo.py](https://github.com/capeprivacy/pycape/blob/main/examples/run_echo.py):\n\n```python\nfrom pycape import Cape\n\ncape = Cape(url=\"https://app.capeprivacy.com\")\ntoken: str = \"eyJhbGci...\" # full token omitted for brevity\n\nf = cape.function(\"pycape-dev/echo\")\nt = cape.token(token)\nresult = client.run(f, t, b\"Hello!\")\nprint(result.decode())\n# Hello!\n```\n\n### `invoke`\n\nInvoke is used to run a function repeatedly with multiple inputs. The connection to your Cape function is not terminated between invocations. It gives you more control over the lifecycle, and can be more efficient. Prior to calling `invoke`, `connect` to your function and then `close` it when you are finished. You can also call `invoke` inside of a `Cape.function_context`, which will handle connecting and closing the connection for you. See the [docs](https://pydocs.capeprivacy.com/pycape.html#pycape.Cape.function_context) for a usage example.\n\nExample [invoke_echo.py](https://github.com/capeprivacy/pycape/blob/main/examples/invoke_echo.py):\n\n```python\nfrom pycape import Cape\n\ncape = Cape(url=\"https://app.capeprivacy.com\")\ntoken: str = \"eyJhbGci...\" # full token omitted for brevity\n\nf = cape.function(\"pycape-dev/echo\")\nt = cape.token(token)\n\ncape.connect(f, t)\nresult = cape.invoke(b\"Hello Alice!\")\nprint(result.decode())\n# Hello Alice!\nresult = cape.invoke(b\"Hello Bob!\")\nprint(result.decode())\n# Hello Bob!\nresult = cape.invoke(b\"Hello Carole!\")\nprint(result.decode())\n# Hello Carole!\n\ncape.close()\n```\n\nPlease note that there is a 60-second inactivity timeout on the enclave connection. You may need to monitor the connection status and reconnect if there is a significant wait between inputs.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\nRead more about how to contribute to the Cape SDK in [CONTRIBUTING](https://github.com/capeprivacy/pycape/tree/main/CONTRIBUTING.md).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapeprivacy%2Fpycape","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapeprivacy%2Fpycape","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapeprivacy%2Fpycape/lists"}