{"id":37083995,"url":"https://github.com/mrh1997/pytcc","last_synced_at":"2026-01-14T10:15:32.225Z","repository":{"id":61188941,"uuid":"211406556","full_name":"mrh1997/pytcc","owner":"mrh1997","description":"Python Binding for TCC (TinyCC)","archived":false,"fork":false,"pushed_at":"2023-01-24T21:10:28.000Z","size":273,"stargazers_count":11,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-31T01:37:56.819Z","etag":null,"topics":["python","tcc","tinycc"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrh1997.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-27T21:47:20.000Z","updated_at":"2024-01-31T00:14:37.000Z","dependencies_parsed_at":"2023-02-14T01:32:00.435Z","dependency_job_id":null,"html_url":"https://github.com/mrh1997/pytcc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/mrh1997/pytcc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrh1997%2Fpytcc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrh1997%2Fpytcc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrh1997%2Fpytcc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrh1997%2Fpytcc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrh1997","download_url":"https://codeload.github.com/mrh1997/pytcc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrh1997%2Fpytcc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["python","tcc","tinycc"],"created_at":"2026-01-14T10:15:31.418Z","updated_at":"2026-01-14T10:15:32.218Z","avatar_url":"https://github.com/mrh1997.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"`pytcc` is a self-contained python extension for compiling C code (utilizing [TCC](https://en.wikipedia.org/wiki/Tiny_C_Compiler)).\n\nWhat this extensions sets apart from other TCC extensions is, that no separate\nTCC installation is required. By simply adding `pytcc` to your\n`requirements.txt` your environment will be setup.\n\nTCC is a full-fledged, blazing fast (up to 9 times faster compilation time than \nGCC) and extraordinary small (about 300 kb) C99 compiler originally written by \nFabrice Bellard and now actively maintained by the community.\n\nThis extensions provides a pythonic interface of the API\nof TCC's tcclib. This library allows not only generating executables and \nlibraries, but also running the generated code in the addressspace\nof your python process without the need of creating a file on disk.\n\n# Installation\n\nThe easiest way to install the tool is via pip:\n\n```\npip install --upgrade pip      # only needed if current pip version \u003c 19.3\npip install pytcc\n```\n\nAlternatively you could build it on your own from source\n(see chapter \"Howto build\").\n\n\n# First Steps\n\nTo compile a bunch of C files to ank executable and run it (with include/library\nsearch path and macros specified):\n```python\nimport pytcc\nimport subprocess\ntcc_setup = pytcc.TCC(include_dirs=['incl'], library_dirs=['libs'], MACRO=\"value\")\nexe_binary = tcc_setup.build_to_exe('exename', 'src1.c', 'src2.c')\nsubprocess.run([str(exe_binary.path)])\n```\n\nIf you want to build dynamic library instead of an executable and you want\nto create it from in-memory source code it would look like:\n```python\nimport pytcc\nimport ctypes\ntcc_setup = pytcc.TCC()\nlib_binary = tcc_setup.build_to_lib('libname', pytcc.CCode('''\n__attribute__((dllexport)) int func(int p) { \n    return p+1; \n}\n'''))\nlib = ctypes.CDLL(str(lib_binary.path))\nprint(lib.func(123))\n```\n\nAlternatively you could build a library in memory and retrieve its symbols:\n```python\nimport pytcc\nimport ctypes\nfunc_t = ctypes.CFUNCTYPE(None, ctypes.c_int)\ntcc_setup = pytcc.TCC()\nmem_binary = tcc_setup.build_to_mem('src1.c', 'src2.c')\nvar_obj = ctypes.c_int.from_address(mem_binary['var'])\nfunc_obj = func_t(mem_binary['func'])\nfunc_obj(var_obj)\n```\n\n\n# Current status\n\n![CI Badge](https://github.com/mrh1997/pytcc/workflows/Build%20pytcc%20and%20run%20unittests/badge.svg \"Status of CI run of head\")\n\n* Provides tcclib API as pythonic interface\n* Supports all major platforms:\n   * Windows x86 and x64\n   * macOS x64 (does not support executable/library generation yet and cannot find standard headers by default)\n   * linux x64\n* Provide ready to use binary wheels for all supported platforms\n\n## Roadmap\n* Make it work on macOS without manually referring to the  headerfiles of XCode by adding the darwin headerfiles to the TCC package\n* MAYBE: Extend TCC (and PyTCC) to provide access to AST\n\n\n\n# Howto Build\n\nTo build this extension the following software (apart from python) is\nrequired as prerequisites:\n* CMake\n* C Compiler\n* tox *[OPTIONAL]*\n\nFirst of all you have to build the TCC binaries by running cmake to\ncreate your platform specific project files and then build your project\nfiles. In the last step you build the python C-extension as wheel via setup.py.\n\n## Linux\n```\n\u003e\u003e cmake -B tinycc-bin/linux64\n\u003e\u003e cmake --build tinycc-bin/linux64 --config Release\n\u003e\u003e pip wheel -w wheels .\n```\n\n## macOS\n```\n\u003e\u003e cmake -B tinycc-bin/mac64\n\u003e\u003e cmake --build tinycc-bin/mac64 --config Release\n\u003e\u003e pip wheel -w wheels .\n```\n\n## Win32\n```\n\u003e\u003e cmake -A Win32 -B tinycc-bin/win32\n\u003e\u003e cmake --build tinycc-bin/win32 --config Release\n\u003e\u003e pip wheel -w wheels .\n```\n\n## Win64\n```\n\u003e\u003e cmake -A x64 -B tinycc-bin/win64\n\u003e\u003e cmake --build tinycc-bin/win64 --config Release\n\u003e\u003e pip wheel -w wheels .\n```\n\nAlternatively you could choose any directory as output for the TCC libraries\nbuild by cmake and set the environment variable ``TCC_BUILD_DIR`` to the \ncorresponding directory.\n\nIf you want to run the unittests the recommended way is running tox after you\nbuilt the TCC binaries.\n\n\n\n# Howto debug\n\nTo debug pytcc it is recommended to run cmake when the python environment\nthat shall be used for the tests is activated.\nCMake will then create an additional target: \"pytcc\".\nThis one can be used for creating the C extention without setup.py.\nAs cmake is supported by most C IDEs you can use the resulting project file\nto debug the project:\n\nFor example on linux the sequence looks like:\n```\n\u003e\u003e source .tox/py36/bin/activate  # tox has to be run before this command!\n\u003e\u003e cd tinycc-bin/linux64\n\u003e\u003e rm -R *                        # necessary as CMake cache has to be reset\n\u003e\u003e cmake ../..\n\u003e\u003e make pytcc\n\u003e\u003e export PYTHONPATH=.\n\u003e\u003e python -m pytest ../../tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrh1997%2Fpytcc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrh1997%2Fpytcc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrh1997%2Fpytcc/lists"}