Skip to content

Commit 7334d69

Browse files
committed
refactor: Add Astral/Uv Python project/package manager
Replace setup tools and configure to unified Uv with pyproject based setup. Set minimum default python to 3.10 as python 3.9 will be EOL middle of 2025. Project file pyproject.toml now replaced all linters for a unified solution using ruff and mypy and integrated pytest configurations. Signed-off-by: Helio Chissini de Castro <[email protected]>
1 parent 31990dd commit 7334d69

13 files changed

+3051
-894
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Buld and Publish
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
tags:
8+
- "v*"
9+
10+
jobs:
11+
build_and_upload:
12+
name: Build and Upload Archive
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0
20+
with:
21+
enable-cache: true
22+
23+
- name: Prepare Python Env
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version-file: "pyproject.toml"
27+
28+
- name: Build 📦 package
29+
run: |
30+
uv build
31+
shell: bash
32+
33+
- name: Upload artifacts
34+
if: github.event_name == 'push'
35+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2
36+
with:
37+
name: pypi_archives
38+
path: dist/python_inspector-*-py3-none-any.whl
39+
overwrite: true
40+
41+
create-gh-release:
42+
name: Create GH release
43+
runs-on: ubuntu-24.04
44+
needs: build_and_upload
45+
46+
steps:
47+
- name: Download built archives
48+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # 4.2.1
49+
with:
50+
name: pypi_archives
51+
path: dist
52+
53+
- name: Create GH release
54+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # 2.2.1
55+
with:
56+
draft: true
57+
files: dist/*
58+
59+
create-pypi-release:
60+
name: Create PyPI release
61+
needs: create-gh-release
62+
runs-on: ubuntu-24.04
63+
steps:
64+
- name: Install uv
65+
if: github.event_name == 'push'
66+
uses: astral-sh/setup-uv@22695119d769bdb6f7032ad67b9bca0ef8c4a174 # v5.4.0
67+
with:
68+
enable-cache: true
69+
70+
- name: Publish
71+
if: github.event_name == 'push'
72+
env:
73+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
74+
run: |
75+
uv publish dist/*

.github/workflows/pypi-release.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
default_language_version:
2+
python: python3.10
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v5.0.0
6+
hooks:
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
10+
- repo: https://github.com/pre-commit/mirrors-mypy
11+
rev: v1.15.0
12+
hooks:
13+
- id: mypy
14+
additional_dependencies:
15+
- pydantic
16+
- types-PyYaml==6.0.12.12
17+
- types-toml
18+
- types-requests
19+
args: [--config, pyproject.toml]
20+
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: "v0.11.2"
23+
hooks:
24+
- id: ruff
25+
26+
- repo: https://github.com/astral-sh/uv-pre-commit
27+
# uv version.
28+
rev: 0.6.10
29+
hooks:
30+
- id: uv-lock

README.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
python-inspector - inspect Python packages dependencies and metadata
2+
=====================================================================
3+
4+
Copyright (c) nexB Inc. and others.
5+
SPDX-License-Identifier: Apache-2.0
6+
Homepage: https://github.com/aboutcode-org/python-inspector and https://www.aboutcode.org/
7+
8+
``python-inspector`` is a collection of utilities to:
9+
10+
- resolve PyPI packages dependencies
11+
12+
- parse various requirements.txt files and setup.py files as input
13+
for resolving dependencies.
14+
15+
- parse additionally various manifests and packages files such as
16+
Pipfile, pyproject.toml, poetry.lock and setup.cfg and legacy and
17+
current metadata file formats for eggs, wheels and sdist. These
18+
have not been wired with the command line yet.
19+
20+
- query PyPI JSON and simple APIs for package information
21+
22+
It grew out of ScanCode toolkit to find and analyze PyPI archives and
23+
installed Python packages and their files.
24+
25+
The goal of python-inspector is to be a comprehensive library
26+
that can handle every style of Python package layouts, manifests and lockfiles.
27+
28+
Developing
29+
----------
30+
31+
- [Install Astral Uv](https://docs.astral.sh/uv/getting-started/installation/). For convenience:
32+
33+
- Isolated: `pipx install uv`
34+
- Regular: `pip install uv`
35+
36+
- (Optional) Configure pre-commit for commit linter checks:
37+
38+
```bash
39+
pre-commit install
40+
pre-commit install --hook-type commit-msg
41+
```
42+
43+
- Run from development. A virtual .venv will be created if you not have one
44+
45+
```bash
46+
uv run python-inspector --help
47+
```
48+
49+
Testing
50+
--------
51+
52+
- Run the tests. Tests have a special dependency group with their requirements for text exclusively:
53+
54+
```bash
55+
uv sync --group=test
56+
uv pytest -vvs
57+
```
58+
59+
- These are live tests to regenrate the tests with updated data run::
60+
61+
```bash
62+
uv sync
63+
PYINSP_REGEN_TEST_FIXTURES=yes uv run pytest -vvs
64+
```
65+
66+
Documentation
67+
-------------
68+
69+
```bash
70+
uv sync --all-groups
71+
hatch run validate-docs
72+
```
73+
74+
Usage
75+
--------
76+
77+
- Install with pip:
78+
79+
```bash
80+
pip install git+https://github.com/aboutcode-org/python-inspector
81+
```
82+
83+
- Run the command line utility with::
84+
85+
```bash
86+
python-inspector --help
87+
```
88+
89+
Its companion libraries are:
90+
91+
- ``pip-requirements-parser``, a mostly correct pip requirements parsing
92+
library extracted from pip.
93+
94+
- ``pkginfo2``, a safer fork of pkginfo to parse various installed and extracted
95+
package layouts and their metadata files.
96+
97+
- ``dparse2``, a safer fork of dparse to parse various package manifests
98+
99+
- ``resolvelib``, the library used by pip for dependency resolution
100+
101+
- ``packaging``, the official Python packaging utility library to process
102+
versions, specifiers, markers and other packaging data formats.
103+
104+
- ``importlib_metadata``, the official Python utility library to process
105+
installed site-packages and their metadata formats.
106+
107+
- ``packageurl-python`` to use Package URL to reference Python packages
108+
109+
Acknowledgements, Funding, Support and Sponsoring
110+
--------------------------------------------------------
111+
112+
This project is funded, supported and sponsored by:
113+
114+
- Generous support and contributions from users like you!
115+
- the European Commission NGI programme
116+
- the NLnet Foundation
117+
- the Swiss State Secretariat for Education, Research and Innovation (SERI)
118+
- Google, including the Google Summer of Code and the Google Seasons of Doc programmes
119+
- Mercedes-Benz Group
120+
- Microsoft and Microsoft Azure
121+
- AboutCode ASBL
122+
- nexB Inc.
123+
- Cariad SE
124+
125+
<p align="left">
126+
<a href="http://ec.europa.eu/index_en.htm" target="_blank"><img src="https://ngi.eu/wp-content/uploads/sites/77/2017/10/bandiera_stelle.png" height="40" alt="Europa logo"></a>
127+
&nbsp;&nbsp;&nbsp;
128+
<a href="https://commission.europa.eu/about-european-commission/departments-and-executive-agencies/communications-networks-content-and-technology_en" target="_blank"><img src="https://commission.europa.eu/themes/contrib/oe_theme/dist/ec/images/logo/positive/logo-ec--en.svg" height="40" alt="EC DG Connect logo"></a>
129+
</p>
130+
131+
<p align="left">
132+
<a href="https://ngi.eu35" target="_blank"><img src="https://ngi.eu/wp-content/uploads/thegem-logos/logo_8269bc6efcf731d34b6385775d76511d_1x.png" height="50" alt="NGI logo"></a>
133+
&nbsp;&nbsp;&nbsp;
134+
<a href="https://nlnet.nl" target="_blank"><img src="https://nlnet.nl/logo/banner.png" height="50" alt="NLnet foundation logo"></a>
135+
</p>
136+
137+
<p align="left">
138+
<a href="https://aboutcode.org/" target="_blank"><img src="https://aboutcode.org/wp-content/uploads/2023/10/AboutCode.svg" height="30" alt="AboutCode logo"></a>
139+
&nbsp;&nbsp;&nbsp;
140+
<a href="https://nexb.com" target="_blank"><img src="https://nexb.com/wp-content/uploads/2022/04/nexB.svg" height="30" alt="nexB logo"></a>
141+
</p>
142+
143+
This project was funded through the NGI0 Discovery Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 825322.
144+
145+
<p align="left">
146+
<a href="https://nlnet.nl/project/vulnerabilitydatabase/" target="_blank"><img src="https://nlnet.nl/image/logos/NGI0Discovery_tag.svg" height="40" alt="NGI Discovery logo"></a>
147+
</p>
148+
149+
This project was funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101092990.
150+
151+
<p align="left">
152+
<a href="https://nlnet.nl/project/Back2source-next/" target="_blank"><img src="https://nlnet.nl/image/logos/NGI0_tag.svg" height="40" alt="NGI Zero Core Logo"></a>
153+
</p>

0 commit comments

Comments
 (0)