Skip to main content

Zero-dependency parser for Haskell .cabal files: top-level fields, build stanzas (library/executable/test-suite) and build-depends as clean package names.

Project description

cabal-file-parser

A tiny, dependency-free Python parser for Haskell .cabal package files. It reads the top-level fields (name, version, license, …) and the build stanzas (library, executable NAME, test-suite NAME, benchmark NAME, common), and turns build-depends into a clean list of package names — handy for CI, dashboards, dependency audits and metadata tooling.

Install

pip install cabal-file-parser

CLI

cabal-file-parser mypackage.cabal

Prints a JSON summary: name, version, all fields, every stanza, and a de-duplicated all_dependencies list.

Library

from cabal_file_parser import parse_cabal, dependency_names

pkg = parse_cabal(open("mypackage.cabal").read())
print(pkg.name, pkg.version)
for s in pkg.stanzas:
    print(s.kind, s.name, dependency_names(s.fields.get("build-depends", "")))

dependency_names("base >=4.7 && <5, text")["base", "text"].

A pragmatic parser for tooling/metadata, not a full Cabal grammar.

More Haskell & toolchain guides

Clear, independent guides on Haskell, Cabal and the developer toolchain: coldwa.st.

License

MIT

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

cabal_file_parser-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

cabal_file_parser-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file cabal_file_parser-0.1.0.tar.gz.

File metadata

  • Download URL: cabal_file_parser-0.1.0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cabal_file_parser-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be201d610edf9090f880d2d322753487b2bdd1037e1412dd7335ceaa77452e8e
MD5 8402fbee51478efcce6ee90f0a19240b
BLAKE2b-256 b36766b6394dba9d8e2a98df2c080a2f0e17a64e4123ed1a5dc01ed383ebfca6

See more details on using hashes here.

File details

Details for the file cabal_file_parser-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cabal_file_parser-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 999bc49602c181bcc5bcce484cef7909fce350fd83de93b621e45d1e88aae08b
MD5 f2e5141ebc0baa26a1163f608c1fce4c
BLAKE2b-256 add69263986f15a8c5b0359d9e71f01cd23da92a9b47ac4b8d593befd8b7e325

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