Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 15, 2025

This PR adds the PyNaCl package recipe to emscripten-forge. PyNaCl is a Python binding to the Networking and Cryptography (NaCl) library, providing high-level cryptographic primitives for Python applications.

Changes Made

  • Recipe Definition: Created recipes/recipes_emscripten/pynacl/recipe.yaml with:

    • PyNaCl version 1.6.0 (latest stable release)
    • Proper build dependencies including cffi (>=1.4.1) and make for compiling bundled libsodium
    • Standard emscripten-forge Python package build configuration
    • Correct source URL and SHA256 hash from PyPI
    • Added license_file field pointing to LICENSE file
  • Cross-compilation Support: Added recipes/recipes_emscripten/pynacl/build.sh script to handle cross-compilation:

    • Sets CHOST="wasm32-unknown-emscripten" for autotools recognition
    • Configures LIBSODIUM_CONFIGURE_ARGS="--host=wasm32-unknown-emscripten" for PyNaCl's bundled libsodium
    • Ensures proper cross-compilation setup for the emscripten-wasm32 target platform
  • Testing: Added recipes/recipes_emscripten/pynacl/test_import_pynacl.py with comprehensive import tests covering:

    • Core nacl module
    • Key submodules: secret, public, utils, hash, signing, encoding

Technical Details

PyNaCl bundles its own copy of libsodium which gets compiled during the build process, requiring make as a build dependency and special cross-compilation configuration. The recipe follows established patterns from other cryptographic packages in the repository (like cryptography and cffi).

The build script addresses the autotools configure error by properly setting environment variables that PyNaCl's bundled libsodium recognizes, ensuring the configure script knows it's being cross-compiled for WebAssembly.

The package provides Python bindings for:

  • Symmetric encryption (nacl.secret)
  • Public-key cryptography (nacl.public)
  • Digital signatures (nacl.signing)
  • Cryptographic hashing (nacl.hash)
  • Encoding utilities (nacl.encoding)

Fixes #2873.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] pynacl Add pynacl Sep 15, 2025
Copilot AI requested a review from IsabelParedes September 15, 2025 17:08
Copilot finished work on behalf of IsabelParedes September 15, 2025 17:08
Copy link
Member

@IsabelParedes IsabelParedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot implement changes

Copilot AI requested a review from IsabelParedes September 15, 2025 17:14
Copilot finished work on behalf of IsabelParedes September 15, 2025 17:14
Copy link
Member

@IsabelParedes IsabelParedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot add --host

configure: error: cannot run C compiled programs.
      If you meant to cross compile, use '--host'.

Copy link
Contributor Author

Copilot AI commented Sep 16, 2025

@copilot add --host

...

Added --host=wasm32-unknown-emscripten flag via build.sh script to fix cross-compilation error. The script sets environment variables that will be passed to the bundled libsodium configure script. Commit 184cb29

Copilot finished work on behalf of IsabelParedes September 16, 2025 09:23
Copilot AI requested a review from IsabelParedes September 16, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pynacl

2 participants