Skip to main content

Library to parse the Cargo.toml manifest file.

Project description

cargo-parse

A Python package to parse Cargo.toml manifest files.

Installation

This package is not (yet) published on PyPI. For now, the best way to install the package is to use Poetry.

Clone this repository and run poetry install.

Install in another environment

To install the package in a system environment, or another virtual environment besides the Poetry project environment:

  1. Build the package wheel with poetry build.
  2. Install the package using the correct environment's pip:
<your-python> -m pip install <path-to-repo>/dist/cargo-parse-*.whl

Usage

Import the parse_manifest_from_toml function and use it to parse the contents of Cargo.toml:

from cargo_parse import parse_manifest_from_toml

from pathlib import Path

cargo_toml_file = "Cargo.toml"
manifest = parse_manifest_from_toml(Path(cargo_toml_file))

# Print out the package version
print(manifest.package.version)

# Print out the dependencies
if manifest.dependencies is not None:
    print(manifest.dependencies)
else:
    print(f"No dependencies defined in {cargo_toml_file}")

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

cargo-parse-0.1.0.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

cargo_parse-0.1.0-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

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