srcml_caller
Simple python bindings for srcML.
Provides:
from typing import Optional
import enum
class CodeLanguage(enum.Enum):
c = enum.auto() # (= 0)
c_sharp = enum.auto() # (= 1)
c_plus_plus = enum.auto() # (= 2)
java = enum.auto() # (= 3)
objective_c = enum.auto() # (= 4)
def to_code(
xml_str: str,
encoding_src: str = "utf-8",
encoding_xml: str = "utf-8"
) -> Optional[str]:
pass
def to_srcml(
code: str,
language: CodeLanguage,
include_positions: bool = True,
encoding_src: str = "utf-8",
encoding_xml: str = "utf-8"
) -> Optional[str]:
pass
def cpp_to_srcml(
code: str,
include_positions: bool = True,
encoding_src: str = "utf-8",
encoding_xml: str = "utf-8"
) -> Optional[str]:
pass
Example usage
>>> import srcml_caller
>>> srcml_caller.to_srcml("void foo(int v);", srcml_caller.CodeLanguage.c_plus_plus)
'<unit revision="1.0.0" language="C++" pos:tabs="8"><function_decl pos:start="1:1" pos:end="1:16"><type pos:start="1:1" pos:end="1:4"><name pos:start="1:1" pos:end="1:4">void</name></type> <name pos:start="1:6" pos:end="1:8">foo</name><parameter_list pos:start="1:9" pos:end="1:15">(<parameter pos:start="1:10" pos:end="1:14"><decl pos:start="1:10" pos:end="1:14"><type pos:start="1:10" pos:end="1:12"><name pos:start="1:10" pos:end="1:12">int</name></type> <name pos:start="1:14" pos:end="1:14">v</name></decl></parameter>)</parameter_list>;</function_decl></unit>'
Install instructions (from pypi)
pip install -v srcml_caller
Install instructions (from source)'
git clone https://github.com/pthom/srcml_caller.git
cd srcml_caller
git submodule update --init # will fetch srcML submodule
pip install -v .
Note: on windows, you need to first install libxml2 and libxslt with vcpkg, see below:
# inside the srcml_caller directory:
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg install libxml2:x64-windows-static libxslt:x64-windows-static libiconv:x64-windows-static
.\vcpkg\vcpkg install libxml2:x86-windows-static libxslt:x86-windows-static libiconv:x86-windows-static
Development build instructions
Install requirements
Linux
Download and install a newer binary version of cmake (cmake 3.24 is required)
For example:
# This is where cmake will be put
MY_BIN_DIR=~/bin
# (select your arch below)
CMAKE_BIN_URL=https://cmake.org/files/v3.25/cmake-3.25.0-linux-x86_64.tar.gz
# CMAKE_BIN_URL=https://cmake.org/files/v3.25/cmake-3.25.0-linux-aarch64.tar.gz
curl -L $CMAKE_BIN_URL > cmake_new.tgz
tar xvfz cmake_new.tgz
rm cmake_new.tgz
echo "export PATH=$MY_BIN_DIR/cmake-3.25.0-linux-aarch64/bin:$PATH" >> ~/.bashrc
echo "export PATH=$MY_BIN_DIR/cmake-3.25.0-linux-aarch64/bin:$PATH" >> ~/.zshrc
Install requirements
Follow instructions on srcML repo: https://github.com/srcML/srcML/blob/master/BUILD.md
Install requirements for Ubuntu
From https://github.com/srcML/Docker/blob/ubuntu_latest/base/Dockerfile
sudo apt-get update && sudo apt-get install --no-install-recommends -y \
curl \
zip \
g++ \
make \
ninja-build \
libxml2-dev \
libxml2-utils \
libxslt1-dev \
libarchive-dev \
libssl-dev \
libcurl4-openssl-dev \
cpio \
man \
file \
dpkg-dev
You can also run ci_scripts/install_requirements_ubuntu.sh, which does exactly this.
Build
git submodule update --init
Unix and MacOS
python3 -m venv venv
source venv/bin/activate
pip install pybind11
mkdir build
cd build
cmake .. -DPYTHON_EXECUTABLE=../venv/bin/python
Windows
Please clone vcpkg in the same directory as this project, then install libxml2 and libxslt like this:
git clone https://github.com/Microsoft/vcpkg.git
.\vcpkg\bootstrap-vcpkg.bat
.\vcpkg\vcpkg install libxml2:x64-windows-static libxslt:x64-windows-static libiconv:x64-windows-static
.\vcpkg\vcpkg install libxml2:x86-windows-static libxslt:x86-windows-static libiconv:x86-windows-static
python3 -m venv venv
venv\Scripts\activate
pip install pybind11
mkdir build
cd build
cmake .. -DPYTHON_EXECUTABLE=c:\FULL\PATH\TO\venv\Scripts\python.exe
Metadata
Release files for srcml-caller 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| srcml_caller-0.5.0.tar.gz | 727.3 kB | Details |
Built distributions (wheels)
Total release size: 93.0 MB
Release files / srcml_caller-0.5.0.tar.gz
| Download URL | srcml_caller-0.5.0.tar.gz |
|---|---|
| Size | 727.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f45c91384fc2595b49e27f853eea93dbd4a8c40400577e12292aaad97940d877
|
|
BLAKE2b-256 checksum How to use checksums |
7874611253f5f08b8d594d1b87199ef635a43a4ebebe9764b2ee2820755d685c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp314-cp314-win_amd64.whl
| Download URL | srcml_caller-0.5.0-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 6.6 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
76e12c9243f6afb51e6984581cdb6177c205c0ca85f66aa7cce1e2b9589ec2c1
|
|
BLAKE2b-256 checksum How to use checksums |
487455e30643b289d50186a99d9e644d27185e368820e76136a53e25e74050b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
6ca74314080524f7a22c66cc89b7f07bcde25b935a9ddbdef00611a5f946b25e
|
|
BLAKE2b-256 checksum How to use checksums |
92f4f391a941d0de6836f2857d75b533a977d56849cf1b12e2cc2402de94ebdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp314-cp314-manylinux_2_28_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp314-cp314-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.5 MB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
26077a43303840a1d63d6673f07fe364334597591a59f65e93b20dad5454fba3
|
|
BLAKE2b-256 checksum How to use checksums |
fd66b5b8f93b3ecb3c6ba3abe5d0be89af34576407975dc03123134b8a3cb9ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | srcml_caller-0.5.0-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f392c3360f44a3a58c464894696d086ec399ccc37187ed699c568faa6c7afd07
|
|
BLAKE2b-256 checksum How to use checksums |
2ca5c7029656cf97786f1793c87ce0353266ab409f6cc511947390789ca66e90
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp313-cp313-win_amd64.whl
| Download URL | srcml_caller-0.5.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 6.5 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c3754650f894c4247f51ca4437910b6131af63bc4de72a61c38467f04c1bdf89
|
|
BLAKE2b-256 checksum How to use checksums |
1eda34b73fa4437cce68ce9491cc4dba0b3bcb683c1a4521cbc9e7e523130006
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
d449ca2f41d77f49c36e4181c6038b4dfa01b73dc270a9b41e316fa9ba49d6c6
|
|
BLAKE2b-256 checksum How to use checksums |
e71cbeb1f92fd90446b7e85eef14a9ef01b274734edd2c090d0f39eecaf5cd58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.5 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
b75894de3e083cffe858c8cb124bd647b13bd69e39c719d41b02f7818a8400aa
|
|
BLAKE2b-256 checksum How to use checksums |
069f9b1450705b241a00b75cbdc0611b744eb255b1f36d14d6071b97210a3138
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | srcml_caller-0.5.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bde0d754b13c12108e1710ca890e1546e1ed1b83ae251421958705ebad9c23ea
|
|
BLAKE2b-256 checksum How to use checksums |
3ff31dea50e8f9f065a3ca327243f410845eadd1ed3afeda7515deb91b932989
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp312-cp312-win_amd64.whl
| Download URL | srcml_caller-0.5.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 6.5 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e36f9d5c69f41fe2d0a01b767486f3692d4bdda47bff1f69d66ace19cf1ddf68
|
|
BLAKE2b-256 checksum How to use checksums |
f9d64becd7e9fe5b0c87267fb3d2a0c20dab77294d66c3a0b3425e82883a9a9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
a59b8d606c3f5a24439013ff399c2215281b81137acefe70633b94e53db232bf
|
|
BLAKE2b-256 checksum How to use checksums |
ff1826e48fd53e1319eeadd7f81cffc4b5352d7612435dd30aeee50257bde7a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp312-cp312-manylinux_2_28_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp312-cp312-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.5 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
33d22351121686f66bc00a07df82b5851e6bcff3800868bcf38ff142fbca2cdb
|
|
BLAKE2b-256 checksum How to use checksums |
7eb5e62829e0754547f28417e3dbeeb5603de8dfb89d08fb931116c0b53bf6c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | srcml_caller-0.5.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
626f39bcb8dfd12bacca8ca7534c0681822fa445c712dacfcdc7648ea7da273f
|
|
BLAKE2b-256 checksum How to use checksums |
956ae30fa832223d812ef96dddd7166b4bc7b21d8b1ed02d192043f2ffede024
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp311-cp311-win_amd64.whl
| Download URL | srcml_caller-0.5.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 6.5 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
64ea972a099b7aa4acc1fd91eea9d124aecf28409aa2b8c31ba7ad3ab9593b61
|
|
BLAKE2b-256 checksum How to use checksums |
8437e4b731f81deda6fb7b2a97d841a0ab5111c4c186ee31089c902226a19422
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
c23fbb112fa8ab4468dcf17440a25677da2eaf46e8672619c10a3750d62e3e1b
|
|
BLAKE2b-256 checksum How to use checksums |
cdb7f8a9b77d647b861d343c5959d88d57707c15107391264e7aee49fa749384
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp311-cp311-manylinux_2_28_x86_64.whl
| Download URL | srcml_caller-0.5.0-cp311-cp311-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.5 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
55737b2335b2c5bcb9c6a32e980c7f2615777ffb03af28c8211482b96c386d6e
|
|
BLAKE2b-256 checksum How to use checksums |
5bf8af371757af799ab5fa33502566a25d34d28ff1cb83283d97aec6e2ea9680
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / srcml_caller-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | srcml_caller-0.5.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2ab4ca4780d0ea7a23e19e61ea3d30b12fd2c7a8965af69789009059c5eb917b
|
|
BLAKE2b-256 checksum How to use checksums |
ede3378b082ef6dd7e434af6c77c5521a5f39a17b745e68bfade59e8ad81fb89
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|