Skip to content

Commit 47105e9

Browse files
KOLANICHjayvdb
authored andcommitted
Moved the metadata into setup.cfg.
Added pyproject.toml. Renamed console_scripts because their names are too generic to have this package installed into system. Fixed the names of the commands within the docstrings. Versions are now fetched from git tags. Excluded the dirs that are not meant to go into wheels, like `examples/`. Added the things jayvdb has suggested into the metadata. Co-authored-by: John Vandenberg <[email protected]> Signed-off-by: KOLANICH <[email protected]>
1 parent 30c1f4e commit 47105e9

File tree

8 files changed

+86
-79
lines changed

8 files changed

+86
-79
lines changed

.circleci/config.yml

+17-1
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,18 @@ commands:
2222
pyenv global << parameters.python_version >>
2323
python --version
2424
25+
update_packaging_tools:
26+
steps:
27+
- run: |
28+
python -m pip install --upgrade pip
29+
- run: |
30+
python -m pip install --upgrade setuptools wheel setuptools_scm build
31+
2532
install_run_tests:
2633
steps:
2734
- run: |
28-
python setup.py install
35+
python -m build -nwx .
36+
python -m pip install --upgrade ./dist/*.whl
2937
python -m pip install pytest
3038
- run: pytest
3139

@@ -38,6 +46,7 @@ jobs:
3846
- checkout
3947
- mac_install_python:
4048
python_version: "3.7.10"
49+
- update_packaging_tools
4150
- install_run_tests
4251

4352

@@ -49,6 +58,7 @@ jobs:
4958
- checkout
5059
- mac_install_python:
5160
python_version: "3.8.10"
61+
- update_packaging_tools
5262
- install_run_tests
5363

5464
mac_python_3_9:
@@ -59,6 +69,7 @@ jobs:
5969
- checkout
6070
- mac_install_python:
6171
python_version: "3.9.5"
72+
- update_packaging_tools
6273
- install_run_tests
6374

6475
mac_python_3_10:
@@ -69,34 +80,39 @@ jobs:
6980
- checkout
7081
- mac_install_python:
7182
python_version: "3.10.6"
83+
- update_packaging_tools
7284
- install_run_tests
7385

7486
linux_python_3_7:
7587
docker:
7688
- image: python:3.7
7789
steps:
7890
- checkout
91+
- update_packaging_tools
7992
- install_run_tests
8093

8194
linux_python_3_8:
8295
docker:
8396
- image: python:3.8
8497
steps:
8598
- checkout
99+
- update_packaging_tools
86100
- install_run_tests
87101

88102
linux_python_3_9:
89103
docker:
90104
- image: python:3.9
91105
steps:
92106
- checkout
107+
- update_packaging_tools
93108
- install_run_tests
94109

95110
linux_python_3_10:
96111
docker:
97112
- image: python:3.10
98113
steps:
99114
- checkout
115+
- update_packaging_tools
100116
- install_run_tests
101117

102118
workflows:

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,31 @@ This is the result of an initial GSoC contribution by @[ah450](https://github.co
5050
## Command-line usage:
5151

5252
1. **PARSER** (for parsing any format):
53-
* Use `parser --file <filename>` where `<filename>` is the location of the file.
54-
Try running: `parser --file data/SPDXRdfExample.rdf`.
53+
* Use `pyspdxtools_parser --file <filename>` where `<filename>` is the location of the file.
54+
Try running: `pyspdxtools_parser --file data/SPDXRdfExample.rdf`.
5555

56-
* Or you can use `parser` only, and it will automatically prompt/ask for `filename`.
56+
* Or you can use `pyspdxtools_parser` only, and it will automatically prompt/ask for `filename`.
5757

58-
* For help use `parser --help`
58+
* For help use `pyspdxtools_parser --help`
5959

6060

6161
2. **CONVERTOR** (for converting one format to another):
6262
* If I/O formats are known:
6363

64-
* Use `convertor --infile/-i <input_file> --outfile/-o <output_file>` where `<input_file>` is the location of the file to be converted
64+
* Use `pyspdxtools_convertor --infile/-i <input_file> --outfile/-o <output_file>` where `<input_file>` is the location of the file to be converted
6565
(Note: only RDF and Tag formatted supported) and `<output_file>` is the location of the output file.
66-
Try running : `convertor --infile data/SPDXRdfExample.rdf --outfile output.json`
66+
Try running : `pyspdxtools_convertor --infile data/SPDXRdfExample.rdf --outfile output.json`
6767

6868
* If I/O formats are not known:
6969

70-
* Use `convertor --from/-f <input_format> <input_file> --to/-t <output_format> <output_file>` where `<input_format>` is the manually entered format of the input file (can be either rdf or tag)
70+
* Use `pyspdxtools_convertor --from/-f <input_format> <input_file> --to/-t <output_format> <output_file>` where `<input_format>` is the manually entered format of the input file (can be either rdf or tag)
7171
and `<out_format>` (can be tag, rdf, json, yaml, xml) is the manually entered format of the output file.
72-
Try running : `convertor --from tag data/SPDXTagExample.in --to yaml output.out`
72+
Try running : `pyspdxtools_convertor --from tag data/SPDXTagExample.in --to yaml output.out`
7373

7474
* If one of the formats is known and the other is not, you can use a mixture of the above two points.
75-
Example: `convertor -f rdf data/SPDXRdfExample.xyz -o output.xml`
75+
Example: `pyspdxtools_convertor -f rdf data/SPDXRdfExample.xyz -o output.xml`
7676

77-
* For help use `convertor --help`
77+
* For help use `pyspdxtools_convertor --help`
7878

7979

8080
# Installation

appveyor.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ environment:
1010

1111
install:
1212
- "%PYTHON_EXE% --version"
13-
- "%PYTHON_EXE% setup.py install"
14-
- "%PYTHON_EXE% -m pip install pytest"
13+
- "%PYTHON_EXE% -m pip install --upgrade pip"
14+
- "%PYTHON_EXE% -m pip install --upgrade setuptools setuptools_scm wheel build pytest"
15+
- "%PYTHON_EXE% -m pip install --upgrade -e ."
1516

1617
build: off
1718

pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=44", "wheel", "setuptools_scm[toml]>=3.4.3"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
git_describe_command = ["git", "describe", "--dirty", "--tags", "--long", "--match", "v[0-9]*"] # `python3.6` tag falsely matches to the default one, clrearly a bug in setuptools_scm

setup.cfg

+41
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,46 @@
11
[metadata]
2+
name = spdx-tools
3+
author = Ahmed H. Ismail
4+
author_email = [email protected]
5+
maintainer = Philippe Ombredanne, SPDX group at the Linux Foundation and others
6+
maintainer_email = [email protected]
7+
license = Apache-2.0
28
license_file = LICENSE
9+
description = SPDX parser and tools.
10+
url = https://github.com/spdx/tools-python
11+
long_description = file: README.md
12+
long_description_content_type = text/markdown
13+
classifiers =
14+
Intended Audience :: Developers
15+
Intended Audience :: System Administrators
16+
License :: OSI Approved :: Apache Software License
17+
Programming Language :: Python :: 3.6
18+
Programming Language :: Python :: 3.7
19+
Programming Language :: Python :: 3.8
20+
Programming Language :: Python :: 3.9
21+
Programming Language :: Python :: 3.10
22+
Programming Language :: Python :: 3.11
23+
24+
[options]
25+
zip_safe = False # because of the uses of __file__: https://github.com/spdx/tools-python/issues/257
26+
packages = find:
27+
install_requires = ply; rdflib; click; pyyaml; xmltodict
28+
include_package_data = True
29+
python_requires = >=3.6
30+
test_suite = setup.test_suite
31+
32+
[options.extras_require]
33+
test = pytest
34+
35+
[options.packages.find]
36+
include =
37+
spdx
38+
spdx.*
39+
40+
[options.entry_points]
41+
console_scripts =
42+
pyspdxtools_convertor = spdx.cli_tools.convertor:main
43+
pyspdxtools_parser = spdx.cli_tools.parser:main
344

445
[aliases]
546
release = clean --all sdist --formats=gztar bdist_wheel

setup.py

+3-60
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,6 @@
1-
#!/usr/bin/env python
2-
# -*- encoding: utf-8 -*-
1+
#!/usr/bin/python
32

43
from setuptools import setup
5-
import unittest
64

7-
8-
def test_suite():
9-
return unittest.TestLoader().discover('tests', pattern='test_*.py')
10-
11-
12-
with open('README.md', 'r') as fh:
13-
long_description = fh.read()
14-
15-
setup(
16-
name='spdx-tools',
17-
version='0.7.0a3',
18-
description='SPDX parser and tools.',
19-
long_description=long_description,
20-
long_description_content_type='text/markdown',
21-
packages=[
22-
'spdx',
23-
'spdx.parsers',
24-
'spdx.parsers.lexers',
25-
'spdx.writers',
26-
'examples',
27-
],
28-
include_package_data=True,
29-
zip_safe=False,
30-
test_suite='setup.test_suite',
31-
install_requires=[
32-
'ply',
33-
'rdflib',
34-
'click',
35-
'pyyaml',
36-
'xmltodict',
37-
],
38-
tests_require=[
39-
'pytest',
40-
],
41-
python_requires='>=3.6',
42-
entry_points={
43-
'console_scripts': [
44-
'convertor = spdx.cli_tools.convertor:main',
45-
'parser = spdx.cli_tools.parser:main',
46-
],
47-
},
48-
49-
author='Ahmed H. Ismail',
50-
author_email='[email protected]',
51-
maintainer='Philippe Ombredanne, SPDX group at the Linux Foundation and others',
52-
maintainer_email='[email protected]',
53-
url='https://github.com/spdx/tools-python',
54-
license='Apache-2.0',
55-
classifiers=[
56-
'Intended Audience :: Developers',
57-
'License :: OSI Approved :: Apache Software License',
58-
'Programming Language :: Python :: 3.6',
59-
'Programming Language :: Python :: 3.7',
60-
'Programming Language :: Python :: 3.8',
61-
'Programming Language :: Python :: 3.9',
62-
]
63-
)
5+
if __name__ == "__main__":
6+
setup()

spdx/cli_tools/convertor.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def determine_infile_and_outfile(infile, outfile, src, from_, to):
2626
if infile is not None and outfile is not None:
2727
"""
2828
when the CLI is of given format:
29-
' convertor ---infile <input_file> ---outfile <output_file>.
29+
' pyspdxtools_convertor ---infile <input_file> ---outfile <output_file>.
3030
"""
3131
return infile, outfile
3232

3333
elif infile is None and outfile is None and len(src) == 2:
3434
"""
35-
' convertor -f/--from <type> <input_file> -t/--to <type> <output_file>.
35+
' pyspdxtools_convertor -f/--from <type> <input_file> -t/--to <type> <output_file>.
3636
"""
3737
infile = src[0]
3838
outfile = src[1]
@@ -47,7 +47,7 @@ def determine_infile_and_outfile(infile, outfile, src, from_, to):
4747

4848
elif infile is None and outfile is not None:
4949
"""
50-
' convertor -f/--from <type> <input_file> --outfile <output_file> '
50+
' pyspdxtools_convertor -f/--from <type> <input_file> --outfile <output_file> '
5151
"""
5252
infile = src[0]
5353
if from_ is not None:
@@ -57,7 +57,7 @@ def determine_infile_and_outfile(infile, outfile, src, from_, to):
5757

5858
elif infile is not None and outfile is None:
5959
"""
60-
' convertor --infile <input_file> -t/--to <type> <output_file>'
60+
' pyspdxtools_convertor --infile <input_file> -t/--to <type> <output_file>'
6161
"""
6262
outfile = src[0]
6363
if to is not None:
@@ -88,7 +88,7 @@ def main(infile, outfile, src, from_, to, force):
8888
"""
8989
CLI-TOOL for converting a RDF or TAG file to RDF, JSON, YAML, TAG or XML format.
9090
91-
To use : run 'convertor -f <from_TYPE> <input file> -t <to_TYPE> <output_file>' command on terminal or use ' convertor --infile <input file name> --outfile <output file name> '
91+
To use : run 'pyspdxtools_convertor -f <from_TYPE> <input file> -t <to_TYPE> <output_file>' command on terminal or use ' pyspdxtools_convertor --infile <input file name> --outfile <output file name> '
9292
9393
"""
9494
try:

spdx/cli_tools/parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def main(file, force):
2525
"""
2626
COMMAND-LINE TOOL for parsing file of RDF, XML, JSON, YAML and XML format.
2727
28-
To use : run `parser` using terminal or run `parser --file <file name>`
28+
To use : run `pyspdxtools_parser` using terminal or run `pyspdxtools_parser --file <file name>`
2929
3030
"""
3131
doc, errors = parse_file(file)

0 commit comments

Comments
 (0)