Skip to main content

srcml_caller, simple python bindings for srcML

Project description

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

Example usage

>>> import srcml_caller
>>> srcml_caller.to_srcml("void foo(int v);", srcml_caller.CodeLanguage.c_plus_cplus)

'<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                                
.\vcpkg\vcpkg install libxml2:x86-windows-static libxslt: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                                
.\vcpkg\vcpkg install libxml2:x86-windows-static libxslt: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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

srcml-caller-0.2.0.tar.gz (603.7 kB view details)

Uploaded Source

Built Distributions

srcml_caller-0.2.0-cp312-cp312-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.12 Windows x86-64

srcml_caller-0.2.0-cp312-cp312-win32.whl (5.1 MB view details)

Uploaded CPython 3.12 Windows x86

srcml_caller-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.1+ x86-64

srcml_caller-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

srcml_caller-0.2.0-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

srcml_caller-0.2.0-cp312-cp312-macosx_10_9_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

srcml_caller-0.2.0-cp311-cp311-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.11 Windows x86-64

srcml_caller-0.2.0-cp311-cp311-win32.whl (5.1 MB view details)

Uploaded CPython 3.11 Windows x86

srcml_caller-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

srcml_caller-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

srcml_caller-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

srcml_caller-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

srcml_caller-0.2.0-cp310-cp310-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.10 Windows x86-64

srcml_caller-0.2.0-cp310-cp310-win32.whl (5.1 MB view details)

Uploaded CPython 3.10 Windows x86

srcml_caller-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

srcml_caller-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

srcml_caller-0.2.0-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

srcml_caller-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

File details

Details for the file srcml-caller-0.2.0.tar.gz.

File metadata

  • Download URL: srcml-caller-0.2.0.tar.gz
  • Upload date:
  • Size: 603.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for srcml-caller-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d9070cca14123d0edc21fd8a885b9984b62d979c1ca937f2e3890274d4751ae2
MD5 9079e340d3180738243c26a355c10e5c
BLAKE2b-256 3cbf8782cb564ff460a2b29f57c5d64a116b4116647e00ce4d48a94157f9dfb8

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 930ab31f8347e7fd50dfe438ed4a0b10e8504d394fa33a35a704d831cd27d335
MD5 a2505d7bbedfa504d8f1175b43ae5383
BLAKE2b-256 537cee6ddd7060f7609f6240fd1690ce5d213f5bee07446d9b343055dedddd9a

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 8a9c3e99097eab43c7ded716b4a051ad94f182b7efc1414d8b6e6025b1440b9c
MD5 7b46b143a31d3032c287df8e23fcfcbb
BLAKE2b-256 08a2dbf87c00ad85c302cf53e52e33de651eeecfb18fcc3bef298830262af097

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 6c8009a1d82bb61c8dc270cf2d3b5f4a956069dd1341a87951572ad864f6adbf
MD5 eb2494e7c1ca9759178c3c758f98560f
BLAKE2b-256 6296e0932c43961e2dbd081054a4cc15b14d19777c0ddf6fcdf7df00e5a86d09

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e193837e74ee5c812cc9308a4dca2884e6d05363436dbd8c3380fbc4b2eb7f04
MD5 b362249604f862e2eadecfe955660054
BLAKE2b-256 fcbd39220ff2bdcac4072dad63e055a3543ffedbc6648dd45acfe701439fa540

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a32cb6258aa631f0ec09ec18d5e2dea5c6a1c8c008a380151989cbaf209e73ee
MD5 96733f05ad46e4114810eccdf44ab0f6
BLAKE2b-256 6d262ff782bc52011ea013f98bc6191657c3f59e78ad434c05dab2fa6f52b040

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ffe736c7caf2c57510130e2a1a0708cab9fd9c6b14ee2c6084afa8859c13959f
MD5 2760ba4bfb5d972d37ca3c16cfab9523
BLAKE2b-256 881bfd8b0b93f9d7de1c623c25e293e4bd0867d16ce5dffe8fd12075faa98cc7

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c8b453f6e40f61cafa86ebd116afbdd5ec21165170e7a75822f274c6fc918627
MD5 5d6b71c5912bd26cfb0bfbda0734760a
BLAKE2b-256 c8538587bb90331a7147833053af85695bb596ef1c2374686ac62384cc1d0374

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 26d47c210f96b78557bee5f085cc664a1a658b23234a78bf80d68413e53a9372
MD5 63ca1a70e3a3b8468d48498ade2a4460
BLAKE2b-256 1523770c94b33a0f3b50790882808d6677eae38483e573d0072c116d7a6e5aa5

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 3911f1bc5c767bd3d9ae169f66c0a2d97c77bac8bc66e5aea5dceae88f1ca102
MD5 d245ac639b8d92c779f19957780b1093
BLAKE2b-256 f64357c78aeeb4b09ef90709ad10beaa0b16f0a3206f306387e2e07cc1aa1325

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61f914875e43d723c0d822c99b47c13c997a70eb484dd2562f3518477c27f69c
MD5 b21e87c7ce9fe444d609db516c183f2f
BLAKE2b-256 bb25c125170d41d82507b0a96b26c3bb658b7ee997cd7e50d0ee5e4e3e04e2c7

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29577019ae334558f09aacb8aacfab9d68e125cb55a45e44e4f08da0e6adfa3c
MD5 df829395773de12c5e3279a037de8702
BLAKE2b-256 ec5e583aa9687778f44e84f787e21fa919bf8e81d7bd6ce8e9f593a6958dd682

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 16b3f02209515f08d1870fe510088d0d663608de9491bac048c22963f9ad79c2
MD5 2ac296a1c13389d01211dd94bf75d8af
BLAKE2b-256 179d37b3147d84d8016bcaaaa2fa9a7d2491fcd4cad43639912eac698fbb90c4

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 98311c1d4c044e1fe549375c78cb7efe792c868045e2ca8b531ff15559625170
MD5 ebccdc37a16e06717857f20ad9e8c9ae
BLAKE2b-256 4dfc1306fbcced145b28aa173d565f019a29c20be7e568b5ca5e18f886de5fc8

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 a59f41875148b4c2f02e4943a4b109ac0136e4fc89a1ab3cecafc433359663da
MD5 f17a85643af77a7b2a3422b7cb2dcbbb
BLAKE2b-256 629ba7e3c3d4c4bf82e8e0d9d69a9b0c95fafda4c6c7d6c6c68a5046e4f2d375

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 21203ed44adade966c27bef4ae5f4b5fdf649121bcf8bbc512dfb4fb348851da
MD5 8e3b70727f6adc8325a6f083eb7237b2
BLAKE2b-256 c12faf30440041c8966cecee5664544671ca5964f370b8b7556a1f6e0d1dd7bf

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ac839fc228291e7e53b93fafc756b588bbad283df435a84bb92bba001958a2be
MD5 8a23f19f93a41e76ede378e4d81bbd3d
BLAKE2b-256 63dfb973f8050fe0f953014eaa4b138ed1c339001edb470c348defc38aac37e6

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0182980e0028ee31c28ada2fdac9caddc239a4cddcb9811326431e69f76ab400
MD5 48bbffe0a8c31bb87108165a717e1777
BLAKE2b-256 807f56249c59af4ef263d5517af74c9ce83524519aa79337424be81d8e19b2a7

See more details on using hashes here.

File details

Details for the file srcml_caller-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for srcml_caller-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 01d6730682ba94282e6d17610adf477415ae2d48284dcecb9d49230f7b081290
MD5 4d5bea3fb4e780f16052d012408b1e14
BLAKE2b-256 c302232391e8040e90f5824ba62b8653317c9486777a80b513cb6f6e1287645b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page