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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be201d610edf9090f880d2d322753487b2bdd1037e1412dd7335ceaa77452e8e
|
|
| MD5 |
8402fbee51478efcce6ee90f0a19240b
|
|
| BLAKE2b-256 |
b36766b6394dba9d8e2a98df2c080a2f0e17a64e4123ed1a5dc01ed383ebfca6
|
File details
Details for the file cabal_file_parser-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cabal_file_parser-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
999bc49602c181bcc5bcce484cef7909fce350fd83de93b621e45d1e88aae08b
|
|
| MD5 |
f2e5141ebc0baa26a1163f608c1fce4c
|
|
| BLAKE2b-256 |
add69263986f15a8c5b0359d9e71f01cd23da92a9b47ac4b8d593befd8b7e325
|