diff --git a/.gitignore b/.gitignore index a2064dc..0dde76c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,9 @@ docs/_build # Virtual Env # ###################### venv + +# Setuptools # +###################### +build +dist +*.egg-info diff --git a/README.md b/README.md index b487bcc..3627a73 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,24 @@ Automagically process the model of the SPDXv3 specification to validate input or to generate stuff. +## Build / Install + +``` +python3 -m pip install build +python3 -m build +``` + +This creates a wheel file in `dist` that can be installed. Alternatively, +run setup.py to install: + +``` +python3 ./setup.py install +``` ## Usage ``` -python3 ./main.py -h +spec-parser -h usage: main.py [-h] [-d] [-f] [-n] [-q] [-v] [-V] input_dir [output_dir] Generate documentation from an SPDX 3.0 model @@ -30,15 +43,14 @@ Note that not all flags are functional yet. ### Checking input ``` -python3 main.py -n some/where/.../model +spec-parser -n some/where/.../model ``` Note that no dependencies are needed. ### Generate output ``` -python3 -m pip install -r requirements.txt -python3 main.py some/where/.../model some/where/else/.../output_dir +spec-parser some/where/.../model some/where/else/.../output_dir ``` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..62b4dfc --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = ["setuptools>=61.0", "build", "wheel"] + +[project] +name = "spec_parser" +version = "0.1.0" +dependencies = [ + "Jinja2", + "jsonpickle", + "rdflib" +] + +[project.scripts] +spec-parser = "spec_parser.main:main" + +[tool.setuptools.package-data] +"spec_parser.templates.mkdocs" = ["*.j2"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 8aaf7a0..0000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Jinja2==3.1.2 -jsonpickle==3.0.2 -rdflib==7.0.0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8bf1ba9 --- /dev/null +++ b/setup.py @@ -0,0 +1,2 @@ +from setuptools import setup +setup() diff --git a/main.py b/spec_parser/main.py similarity index 79% rename from main.py rename to spec_parser/main.py index f4d61f9..9affb07 100644 --- a/main.py +++ b/spec_parser/main.py @@ -3,12 +3,16 @@ # SPDX-License-Identifier: Apache-2.0 from spec_parser import Model -from runparams import RunParams +from spec_parser.runparams import RunParams -if __name__ == "__main__": + +def main(): cfg = RunParams() m = Model(cfg.input_dir) if not cfg.opt_nooutput: m.gen_all(cfg.output_dir, cfg) + +if __name__ == "__main__": + main() diff --git a/runparams.py b/spec_parser/runparams.py similarity index 100% rename from runparams.py rename to spec_parser/runparams.py