Skip to main content

Python bindings for the userauth library: the anonymous credentials implementation used in OONI

Project description

ooniauth-py

This is the bindings library used to call the anonymous credentials library from Python land

We use this in our backend implement the anonymous credentials protocol in our API

Installation

You can install this library by running:

pip install ooniauth-py

Development requirements

These tools are required to contribute to this library

  1. maturin: Is used to build the library itself, it's heavily used to develop this library

In order to use maturin, you need a virtual environment to manage the resulting Python package during development, see more details here

Testing installation

If you try to run the tests as you usually would with cargo test, you will get linking errors. This happens because Maturin provides a build configuration with all the linking flags required to build the library. However, it does not provide a maturing test command that could help you with this.

A possible solution is to manually specify the linking flags to the compiler, but in order to do this you will probably need to download the specific Python version (3.10). A good way to do this is using Pyenv:

  1. Install Pyenv
  2. Install Python 3.10.0 with pyenv: pyenv install 3.10.0

With the Python version installed, you can create a .cargo/config.toml with the linking flags. Create the file in userauth/.cargo/config.toml and fill the following template:

[target.'cfg(all())']
rustflags = [
    "-C", "link-arg=-Wl,-rpath,<YOUR PYENV PATH HERE>/.pyenv/versions/3.10.0/lib",
    "-C", "link-arg=-L<YOUR PYENV PATH HERE>/.pyenv/versions/3.10.0/lib",
    "-C", "link-arg=-lpython3.10",
]

Example result:

[target.'cfg(all())']
rustflags = [
    "-C", "link-arg=-Wl,-rpath,/home/ooni/.pyenv/versions/3.10.0/lib",
    "-C", "link-arg=-L/home/ooni/.pyenv/versions/3.10.0/lib",
    "-C", "link-arg=-lpython3.10",
]

Note: Make sure to create this file in userauth/.cargo/config.toml and not in userauth/ooniauth-py/.cargo.toml

Usage

  1. Create a ready-to-use .whl to import in python: make wheels
  • Note: You will find the wheels file in: /userauth/ooniauth-py/wheels
  1. Build the library and install it in a virtualenv for trying it in Python: make dev
  • Note: Requires an active virtual environment to install the library
  1. Run tests: make test

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ooniauth_py-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl (648.7 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

ooniauth_py-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (585.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file ooniauth_py-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ooniauth_py-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 51a75eebdf2f473fea94785323bf4e4151098cdadf1d00f3256f0a9bbae64ff7
MD5 d45cac299098ace26405fdd827eae980
BLAKE2b-256 1ad55b9b3345d5b6fcd7be4759d4b83a4964c640db6c81aab41b8911f4407ed8

See more details on using hashes here.

File details

Details for the file ooniauth_py-0.2.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ooniauth_py-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f28c2df90db6285fc73d1d04b0fa4e95c688621e25a6f6290145f90c50875b1
MD5 65493f7d8d435ac19b7119a7c84acc1c
BLAKE2b-256 75f8a1f3a76103ee7ea2e6eacf44767fe637f76b5f998bcc308c250acc91bf29

See more details on using hashes here.

Supported by

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