Skip to main content

PyPI Python Versions Build Status Test Coverage Black License

pygount

Pygount is a command line tool to scan folders for source code files and count the number of source code lines in it. It is similar to tools like sloccount and cloc but uses the pygments package to analyze the source code and consequently can analyze any programming language supported by pygments.

The name is a combination of pygments and count.

Pygount is open source and distributed under the BSD license. The source code is available from https://github.com/roskakori/pygount.

Quickstart

For installation run

$ pip install pygount

or use uv to run it directly, for example:

$ uvx pygount --version

To get a list of line counts for a projects stored in a certain folder:

$ pygount ~/projects/example

To limit the analysis to certain file types identified by their suffix:

$ pygount --suffix=cfg,py,yml ~/projects/example

To get a summary of each programming language with sum counts and percentage:

$ pygount --format=summary ~/projects/example

To analyze a remote git repository directly without having to clone it first:

$ pygount --format=summary https://github.com/roskakori/pygount.git

You can pass a specific revision at the end of the remote URL:

$ pygount --format=summary https://github.com/roskakori/pygount.git/v1.5.1

This example results in the following summary output:

┏━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━┳━━━━━━━━━┳━━━━━━┓
┃ Language         ┃ Files ┃     % ┃ Code ┃    % ┃ Comment ┃    % ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━╇━━━━━━━━━╇━━━━━━┩
│ Python           │    18 │  47.4 │ 2132 │ 63.6 │     418 │ 12.5 │
│ TOML             │     2 │   5.3 │ 1204 │ 82.7 │       1 │  0.1 │
│ Batchfile        │     1 │   2.6 │   24 │ 68.6 │       1 │  2.9 │
│ Bash             │     2 │   5.3 │   12 │ 80.0 │       3 │ 20.0 │
│ Makefile         │     1 │   2.6 │    9 │ 45.0 │       7 │ 35.0 │
│ reStructuredText │     9 │  23.7 │    0 │  0.0 │     438 │ 50.2 │
│ Markdown         │     3 │   7.9 │    0 │  0.0 │      53 │ 49.1 │
│ Text only        │     2 │   5.3 │    0 │  0.0 │      24 │ 82.8 │
├──────────────────┼───────┼───────┼──────┼──────┼─────────┼──────┤
│ Sum              │    38 │ 100.0 │ 3381 │ 57.4 │     945 │ 16.1 │
└──────────────────┴───────┴───────┴──────┴──────┴─────────┴──────┘

Plenty of tools can post process SLOC information, for example the SLOCCount plug-in for the Jenkins continuous integration server.

A popular format for such tools is the XML format used by cloc, which pygount also supports and can store in an output file:

$ pygount --format=cloc-xml --out=cloc.xml ~/projects/example

To get a short description of all available command line options use:

$ pygount --help

For more information and examples read the documentation chapter on Usage.

Contributions

To report bugs, visit the issue tracker.

In case you want to play with the source code or contribute improvements, see CONTRIBUTING.

Version history

See CHANGES.

Release files for pygount 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygount 3.2.0
File Size Uploaded
pygount-3.2.0.tar.gz 983.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygount 3.2.0
File Interpreter ABI Platform
pygount-3.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / pygount-3.2.0.tar.gz

Download URL pygount-3.2.0.tar.gz
Size 983.2 kB
Tags Source
SHA-256 checksum
How to use checksums
27b03a6c6d791c4920003eec361a3c38ccd815637c51f5536efb9e47db1d452a
BLAKE2b-256 checksum
How to use checksums
d85c27b0bd8678ef5d7af67d925bbe22fb8f7e484151d284c52f0712c32a7ec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / pygount-3.2.0-py3-none-any.whl

Download URL pygount-3.2.0-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c037bf293d92ccc3ed5728329fe330f992901d933a7d278cb997bbbbeb0cf965
BLAKE2b-256 checksum
How to use checksums
f7566b92a522a91140977941ee212421760b4c6f84897fb2a3cc63cc934c7a23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

1 release file

1.3.0

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page