Crimes
Blur the line between C and Python.
First, write some C code:
/* hello.c */
#include <stdio.h>
void hello(void) {
printf("Hello world from C!\n");
}
Then import that C code into Python:
import crimes
crimes.commit()
from hello import hello
hello() # prints "Hello world from C!"
All you had to do is call crimes.commit()!
What if I am a terrible C programmer?
Not to worry! crimes will print your syntax errors as part of the normal Python traceback:
/* hello.c */
#include <stdio.h>
/* missing ')' on the next line: */
void hello(void {
printf("Hello world from C!\n");
}
import crimes
crimes.commit()
from hello import hello # raises an error here
Gives you this error:
Traceback (most recent call last):
File "/tmp/example.py", line 6, in <module>
from hello import hello # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/hello.c", line 5, in hello.c
void hello(void {
^
crimes.exceptions.CCompileError: expected ';', ',' or ')' before '{' token
Install
First, install the library:
pip install crimes
Next, make sure you have a compatible version of GCC.
Any version of GCC 9.0 or greater should work. On most Linux distros,
you probably already have this installed. On macOS though... Apple
thought it was a good idea to symlink gcc to clang. This does not
work. So first, install actual GCC using brew:
brew install gcc@13
Next, before using this module, make sure that CC is set to use
gcc-13. You can do this universally like this:
export CC=gcc-13
...but I prefer to do it per-process:
env CC=gcc-13 python3 my-program-that-commits-crimes.py
Copying
Copyright © 2023 Eddie Antonio Santos. Apache-2.0 licensed. See
LICENSE for details. Especially the Disclaimer of Warranty!
Metadata
Release files for crimes 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| crimes-0.1.1.tar.gz | 10.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crimes-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / crimes-0.1.1.tar.gz
| Download URL | crimes-0.1.1.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fdfc0066982a91aaf37f79485b697db27770f249636f25d21c40524f62850aa9
|
|
BLAKE2b-256 checksum How to use checksums |
4b4b2bfa502d40be1f880df92c1e6b51b71d8b9d81d09adad1e6a1cf28be0b49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0
|
Release files / crimes-0.1.1-py3-none-any.whl
| Download URL | crimes-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
96fe487a9baa0f5051f710a7fd4644be6e6eb0645c46cd7dc50a58640355ff2d
|
|
BLAKE2b-256 checksum How to use checksums |
189d294f3b63311739a95f94d39544aee27ec530356f6c4d2fc19ef5cbaa5c9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0
|