Skip to main content

A pymsbuild extension for compiling native modules written in Rust.

Project description

pymsbuild-rust

This is a pymsbuild extension for compiling native modules written in Rust.

Quick Start

In your _msbuild.py, import RustPydFile and Cargo from pymsbuild_rust (using import * is okay).

While Cargo is used to run the build, all files need to be specified from your _msbuild.py file to be collected when building an sdist, and to handle incremental builds correctly.

from pymsbuild import *
from pymsbuild_rust import *

METADATA = {...}

PACKAGE = Package(
    'package',
    PyFile("__init__.py"),
    RustPydFile(
        "native",
        Cargo("Cargo.toml"),
        SourceFile("src/lib.rs"),
        source="native"
    ),
)

The Cargo element refers to your Cargo.toml, which should specify that a cdylib is to be built. The name of the lib should match the name provided to RustPydFile, which will also be the resulting extension module's name.

[lib]
name = "native"
crate-type = ["cdylib"]

Other than this, the module may build in any way it likes. Most likely, you will use PyO3, and so should follow their documentation for instructions on setting up the rest of your project (ignoring the parts that refer to other build backends such as Maturin).

Other files listed in the RustPydFile will be included in your sdist, and will be used to determine whether the module needs to be recompiled.

Theoretically, multiple Cargo elements will trigger multiple builds. However, as they will all be directed into the same directory, this may not do what you hope. Advanced users may find some value regardless.

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

pymsbuild_rust-0.1.4.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

pymsbuild_rust-0.1.4-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pymsbuild_rust-0.1.4.tar.gz.

File metadata

  • Download URL: pymsbuild_rust-0.1.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pymsbuild_rust-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e75f92d141dd6142b203dc7fb8ed5c0ef941434d52cd53c2f9c5be15ad7ae084
MD5 01333bc59afd19bca8921e6113283438
BLAKE2b-256 5fa1040bca750b022dd72ffbf1d7b65a7e6867bd66fbd8a43abc5b9e57c83b02

See more details on using hashes here.

Provenance

File details

Details for the file pymsbuild_rust-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pymsbuild_rust-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 78a6d55dc0c811420ce637d2617b591d06b9e43fc4f331089da322624cf0bdc4
MD5 d686e4f79b045bb96543c4c455938958
BLAKE2b-256 98c193de81b4dd049b4cfd7c384cda1fa3098721a5d1a78d2a665904ffb9c6c1

See more details on using hashes here.

Provenance

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