Skip to content

Commit 1949eb9

Browse files
authored
Merge pull request #108 from RedHatProductSecurity/update-dev-setup
Upgrade dev setup and publishing to use uv
2 parents 7c1ba01 + ebb3245 commit 1949eb9

File tree

5 files changed

+115
-106
lines changed

5 files changed

+115
-106
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,6 @@ dmypy.json
106106

107107
# Editors
108108
.idea/
109+
110+
# uv
111+
uv.lock

MANIFEST.in

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

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ A library and a command line interface for the CVE Services API.
1313

1414
### Linux, MacOS, Windows
1515

16+
17+
#### pip
18+
1619
```bash
1720
python3 -m pip install --user cvelib
1821
```
@@ -32,6 +35,20 @@ To resolve this error, add the file path for where your `cve.exe` file resides (
3235
`C:\Users\<username>\AppData\Roaming\Python\Python39\Scripts`) to your `PATH` variable. You can
3336
edit your environment variables by searching *Edit the system environment variables* from the Start menu.
3437

38+
#### uv
39+
40+
To run the `cve` command using [uvx](https://docs.astral.sh/uv/guides/tools/), execute:
41+
42+
```
43+
uvx --from cvelib cve --help
44+
```
45+
46+
or to install it, execute:
47+
48+
```
49+
uv tool install cvelib
50+
```
51+
3552
### Podman/Docker
3653

3754
You can fetch a specific version of the `cvelib` library installed in a container image at
@@ -241,61 +258,66 @@ For more information, see the individual methods defined in the
241258

242259
## Development Setup
243260

261+
[uv](https://github.com/astral-sh/uv) is the recommended tool for local development:
262+
263+
```bash
264+
git clone https://github.com/RedHatProductSecurity/cvelib.git && cd cvelib
265+
uv sync --dev
266+
```
267+
268+
The `uv sync --dev` command will:
269+
- Create a virtual environment in `.venv/`
270+
- Install the project in editable mode
271+
- Install all development dependencies (test, dev groups)
272+
273+
To run all of the below commands without `uv run`, activate the virtual environment:
274+
244275
```bash
245-
git clone https://github.com/RedHatProductSecurity/cvelib.git
246-
cd cvelib
247-
python3 -m venv venv
248-
source venv/bin/activate
249-
pip install --upgrade pip
250-
pip install -e .
251-
pip install tox
252-
# If you want to use any of the dev dependencies outside of Tox, you can install them all with:
253-
pip install -e .[dev]
276+
source .venv/bin/activate
254277
```
255278

256279
To enable command autocompletion when using a virtual environment, add the line noted in `Command Autocompletion`
257-
above to your `venv/bin/activate` file, for example:
280+
above to your virtual environment's activate file:
258281

259282
```bash
260-
echo 'eval "$(_CVE_COMPLETE=bash_source cve)"' >> venv/bin/activate
283+
echo 'eval "$(_CVE_COMPLETE=bash_source cve)"' >> .venv/bin/activate
261284
```
262285

263286
This project uses [ruff formatter](https://docs.astral.sh/ruff/formatter/) for code formatting.
264287
To reformat the entire code base after you make any changes, run:
265288

266289
```bash
267-
ruff format .
290+
uv run ruff format .
268291
```
269292

270293
To sort all imports using [ruff's import sorting](https://docs.astral.sh/ruff/rules/#isort-i), run:
271294

272295
```bash
273-
ruff check --select I --fix .
296+
uv run ruff check --select I --fix .
274297
```
275298

276299
Running tests and linters:
277300

278301
```bash
279302
# Run all tests and format/lint checks (also run as a Github action)
280-
tox
303+
uv run tox
281304
# Run lint check only
282-
tox -e ruff-lint
305+
uv run tox -e ruff-lint
283306
# Run format check only
284-
tox -e ruff-format
307+
uv run tox -e ruff-format
285308
# Run tests using a specific version of Python
286-
tox -e py313
309+
uv run tox -e py313
287310
# Run a single test using a specific version of Python
288-
tox -e py313 -- tests/test_cli.py::test_cve_show
311+
uv run tox -e py313 -- tests/test_cli.py::test_cve_show
289312
```
290313

291314
Any changes in the commands, their options, or help texts must be reflected in the generated man pages. To refresh
292315
them, run:
293316

294317
```bash
295-
pip install click-man
296-
click-man cve
318+
uv run click-man cve
297319
# OR
298-
tox -e manpages
320+
uv run tox -e manpages
299321
```
300322

301323
---

pyproject.toml

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,72 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "cvelib"
7+
dynamic = ["version"]
8+
description = "A library and command line interface for the CVE Project services."
9+
readme = "README.md"
10+
license = "MIT"
11+
authors = [
12+
{ name = "Red Hat Product Security", email = "secalert@redhat.com" }
13+
]
14+
classifiers = [
15+
"Topic :: Security",
16+
"License :: OSI Approved :: MIT License",
17+
"Programming Language :: Python :: 3",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
]
24+
requires-python = ">=3.9"
25+
dependencies = [
26+
"click>=7.1.2",
27+
"requests>=2.32.0",
28+
"jsonschema>=4.7.2",
29+
]
30+
31+
[project.optional-dependencies]
32+
test = [
33+
"pytest",
34+
]
35+
dev = [
36+
"pytest",
37+
"ruff",
38+
"click-man",
39+
"mypy",
40+
"tox",
41+
"types-click",
42+
"types-requests",
43+
"types-jsonschema",
44+
]
45+
46+
[project.scripts]
47+
cve = "cvelib.cli:cli"
48+
49+
[project.urls]
50+
Homepage = "https://github.com/RedHatProductSecurity/cvelib"
51+
Repository = "https://github.com/RedHatProductSecurity/cvelib"
52+
53+
[tool.hatch.version]
54+
path = "cvelib/__init__.py"
55+
56+
[tool.hatch.build.targets.sdist]
57+
include = [
58+
"/cvelib",
59+
"/man",
60+
"/tests",
61+
"LICENSE",
62+
"README.md",
63+
"CHANGELOG.md",
64+
"SECURITY.md",
65+
]
66+
67+
[tool.hatch.build.targets.wheel]
68+
packages = ["cvelib"]
69+
170
[tool.ruff]
271
line-length = 100
372

@@ -11,11 +80,3 @@ warn_unused_configs = true
1180
warn_unreachable = true
1281
warn_no_return = true
1382
warn_unused_ignores = true
14-
15-
[build-system]
16-
requires = [
17-
"setuptools >= 40.9.0",
18-
"wheel",
19-
"collective.checkdocs",
20-
]
21-
build-backend = "setuptools.build_meta"

setup.py

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

0 commit comments

Comments
 (0)