This release is a pre-release and may not be stable for production use.
|PyPI| |Actions Status| |Release|
llvm2py #######
A fairly large proportion of programs are written in C/C++.
Let's imagine that you need to analyze programs in a given language, to search for vulnerabilities, to detect patterns or for optimization purposes. To solve such a problem, it is necessary to have the code in a slightly more convenient form than the source code of the program - an intermediate representation.
You might come up with the idea of building your own compiler, which is quite difficult, or you might decide to use intermediate representations of GCC or LLVM, but in that case you have to deal with the C/C++ API, which is something you don't want when you have elegant solutions in Python.
llvm2py allows you to analyze C/C++ programs in the LLVM IR representation in Python.
.. note::
The library is in beta, so in case of problems, feel free to create issues.
Usage example
The following example will build a control flow graph for the following function factorial.c, factorial.ll.
.. code-block:: cpp
int factorial_req(int n)
{
if (n == 1)
{
return 1;
}
return factorial_req(n - 1) * n;
}
.. code-block:: python
from llvm2py import parse_assembly
from llvm2py.ir import *
from graphviz import Digraph
with open("../test_files/factorial.ll") as file:
source = file.read()
mod = parse_assembly(source)
g = Digraph()
node_attributes = {"shape": "record", "style": "filled"}
def name_label(label):
return label.replace("%", "\\%")
def name_block(block):
name = block.value.val
return name_label(name)
for block in mod.funcs["factorial_req"].blocks.values():
color = "#f59c7d70" # Default block color
last_instruction = block.instrs[-1]
match last_instruction:
case Br(None, Value(label)):
g.edge(name_block(block), name_label(label))
case Br(_, Value(label_false), Value(label_true)):
g.edge(name_block(block), name_label(label_true), label="True")
g.edge(name_block(block), name_label(label_false), label="False")
if len(block.pred_blocks) >= 2:
color = "#b70d2870" # merge-type block
g.node(name_block(block), **node_attributes, color=color)
g.save("cfg.dot")
.. |PyPI| image:: https://img.shields.io/pypi/v/llvm2py.svg :target: https://pypi.python.org/pypi/llvm2py
.. |Actions status| image:: https://github.com/Papr1ka/llvm2py/actions/workflows/main.yml/badge.svg?branch=main :target: https://github.com/Papr1ka/llvm2py/actions/workflows/main.yml
.. |Release| image:: https://img.shields.io/github/v/release/Papr1ka/llvm2py.svg?label=release :target: https://github.com/Papr1ka/llvm2py/releases
Metadata
Release files for llvm2py 0.2.0b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llvm2py-0.2.0b0.tar.gz | 36.3 kB | With provenance | Details for llvm2py-0.2.0b0.tar.gz |
Built distributions (wheels)
Total release size: 20.6 MB
Release files / llvm2py-0.2.0b0.tar.gz
| Download URL | llvm2py-0.2.0b0.tar.gz |
|---|---|
| Size | 36.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ef07f53a664cd66c00b70db0f075b1ed01ecce9c577748cba052384ea07af66
|
|
BLAKE2b-256 checksum How to use checksums |
d9a8c5113f562bcc6aa68f0bed05a303f18cf8f03779cdbb8901c21247d4a0ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp313-cp313-win_amd64.whl
| Download URL | llvm2py-0.2.0b0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c672220133b33cef60e459268da72b68e15e2f610b9be5911bd95a06f61dd87c
|
|
BLAKE2b-256 checksum How to use checksums |
f2382d149b21360968bc48a7226ed2c3b286db8fc9987bd4621cd81e0401654d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | llvm2py-0.2.0b0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ca8595389184251aacefb4505a2019864a5c92197d160feeff75929a944f370d
|
|
BLAKE2b-256 checksum How to use checksums |
07a8d803872bf7b315a96843da7558b98aecec85f8b470dccd594a9059c706fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp312-cp312-win_amd64.whl
| Download URL | llvm2py-0.2.0b0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
504cc87a4b4604742a59537d7ed7907f70c02c77a96785612aaf3a3bcc1222f8
|
|
BLAKE2b-256 checksum How to use checksums |
21662d3790d7b06c221873626c385ccbc077edb876191c4a8722430246416b52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | llvm2py-0.2.0b0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
45fa6a1ec1d40592c4c3a3d26cc858c627c6583cab170ecdb3207fb1a8c0c659
|
|
BLAKE2b-256 checksum How to use checksums |
41f1c8bb90dfa9c300cb4339130183854385a48ac5880ee027a538575ece8959
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp311-cp311-win_amd64.whl
| Download URL | llvm2py-0.2.0b0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a42036f37db369261c90b724a262d6526a6e13f982a00a144de744e4f0aa0628
|
|
BLAKE2b-256 checksum How to use checksums |
5b3c79639725a6c5ae4eddf0f4a9727dc4159ee76ebff440642facb353d61da8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | llvm2py-0.2.0b0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
83a6e17149a62c7019681560e9f6edcb28a449da1c2ea664c7fb9aa411fec607
|
|
BLAKE2b-256 checksum How to use checksums |
5d918706770400e6809aafe53d31e5df63554c860c95bf01981e1753149fbd6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp310-cp310-win_amd64.whl
| Download URL | llvm2py-0.2.0b0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9a6c9d6bc9ad337fc005abe3b9cdf9bd04d22c37734aed0f0d462c0b5ad6184a
|
|
BLAKE2b-256 checksum How to use checksums |
70b6034759dcaf65d725b847744059bc4776efbf2b7c353deafd8e28cb72947a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logRelease files / llvm2py-0.2.0b0-cp310-cp310-manylinux_2_28_x86_64.whl
| Download URL | llvm2py-0.2.0b0-cp310-cp310-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.8 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b800f5ce5bbc8fbf015a0df664226b55fef0ee4e7dae7fd59c9b88c1aad75fcb
|
|
BLAKE2b-256 checksum How to use checksums |
d733330297a918d0f0a5696c8eefb567da9a6ab91369c92b3bcc15f0b454ac95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logSecurity for llvm2py 0.2.0b0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 9 files in this release have been uploaded with provenance metadata.
Attestation for llvm2py-0.2.0b0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 9, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.