Skip to content

Commit f079bcf

Browse files
committed
Improve scaffolding
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 3158ffa commit f079bcf

5 files changed

Lines changed: 118 additions & 14 deletions

File tree

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright (c) nexB Inc. and others. All rights reserved.
4+
# ScanCode is a trademark of nexB Inc.
5+
# SPDX-License-Identifier: Apache-2.0
6+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
7+
# See https://github.com/nexB/python-inspector for support or download.
8+
# See https://aboutcode.org for more information about nexB OSS projects.
9+
#
10+
11+
# Python version can be specified with `$ PYTHON_EXE=python3.x make conf`
12+
VENV=venv
13+
ACTIVATE?=. ${VENV}/bin/activate;
14+
15+
dev:
16+
@echo "-> Configure the dev envt."
17+
./configure --dev
18+
19+
isort:
20+
@echo "-> Apply isort changes to ensure proper imports ordering"
21+
${VENV}/bin/isort --sl src tests
22+
23+
black:
24+
@echo "-> Apply black code formatter"
25+
${VENV}/bin/black -l 100 src tests
26+
27+
doc8:
28+
@echo "-> Run doc8 validation"
29+
@${ACTIVATE} doc8 --max-line-length 100 --ignore-path docs/_build/ --quiet docs/
30+
31+
valid: isort black
32+
33+
check:
34+
@echo "-> Run pycodestyle (PEP8) validation"
35+
@${ACTIVATE} pycodestyle --max-line-length=100 --exclude=venv,lib,thirdparty,docs,migrations,settings.py .
36+
@echo "-> Run isort imports ordering validation"
37+
@${ACTIVATE} isort --sl --check-only .
38+
@echo "-> Run black validation"
39+
@${ACTIVATE} black --check -l 100
40+
41+
clean:
42+
@echo "-> Clean the Python env"
43+
./configure --clean
44+
45+
test:
46+
@echo "-> Run the test suite"
47+
${VENV}/bin/pytest -vvs
48+
49+
docs:
50+
rm -rf docs/_build/
51+
@${ACTIVATE} sphinx-build docs/ docs/_build/
52+
53+
.PHONY: conf dev check valid black isort clean test docs

setup.cfg

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,27 @@ classifiers =
2020
Topic :: Utilities
2121

2222
keywords =
23-
utilities
23+
open source
24+
scan
25+
package
26+
dependency
27+
pypi
28+
python
29+
SBOM
30+
sca
31+
dependencies
32+
dependency resolution
33+
resolver
34+
resolvelib
35+
pip
36+
requirements
2437

2538
license_files =
2639
apache-2.0.LICENSE
2740
NOTICE
2841
AUTHORS.rst
2942
CHANGELOG.rst
43+
CODE_OF_CONDUCT.rst
3044

3145
[options]
3246
package_dir =
@@ -40,27 +54,36 @@ setup_requires = setuptools_scm[toml] >= 4
4054
python_requires = >=3.6.*
4155

4256
install_requires =
43-
attr
44-
commoncode
45-
dparse2
57+
attrs >= 18.1, !=20.1.0
58+
click >= 6.7, !=7.0
59+
colorama >= 0.3.9
60+
commoncode >= 30.0.0
61+
dparse2 >= 0.6.1
4662
importlib_metadata
47-
packageurl_python
48-
packaging
49-
pip_requirements_parser
50-
pkginfo2
51-
requests
52-
saneyaml
63+
packageurl_python >= 0.9.0
64+
pkginfo2 >= 30.0.0
65+
pip-requirements-parser >= 31.2.0
66+
requests >= 2.7.0
67+
resolvelib
68+
saneyaml >= 0.5.2
69+
toml >= 0.10.0
5370

5471
[options.packages.find]
5572
where = src
5673

74+
[options.entry_points]
75+
console_scripts =
76+
dad = python_inspector.resolve_cli:resolve_dependencies
5777

5878
[options.extras_require]
5979
testing =
6080
pytest >= 6, != 7.0.0
6181
pytest-xdist >= 2
62-
aboutcode-toolkit >= 6.0.0
82+
aboutcode-toolkit >= 7.0.2
83+
twine
6384
black
85+
isort
86+
pycodestyle
6487

6588
docs =
6689
Sphinx >= 3.3.1

tests/README.rst

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

tests/test_codestyle.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#
2+
# Copyright (c) nexB Inc. and others. All rights reserved.
3+
# ScanCode is a trademark of nexB Inc.
4+
# SPDX-License-Identifier: Apache-2.0
5+
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
6+
# See https://github.com/nexB/skeleton for support or download.
7+
# See https://aboutcode.org for more information about nexB OSS projects.
8+
#
9+
10+
import subprocess
11+
import unittest
12+
13+
14+
class BaseTests(unittest.TestCase):
15+
def test_codestyle(self):
16+
"""
17+
This test shouldn't run in proliferated repositories.
18+
"""
19+
args = "venv/bin/black --check -l 100 setup.py tests src"
20+
try:
21+
subprocess.check_output(args.split())
22+
except subprocess.CalledProcessError as e:
23+
print("===========================================================")
24+
print(e.output)
25+
print("===========================================================")
26+
raise Exception(
27+
"Black style check failed; please format the code using:\n"
28+
" python -m black -l 100 setup.py tests src",
29+
e.output,
30+
) from e

tests/test_skeleton_codestyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
99

10+
import configparser
1011
import subprocess
1112
import unittest
12-
import configparser
1313

1414

1515
class BaseTests(unittest.TestCase):

0 commit comments

Comments
 (0)