Skip to main content

Python Bindings for Security Labeler

Usages

From Python Interpreter

Python 3.10.13 (main, Aug 24 2023, 12:59:26) [Clang 15.0.0 (clang-1500.0.40.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from labeler import labeler
INFO:2023-12-08 06:19:28,950 get_library_name:12 - Operating System: macos-14.1.2-arm64-arm-64bit
INFO:2023-12-08 06:19:28,950 get_library_name:13 - CPU Architecture: ('64bit', '')
>>> labeler.evaluate('{"number":1}', "when number > 0 then 'tag1' else 'tag2'")
'tag1'

From Python Script

from labeler import labeler

content = '{"number":1}'
statement = "when number > 0 then 'tag1' else 'tag2'"

result: str = labeler.evaluate(content, statement)

print(f"result:{result}")

How to Build (as the developer)

Prerequisites

  • Shared libraries must have been built prior building the Python pacakge.

    • Libraries are expected to exist in the labeler directory with libkoverse_labeler- prefix.

Make Targets

Several make targets are provided.

  • clean - delete files under build/*, dist/*, src/*.egg-info/, inputs/*, src/labeler/libs/*.so, src/labeler/libs/*.dylib directory but keep the .gitkeep file.

  • init - install Python build package.

  • copy_test_data - copy the test data from ../inputs directory to the current directory.

  • copy_library - copy library files from ../labeler directory into ./src/labeler/libs/ directory.

  • install_extra_dependencies - install extra depdencies needed for testing.

  • build - build and package

  • tests - run the test

  • test_upload - upload package to Test PyPI.


Building the package

make init
make build

How to Run Tests

make tests

How to Publish to TestPyPI

make test_upload

How to Install the package (as a user)

pip install cffi

pip install -i https://test.pypi.org/simple/ labeler

# or in one go
pip install -i https://test.pypi.org/simple/ labeler --extra-index-url https://pypi.org/simple/ cffi

Editable Install

This assumes the package has been built locally already.

pip install -e .

Install extra dependencies

pip install -e ".[dev]"

Release files for cch-labeler 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for cch-labeler 0.0.0
File Interpreter ABI Platform
cch_labeler-0.0.0-py3-none-any.whl Python 3 none any Details

Release files / cch_labeler-0.0.0-py3-none-any.whl

Download URL cch_labeler-0.0.0-py3-none-any.whl
Size 30.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88061288ba6d9d27805a1ea23a3b70c0035fcff2ef2b95384ad52c9159ba1773
BLAKE2b-256 checksum
How to use checksums
c961a5acdac4c072c29c92007eb84e9c0b48bdf16aa7c0be25511c4d31c69c33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page