pkgdb 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,73 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.4]
9
+
10
+ ### Added
11
+
12
+ - HTML report enhancements:
13
+ - `pkgdb report <package>` generates detailed single-package report with download stats, history chart, Python version and OS distribution pie charts
14
+ - `pkgdb report -e` includes aggregated Python version and OS distribution summary in the main report
15
+ - New functions: `make_svg_pie_chart`, `aggregate_env_stats`, `generate_package_html_report`
16
+ - 14 new tests for pie charts, environment aggregation, and package reports (69 total)
17
+
18
+ ## [0.1.3]
19
+
20
+ ### Added
21
+
22
+ - `stats` command for detailed package statistics:
23
+ - Python version distribution with visual bars
24
+ - Operating system breakdown (Linux, Windows, Darwin)
25
+ - Download summary (total, month, week, day)
26
+ - New functions: `fetch_python_versions`, `fetch_os_stats`
27
+
28
+ ### Note
29
+
30
+ - Per-version (package version) downloads not available through pypistats API
31
+
32
+ ## [0.1.2]
33
+
34
+ ### Added
35
+
36
+ - `export` command with support for multiple formats:
37
+ - CSV (`pkgdb export -f csv`)
38
+ - JSON (`pkgdb export -f json`)
39
+ - Markdown (`pkgdb export -f markdown`)
40
+ - Export to file with `-o` option or stdout by default
41
+ - New functions: `export_csv`, `export_json`, `export_markdown`
42
+
43
+ ## [0.1.1]
44
+
45
+ ### Added
46
+
47
+ - `history` command to view historical stats for a specific package
48
+ - Growth metrics (month-over-month percentage change) in `list` output
49
+ - Sparkline trend indicators in `list` output
50
+ - Time-series chart in HTML report showing downloads over time (top 5 packages)
51
+ - New functions: `get_package_history`, `get_all_history`, `calculate_growth`, `make_sparkline`
52
+
53
+ ### Changed
54
+
55
+ - `list` command now shows trend sparklines and growth percentages
56
+ - HTML report now includes "Downloads Over Time" chart when historical data available
57
+
58
+ ## [0.1.0]
59
+
60
+ ### Added
61
+
62
+ - Initial release
63
+ - CLI commands: `fetch`, `list`, `report`, `update`
64
+ - SQLite database storage for historical stats
65
+ - HTML report generation with SVG visualizations
66
+ - YAML-based package configuration (`packages.yml`)
67
+ - Support for custom database and packages file paths
68
+ - Pytest test suite with 24 tests covering:
69
+ - Database operations
70
+ - Package loading from YAML
71
+ - Statistics storage and retrieval
72
+ - HTML report generation
73
+ - CLI argument parsing
pkgdb-0.1.0/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shakeeb Alireza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
+ furnished to do so, subject to the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
pkgdb-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,169 @@
1
+ Metadata-Version: 2.4
2
+ Name: pkgdb
3
+ Version: 0.1.0
4
+ Summary: Track, store and query your PyPI package download statistics
5
+ Keywords: pypi,statistics,downloads,analytics,cli
6
+ Author: Shakeeb Alireza
7
+ Author-email: Shakeeb Alireza <shakfu@users.noreply.github.com>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: BSD License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: System :: Software Distribution
22
+ Requires-Dist: pypistats>=1.12.0
23
+ Requires-Dist: pyyaml>=6.0.3
24
+ Requires-Dist: tabulate>=0.9.0
25
+ Requires-Python: >=3.10
26
+ Project-URL: Homepage, https://github.com/shakfu/pkgdb
27
+ Project-URL: Repository, https://github.com/shakfu/pkgdb
28
+ Project-URL: Issues, https://github.com/shakfu/pkgdb/issues
29
+ Description-Content-Type: text/markdown
30
+
31
+ # pkgdb
32
+
33
+ Track PyPI package download statistics. Fetches download stats via the pypistats API, stores historical data in SQLite, and generates HTML reports with charts.
34
+
35
+ ## Installation
36
+
37
+ ```sh
38
+ pip install pkgdb
39
+ ```
40
+
41
+ To build:
42
+
43
+ Requires Python 3.10+. Uses [uv](https://github.com/astral-sh/uv) for dependency management.
44
+
45
+ ```bash
46
+ uv sync
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ### Configure packages
52
+
53
+ Edit `packages.yml` to list the packages you want to track:
54
+
55
+ ```yaml
56
+ published:
57
+ - my-package
58
+ - another-package
59
+ ```
60
+
61
+ ### Commands
62
+
63
+ ```bash
64
+ # Fetch latest stats from PyPI and store in database
65
+ pkgdb fetch
66
+
67
+ # Display stats in terminal (includes trend sparklines and growth %)
68
+ pkgdb list
69
+
70
+ # Show historical stats for a specific package
71
+ pkgdb history <package-name>
72
+
73
+ # Generate HTML report with charts (opens in browser)
74
+ pkgdb report
75
+
76
+ # Generate detailed HTML report for a single package
77
+ pkgdb report <package-name>
78
+
79
+ # Include environment summary (Python versions, OS) in report
80
+ pkgdb report -e
81
+
82
+ # Export stats in various formats
83
+ pkgdb export -f csv # CSV format (default)
84
+ pkgdb export -f json # JSON format
85
+ pkgdb export -f markdown # Markdown table
86
+
87
+ # Show detailed stats for a package (Python versions, OS breakdown)
88
+ pkgdb stats <package-name>
89
+
90
+ # Fetch stats and generate report in one step
91
+ pkgdb update
92
+ ```
93
+
94
+ ### Options
95
+
96
+ ```bash
97
+ # Use custom database file
98
+ pkgdb -d custom.db fetch
99
+
100
+ # Use custom packages file
101
+ pkgdb -p custom.yml fetch
102
+
103
+ # Specify output file for report
104
+ pkgdb report -o custom-report.html
105
+
106
+ # Limit history output to N days
107
+ pkgdb history my-package -n 14
108
+
109
+ # Export to file instead of stdout
110
+ pkgdb export -f json -o stats.json
111
+ ```
112
+
113
+ ## Architecture
114
+
115
+ Single-file CLI application with seven commands:
116
+
117
+ - **fetch**: Calls `pypistats.recent()` and `pypistats.overall()` for each package, stores results in SQLite
118
+ - **list**: Queries latest stats per package with trend sparklines and growth metrics
119
+ - **history**: Shows historical data for a specific package over time
120
+ - **report**: Generates self-contained HTML report with SVG charts (bar charts + time-series). With `-e` flag, includes Python version and OS distribution summary. With package argument, generates detailed single-package report
121
+ - **export**: Exports stats in CSV, JSON, or Markdown format
122
+ - **stats**: Shows detailed breakdown (Python versions, OS) for a single package
123
+ - **update**: Runs fetch then report
124
+
125
+ ### Data flow
126
+
127
+ ```
128
+ packages.yml -> pypistats API -> SQLite (pkg.db) -> HTML/terminal output
129
+ ```
130
+
131
+ ### Database schema
132
+
133
+ The `package_stats` table stores:
134
+ - `package_name`: Package identifier
135
+ - `fetch_date`: Date stats were fetched (YYYY-MM-DD)
136
+ - `last_day`, `last_week`, `last_month`: Recent download counts
137
+ - `total`: Total downloads (excluding mirrors)
138
+
139
+ Stats are upserted per package per day, so running fetch multiple times on the same day updates rather than duplicates.
140
+
141
+ ## Files
142
+
143
+ - `pkgdb.py`: Main CLI application
144
+ - `packages.yml`: Package list configuration
145
+ - `pkg.db`: SQLite database (auto-created)
146
+ - `report.html`: Generated HTML report (default output)
147
+
148
+ ## Development
149
+
150
+ ```bash
151
+ # Install dev dependencies
152
+ uv sync
153
+
154
+ # Run tests
155
+ pytest
156
+
157
+ # Run tests with verbose output
158
+ pytest -v
159
+ ```
160
+
161
+ ## Dependencies
162
+
163
+ Runtime:
164
+ - `pypistats`: PyPI download statistics API client
165
+ - `pyyaml`: YAML configuration parsing
166
+ - `tabulate`: Terminal table formatting
167
+
168
+ Development:
169
+ - `pytest`: Testing framework
pkgdb-0.1.0/README.md ADDED
@@ -0,0 +1,139 @@
1
+ # pkgdb
2
+
3
+ Track PyPI package download statistics. Fetches download stats via the pypistats API, stores historical data in SQLite, and generates HTML reports with charts.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pip install pkgdb
9
+ ```
10
+
11
+ To build:
12
+
13
+ Requires Python 3.10+. Uses [uv](https://github.com/astral-sh/uv) for dependency management.
14
+
15
+ ```bash
16
+ uv sync
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Configure packages
22
+
23
+ Edit `packages.yml` to list the packages you want to track:
24
+
25
+ ```yaml
26
+ published:
27
+ - my-package
28
+ - another-package
29
+ ```
30
+
31
+ ### Commands
32
+
33
+ ```bash
34
+ # Fetch latest stats from PyPI and store in database
35
+ pkgdb fetch
36
+
37
+ # Display stats in terminal (includes trend sparklines and growth %)
38
+ pkgdb list
39
+
40
+ # Show historical stats for a specific package
41
+ pkgdb history <package-name>
42
+
43
+ # Generate HTML report with charts (opens in browser)
44
+ pkgdb report
45
+
46
+ # Generate detailed HTML report for a single package
47
+ pkgdb report <package-name>
48
+
49
+ # Include environment summary (Python versions, OS) in report
50
+ pkgdb report -e
51
+
52
+ # Export stats in various formats
53
+ pkgdb export -f csv # CSV format (default)
54
+ pkgdb export -f json # JSON format
55
+ pkgdb export -f markdown # Markdown table
56
+
57
+ # Show detailed stats for a package (Python versions, OS breakdown)
58
+ pkgdb stats <package-name>
59
+
60
+ # Fetch stats and generate report in one step
61
+ pkgdb update
62
+ ```
63
+
64
+ ### Options
65
+
66
+ ```bash
67
+ # Use custom database file
68
+ pkgdb -d custom.db fetch
69
+
70
+ # Use custom packages file
71
+ pkgdb -p custom.yml fetch
72
+
73
+ # Specify output file for report
74
+ pkgdb report -o custom-report.html
75
+
76
+ # Limit history output to N days
77
+ pkgdb history my-package -n 14
78
+
79
+ # Export to file instead of stdout
80
+ pkgdb export -f json -o stats.json
81
+ ```
82
+
83
+ ## Architecture
84
+
85
+ Single-file CLI application with seven commands:
86
+
87
+ - **fetch**: Calls `pypistats.recent()` and `pypistats.overall()` for each package, stores results in SQLite
88
+ - **list**: Queries latest stats per package with trend sparklines and growth metrics
89
+ - **history**: Shows historical data for a specific package over time
90
+ - **report**: Generates self-contained HTML report with SVG charts (bar charts + time-series). With `-e` flag, includes Python version and OS distribution summary. With package argument, generates detailed single-package report
91
+ - **export**: Exports stats in CSV, JSON, or Markdown format
92
+ - **stats**: Shows detailed breakdown (Python versions, OS) for a single package
93
+ - **update**: Runs fetch then report
94
+
95
+ ### Data flow
96
+
97
+ ```
98
+ packages.yml -> pypistats API -> SQLite (pkg.db) -> HTML/terminal output
99
+ ```
100
+
101
+ ### Database schema
102
+
103
+ The `package_stats` table stores:
104
+ - `package_name`: Package identifier
105
+ - `fetch_date`: Date stats were fetched (YYYY-MM-DD)
106
+ - `last_day`, `last_week`, `last_month`: Recent download counts
107
+ - `total`: Total downloads (excluding mirrors)
108
+
109
+ Stats are upserted per package per day, so running fetch multiple times on the same day updates rather than duplicates.
110
+
111
+ ## Files
112
+
113
+ - `pkgdb.py`: Main CLI application
114
+ - `packages.yml`: Package list configuration
115
+ - `pkg.db`: SQLite database (auto-created)
116
+ - `report.html`: Generated HTML report (default output)
117
+
118
+ ## Development
119
+
120
+ ```bash
121
+ # Install dev dependencies
122
+ uv sync
123
+
124
+ # Run tests
125
+ pytest
126
+
127
+ # Run tests with verbose output
128
+ pytest -v
129
+ ```
130
+
131
+ ## Dependencies
132
+
133
+ Runtime:
134
+ - `pypistats`: PyPI download statistics API client
135
+ - `pyyaml`: YAML configuration parsing
136
+ - `tabulate`: Terminal table formatting
137
+
138
+ Development:
139
+ - `pytest`: Testing framework
@@ -0,0 +1,56 @@
1
+ [project]
2
+ name = "pkgdb"
3
+ version = "0.1.0"
4
+ description = "Track, store and query your PyPI package download statistics"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = "MIT"
8
+ license-files = [ "LICENSE" ]
9
+ authors = [
10
+ { name = "Shakeeb Alireza", email = "shakfu@users.noreply.github.com" }
11
+ ]
12
+ keywords = ["pypi", "statistics", "downloads", "analytics", "cli"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: BSD License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
+ "Topic :: System :: Software Distribution",
26
+ ]
27
+ dependencies = [
28
+ "pypistats>=1.12.0",
29
+ "pyyaml>=6.0.3",
30
+ "tabulate>=0.9.0",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/shakfu/pkgdb"
35
+ Repository = "https://github.com/shakfu/pkgdb"
36
+ Issues = "https://github.com/shakfu/pkgdb/issues"
37
+
38
+ [project.scripts]
39
+ pkgdb = "pkgdb:main"
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "build>=1.2.0",
44
+ "mypy>=1.19.1",
45
+ "pytest>=9.0.2",
46
+ "ruff>=0.14.13",
47
+ "twine>=6.1.0",
48
+ "types-PyYAML>=6.0.0",
49
+ ]
50
+
51
+ [build-system]
52
+ requires = ["uv_build>=0.9.26,<0.10.0"]
53
+ build-backend = "uv_build"
54
+
55
+ [tool.uv.build-backend]
56
+ source-include = ["CHANGELOG.md", "tests"]