TinyCC compiler bundle for windows
Project description
TinyCC (or tcc) is a small, fast C compiler capable of producing DLLs that can be loaded via ctypes. This version compiles for 64 bit Windows.
Compiler version: 0.9.26 (amd64) 2013-02-16
Installation of the compiler and the python interface is simply:
pip install tinycc
Full documentation for the compiler is available at http://bellard.org/tcc. Source and binaries are available from https://savannah.nongnu.org/projects/tinycc/.
TCC is the full path to the tcc.exe executable, wrapped in quotes so that it can be used as part of an os.system command even when it contains spaces. The function find_tcc_path() returns the path without quotes.
Usage example:
import os from tinycc import TCC COMPILE = TCC + " -shared -rdynamic -Wall %(source)s -o %(target)s" source = "hello.c" target = os.path.splitext(source)[0] + ".dll" # replace .c with .dll command = COMPILE%{"source": source, "target": target} status = os.system(command) if status != 0 or not os.path.exists(target): raise RuntimeError("compile failed. File is in %r"%source)
or more simply, use compile:
from tinycc import compile dll_path = compile("hello.c")
Use data_files to gather the data files required for bundling tinycc in a py2exe package. This places the compiler in the tinycc-data directory beside the library.zip generated by py2exe. The following should appear in the setup.py for the py2exe build:
import tinycc data_files = [] ... data_files.extend(tinycc.data_files()) ... setup( ... data_files = data_files, ... )
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.