{"id":24369947,"url":"https://github.com/unikraft/lib-python3","last_synced_at":"2025-08-23T06:10:23.832Z","repository":{"id":35714478,"uuid":"215787781","full_name":"unikraft/lib-python3","owner":"unikraft","description":"Unikraft port of Python 3","archived":false,"fork":false,"pushed_at":"2024-12-20T22:11:28.000Z","size":64,"stargazers_count":4,"open_issues_count":0,"forks_count":7,"subscribers_count":9,"default_branch":"staging","last_synced_at":"2025-04-10T17:41:50.311Z","etag":null,"topics":["library","python3","unikraft"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unikraft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-17T12:32:35.000Z","updated_at":"2024-12-20T10:14:16.000Z","dependencies_parsed_at":"2024-12-20T11:20:19.641Z","dependency_job_id":"60b1ae56-0780-4c1e-9df7-1ce03f365f48","html_url":"https://github.com/unikraft/lib-python3","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/unikraft/lib-python3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unikraft%2Flib-python3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unikraft%2Flib-python3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unikraft%2Flib-python3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unikraft%2Flib-python3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unikraft","download_url":"https://codeload.github.com/unikraft/lib-python3/tar.gz/refs/heads/staging","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unikraft%2Flib-python3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271745695,"owners_count":24813516,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"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":["library","python3","unikraft"],"created_at":"2025-01-19T04:11:07.428Z","updated_at":"2025-08-23T06:10:23.778Z","avatar_url":"https://github.com/unikraft.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python3 for Unikraft\nThis is the port of python3 for Unikraft as external library.\n\n## Build\nPython 3 interpreter depends on the following libraries, that need to\nbe added to `Makefile` in this order:\n\n* `pthreads`, e.g. `pthread-embedded`\n* `libc`, e.g. `newlib`\n* network stack, e.g. `lwip`\n* (optional) a SIMD library, e.g. `intel-intrinsics`, for optimized\n  BLAKE hashing \n* optional extensions: `openssl`, `zlib`, `libuuid`, Expat XML parser,\n  `_ctypes` and decimal operations with `libmpdec`.\n\n## Root filesystem\n### Creating the filesystem\nPython 3 interpreter needs a filesystem which should contain its\nstandard library. Therefore, the filesystem needs to be created before\nrunning the VM.  You can do this by running the following command:\n\n```bash\nmake python-rootfs path=\u003csome directory\u003e\n```\n\nIt will create the filesystem in the directory you choose, by first\ncreating a virtual Python environment. After that it will install the\nPython standard library into it. For this second step, the original\ncode needs to be configured and build with paths relative to the\nprovided root directory. These two steps are executed transparently,\nall you have to do is just running the above `make` command.\n\n### Using the filesystem\nMounting the filesystem is a transparent operation. All you have to do\nis to provide the right Qemu parameters in order for Unikraft to mount\nthe filesystem.  We will use the 9pfs support for filesystems and for\nthis you will need to use the following parameters:\n\n```bash\n-fsdev local,id=myid,path=\u003csome directory\u003e,security_model=none \\\n-device virtio-9p-pci,fsdev=myid,mount_tag=test,disable-modern=on,disable-legacy=off\n```\n\nYou should also use `vfs.rootdev=test` to specify the 9pfs mounting\ntag to Unikraft. To enable 9pfs, you'll need to select the following\nmenu options, all under \"Library Configuration\"\n\n* uk9p: 9p client\n\n* vfscore: VFS Core Interface ---\u003e vfscore: Configuration\n                              ---\u003e Automatically mount a root filesysytem \n\t  \t\t\t\t\t\t  ---\u003e Default root filesystem \n\t \t\t\t\t\t\t  ---\u003e 9PFS\n\n* devfs: devfs file system  ---\u003e Mount /dev during boot\n\n* uk library parameter\n\n## Running modes\nThe Next step is to pick a running mode. We currently support 3 running\nmodes:\n\n1. **Python shell**. No extra parameters are needed.\n     * You can use the `main()` function provided by the library via\n     `menuconfig`:\n\t \n\t Library Configuration  ---\u003e Python 3  ---\u003e Provide main function\n\t \n\t Otherwise you will have to provide your own `main()` function\n     which should call `_Py_UnixMain()`.\n\t \n2. **Python script**. You can use any file available in the root\n   filesystem.  You should use Qemu's `-append` option to pass\n   parameter to Python interpreter, e.g. `-append \"vfs.rootdev=test --\n   \u003csome file in rootfs\u003e\"`.  Please notice that we are using `test`\n   for the 9pfs mounting tag. For brevity we will skip setting the\n   mounting tag in the next examples.\n   \n3. **Python unit testing (developers only)**. With this mode you can\n   check what functionality is completely supported by the Python 3\n   port. Please be aware that this mode is unstable and some of the\n   tests may block. You can work around that by using the options\n   provided by the unit testing framework. The unit testing mode\n   itself supports several submodes:\n   \n     * **Running all the tests**. You have to use the following Qemu\n       parameters: `-append \"-- -B -c 'from test import autotest'\"`\n\t \n     * Check the supported options of the unit testing framework,\n       e.g. `-append \"-- -B -c 'from test import autotest' -h\"`.\n\t \n       * For example, you can run a single unit test with verbosity\n         using `-append \"-- -B -c 'from test import autotest' -v\n         test_dict\"`.\n\t   \n       * Or you can run a set of tests listed in a file using `-append\n         \"-- -B -c 'from test import autotest' -f \u003cfile in rootfs\u003e\"`.\n\t   \n\n### Memory usage\nSome of the unit tests may require a lot of memory to run; for this\nreason please allow for at least 1G of memory for unit testing (e.g.,\n`-m 1G` in Qemu).\n\n## Adding modules\nFor installing Python modules which have only Python code, you can use\nthe `pip` utility installed in the Python virtual environment you\ncreated using the steps above.\n\n```bash\n\u003cmy-python-rootfs\u003e $ . bin/activate\n\u003cmy-python-rootfs\u003e $ pip install mymodule\n```\n\nHowever, some of the Python modules need some native support,\ne.g. some C code which should be compiled and registered at run\ntime. You need to add the source files of the native library to\n`Makefile.uk.` for compiling them. For runtime registration, you need\nto add a new entry in the `modules_config.c` file.\n\nNote that this port already supports a few such modules: `openssl`,\n`zlib` and `libuuid` as of this writing. To enable them select them in\nthe menu under:\n\nLibrary Configuration ---\u003e Python 3 ---\u003e Extensions\n\n## Further information\nPlease refer to the `README.md` as well as the documentation in the\n`doc/` subdirectory of the main unikraft repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funikraft%2Flib-python3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funikraft%2Flib-python3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funikraft%2Flib-python3/lists"}