Skip to content

Commit 3e3a737

Browse files
committed
Convert to build as a module using hatchling
Converts the project to be structured so that it can be built into wheels using `python3 -m build`. The build system chosen is hatchling, because it is very simple to use. Note that now instead of using ./main.py to invoke the script, the module installs a command called `spec-parser` that is used instead
1 parent ca9541f commit 3e3a737

21 files changed

+82
-21
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@
33
Automagically process the model of the SPDXv3 specification to validate input or to generate stuff.
44

55

6+
## Installation
7+
8+
```
9+
# Create virtual environment
10+
python3 -m venv venv
11+
12+
# Activate virtual environment
13+
. ./venv/bin/activate
14+
15+
# Install module and dependencies in editable mode
16+
pip install -e .
17+
```
18+
619
## Usage
720

821
```
9-
python3 ./main.py -h
10-
usage: main.py [-h] [-d] [-f] [-n] [-q] [-v] [-V] input_dir [output_dir]
22+
$ spec-parser -h
23+
usage: spec-parser [-h] [-d] [-f] [-n] [-q] [-v] [-V] input_dir [output_dir]
1124
1225
Generate documentation from an SPDX 3.0 model
1326
@@ -30,15 +43,12 @@ Note that not all flags are functional yet.
3043
### Checking input
3144

3245
```
33-
python3 main.py -n some/where/.../model
46+
spec-parser -n some/where/.../model
3447
```
3548

36-
Note that no dependencies are needed.
37-
3849
### Generate output
3950
```
40-
python3 -m pip install -r requirements.txt
41-
python3 main.py some/where/.../model some/where/else/.../output_dir
51+
spec-parser some/where/.../model some/where/else/.../output_dir
4252
```
4353

4454

pyproject.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[project]
2+
name = "spec-parser"
3+
description = "Parse SPDX Spec Markdown Files"
4+
dynamic = ["version"]
5+
dependencies = [
6+
"Jinja2 == 3.1.2",
7+
"jsonpickle == 3.0.2",
8+
"rdflib == 7.0.0",
9+
]
10+
required-python = ">= 3.8"
11+
authors = [
12+
{name = "Joshua Watt", email = "[email protected]"},
13+
]
14+
readme = "README.md"
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Intended Audience :: Developers",
18+
"Topic :: Software Development :: Build Tools",
19+
"License :: OSI Approved :: MIT License",
20+
"Programming Language :: Python :: 3",
21+
"Programming Language :: Python :: 3.8",
22+
"Programming Language :: Python :: 3.9",
23+
"Programming Language :: Python :: 3.10",
24+
"Programming Language :: Python :: 3.11",
25+
"Programming Language :: Python :: 3.12",
26+
]
27+
28+
[project.urls]
29+
Homepage = "https://github.com/spdx/spec-parser"
30+
Repository = "https://github.com/spdx/spec-parser.git"
31+
Issues = "https://github.com/spdx/spec-parser/issues"
32+
33+
[project.scripts]
34+
spec-parser = "spec_parser.main:main"
35+
36+
[build-system]
37+
requires = ["hatchling"]
38+
build-backend = "hatchling.build"
39+
40+
[tool.hatch.version]
41+
path = "src/spec_parser/__init__.py"

requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.
File renamed without changes.

src/spec_parser/__main__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /usr/bin/env python3
2+
#
3+
# Copyright (c) 2024 Joshua Watt
4+
#
5+
# SPDX-License-Identifier: MIT
6+
7+
import sys
8+
9+
from .main import main
10+
11+
if __name__ == "__main__":
12+
sys.exit(main())
File renamed without changes.
File renamed without changes.

main.py renamed to src/spec_parser/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
# SPDX-License-Identifier: Apache-2.0
44

5-
from spec_parser import Model
6-
from runparams import RunParams
5+
from . import Model
6+
from .runparams import RunParams
77

8-
if __name__ == "__main__":
8+
def main():
99
cfg = RunParams()
1010

1111
m = Model(cfg.input_dir)
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)