{"id":8394,"library":"pact-python-ffi","title":"Pact Python FFI","description":"`pact-python-ffi` provides low-level Python bindings for the underlying Pact FFI (Foreign Function Interface) library, which is written in Rust. It enables Python applications to directly interact with the core Pact logic for contract testing. While often an internal dependency of the higher-level `pact-python` library, it can be used independently for advanced FFI control. The current version is `0.4.28.2`, and it is part of the `pact-python` monorepo, following its active release cadence.","status":"active","version":"0.4.28.2","language":"en","source_language":"en","source_url":"https://github.com/pact-foundation/pact-python/tree/master/packages/python/pact-python-ffi","tags":["pact","ffi","consumer-driven-contracts","testing","bindings","rust"],"install":[{"cmd":"pip install pact-python-ffi","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The `pact.v3.ffi` module was removed and replaced by the top-level `pact_ffi` package in versions `0.4.28.0` and later.","wrong":"from pact.v3.ffi import ffi_version","symbol":"ffi_version","correct":"from pact_ffi import ffi_version"},{"symbol":"ffi_init","correct":"from pact_ffi import ffi_init"},{"symbol":"ffi_log_level","correct":"from pact_ffi import ffi_log_level"}],"quickstart":{"code":"import os\nfrom pact_ffi import ffi_version, ffi_log_level, ffi_init\n\n# Initialize the FFI logging\n# PACT_LOG_LEVEL can be 'trace', 'debug', 'info', 'warn', 'error'\nlog_level = os.environ.get('PACT_LOG_LEVEL', 'info')\nffi_init(log_level)\nprint(f\"Pact FFI initialized with log level: {log_level}\")\n\n# Get and print the FFI library version\nversion = ffi_version()\nprint(f\"Pact FFI library version: {version}\")\n\n# Example of setting log level dynamically (optional, usually set once)\n# ffi_log_level(\"debug\")\n# print(\"Log level set to debug.\")","lang":"python","description":"This quickstart demonstrates how to import and use basic functions from the `pact-python-ffi` library, such as initializing FFI logging and retrieving the underlying FFI library version. It shows how to interact with the FFI directly."},"warnings":[{"fix":"Update all imports from `from pact.v3.ffi import ...` to `from pact_ffi import ...`.","message":"The `pact.v3.ffi` module has been removed and its functions replaced by the top-level `pact_ffi` package.","severity":"breaking","affected_versions":"`pact-python-ffi >= 0.4.28.0`"},{"fix":"Upgrade your Python environment to 3.10 or newer. Earlier versions of `pact-python-ffi` might still support Python 3.9.","message":"Python 3.9 support has been officially dropped.","severity":"breaking","affected_versions":"`pact-python-ffi >= 0.4.28.2`"},{"fix":"For typical consumer/provider testing, consider `pip install pact-python` for a higher-level API.","message":"`pact-python-ffi` is a low-level FFI binding. Most users seeking Python-based Pact contract testing should primarily use the `pact-python` library, which leverages `pact-python-ffi` internally, rather than interacting directly with `pact-python-ffi`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Change your import statements from `from pact.v3.ffi import ...` to `from pact_ffi import ...`.","cause":"You are attempting to import from the deprecated `pact.v3.ffi` module which was removed in recent versions of `pact-python-ffi`.","error":"ModuleNotFoundError: No module named 'pact.v3.ffi'"},{"fix":"Upgrade your Python environment to version 3.10 or newer. You can use tools like `pyenv` or `conda` to manage Python versions.","cause":"You are attempting to install `pact-python-ffi` on an unsupported Python version (Python 3.9 or older).","error":"ERROR: Package 'pact-python-ffi' requires a different Python version: 3.10 or newer, but you have 3.9.x (or similar pip installation error)"}]}