Skip to content

Commit 662963a

Browse files
committed
Improve documentation
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent 10391f7 commit 662963a

20 files changed

Lines changed: 447 additions & 430 deletions

CHANGELOG.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ Package detection:
4343
- Add support to track installed files for each Package type.
4444

4545

46+
v21.8.1
47+
---------
48+
49+
This is a minor bug fix release primarily for Windows installation.
50+
There is no feature change.
51+
52+
Installation:
53+
~~~~~~~~~~~~~~~~~~
54+
55+
- Application installation on Windows works again. This fixes #2610
56+
- We now build and test app bundles on all supported Python versions: 3.6 to 3.9
57+
58+
59+
Thank you to @gunaztar for reporting the #2610 bug
60+
61+
Documentation:
62+
~~~~~~~~~~~~~~~~~~
63+
64+
- Documentation is updated to reference supported Python versions 3.6 to 3.9
65+
66+
67+
4668
v21.7.30
4769
---------
4870

INSTALL.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@ Prerequisites
1616
-------------
1717

1818
Before installing ScanCode make sure you have installed these prerequisites.
19-
The main one is a Python interpreter.
20-
Python 3.6 is required for the standard installation.
19+
The main one is to have Python installed version 3.6, 3.7, 3.8 or 3.9.
2120

2221
- For Linux(Ubuntu): ``sudo apt install python3.6-dev bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev``
23-
- For MacOS: Install Python 3.6.8 from https://www.python.org/ftp/python/3.6.8/python-3.6.8-macosx10.9.pkg
24-
- For Windows: Install Python 3.6.8 from https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe
25-
- For FreeBSD: (this ineeds to be documented)
22+
- For MacOS: Install Python 3.x from https://www.python.org/
23+
- For Windows: Install Python 3.x from https://www.python.org/ using the 64 bits amd64 variant
24+
- For FreeBSD: (this needs to be documented)
2625

2726
Refer `Prerequisites <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#prerequisites>`_
2827
for detailed information on all different operating systems and Python versions.
@@ -46,9 +45,9 @@ Use a release download and install as an application
4645
Advanced installation: pip install a Python PyPI package
4746
--------------------------------------------------------
4847

49-
- Create a virtual environment for Python 3.6 (of higher) and activate it::
48+
- Create a virtual environment for Python 3.x and activate it::
5049

51-
virtualenv -p /usr/bin/python3.6 venv-scancode && source venv-scancode/bin/activate
50+
virtualenv -p python3 venv-scancode && source venv-scancode/bin/activate
5251

5352
- Run ``pip install scancode-toolkit[full]``
5453

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ Installation
120120
============
121121

122122
Before installing ScanCode make sure that you have installed the prerequisites
123-
properly. This means installing Python (Python 3.6 or higher is required.
124-
When installing the app tarball or zip, only Python 3.6 is supported for now).
123+
properly. This means installing Python (Python 3.6 or higher is required).
125124

126125
See `prerequisites <https://scancode-toolkit.readthedocs.io/en/latest/getting-started/install.html#prerequisites>`_
127126
for detailed information on the support platforms and Python versions.

docs/source/cli-reference/output-format.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ following options.
2929
others. Scancode Workbench and other applications that use Scancode Result data as input accept
3030
only the ``json`` format.
3131

32-
.. include:: /rst_snippets/note_snippets/output_json_notdef.rst
33-
3432
The following code performs a scan on the samples directory, and publishes the results in
3533
``json`` format::
3634

docs/source/contribute/contrib_dev.rst

Lines changed: 135 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3,131 +3,177 @@
33
Contributing to Code Development
44
================================
55

6+
TL;DR:
7+
8+
- Contributions comes as bugs/questions/issues and as pull requests.
9+
- Source code and runtime data are in the /src/ directory.
10+
- Test code and test data are in the /tests/ directory.
11+
- Datasets (inluding licenses) and test data are in /data/ sub-directories.
12+
- We use DCO signoff in commit messages, like Linux does.
13+
- Porting ScanCode to other OS (FreeBSD is supported, etc.) is possible. Enter an issue for help.
14+
615
See `CONTRIBUTING.rst <https://github.com/nexB/scancode-toolkit/blob/master/CONTRIBUTING.rst>`_
716
for details.
817

18+
919
.. _contrib_code_conven:
1020

1121
Code layout and conventions
1222
---------------------------
1323

14-
Source code is in ``src/`` Tests are in ``tests/``.
24+
Source code is in the ``src/`` directory, tests are in the ``tests/`` directory.
25+
Miscellaneous scripts and configuration files are in the ``etc/`` directory.
1526

16-
There is one Python package for each major feature under ``src/`` and a corresponding directory
17-
with the same name under ``tests`` (but this is not a package by design).
27+
There is one Python package for each major feature under ``src/`` and a
28+
corresponding directory with the same name under ``tests`` (but this is not a
29+
package by design as it would not make sense to have a top level "tests" package
30+
which is a name that's too common).
1831

19-
Each test script is named ``test_XXXX`` and while we love to use ``py.test`` as a test runner,
20-
most tests have no dependencies on ``py.test``, only on the ``unittest`` module (with the exception
21-
of some command line tests that depend on pytest monkeypatching capabilities.
32+
Each test script is named ``test_XXXX``; we prefer organizing tests in subclasses
33+
of the standard library ``unittest`` module. But we also use plain functions
34+
that are discovered nicely by ``pytest``.
2235

2336
When source or tests need data files, we store these in a ``data`` subdirectory.
37+
This is used extensively in tests and also in source code for the reference
38+
license texts and data and license detection rules files.
2439

25-
We use PEP8 conventions with a relaxed line length that can be up to 90'ish characters long when
26-
needed to keep the code clear and readable.
40+
We use PEP8 conventions with a relaxed line length that can be up to 90'ish
41+
characters long when needed to keep the code clear and readable.
2742

28-
We store pre-built bundled native binaries in ``bin/`` sub-directories of each ``src/`` packages.
29-
These binaries are organized by OS and architecture. This ensures that ScanCode works out of the box
30-
either using a checkout or a download, without needing a compiler and toolchain to be installed.
31-
The corresponding source code for the pre-built binaries are stored in a separate repository at
32-
https://github.com/nexB/scancode-thirdparty-src.
43+
We write tests, a lot of tests, thousands of tests. When finding bugs or adding
44+
new features, we add tests. See existing test code for examples which form also
45+
a good specification for the supported features.
3346

34-
We store bundled thirdparty components and libraries in the ``thirdparty`` directory. Python
35-
libraries are stored as wheels, eventually pre-built if the corresponding wheel is not available
36-
in the Pypi repository. Some of these components may be advanced builds with bug fixes or advanced
37-
patches.
47+
The tests should pass on Linux 64 bits, Windows 64 bits and on
48+
macOS 10.14 and up. We maintain multiple CI loops with Azure (all OSes)
49+
at https://dev.azure.com/nexB/scancode-toolkit/_build and Appveyor (Windows) at
50+
https://ci.appveyor.com/project/nexB/scancode-toolkit .
3851

39-
We write tests, a lot of tests, thousands of tests. Several tests are data-driven and use data
40-
files as test input and sometimes data files as test expectation (in this case using either
41-
JSON or YAML files). The tests should pass on Linux 64 bits, Windows 32 and 64 bits and on
42-
MacOS 10.9 and up. We maintain two CI loops with Travis (Linux) at
43-
https://travis-ci.org/nexB/scancode-toolkit and Appveyor (Windows) at
44-
https://ci.appveyor.com/project/nexB/scancode-toolkit.
4552

46-
When finding bugs or adding new features, we add tests. See existing test code for examples.
53+
Several tests are data-driven and use data files as test input and sometimes
54+
data files as test expectation (in this case using either JSON or YAML files);
55+
a large number of copyright, license and package manifest parsing tests are such
56+
data-driven tests.
4757

48-
More info:
4958

50-
- Source code and license datasets are in the /src/ directory.
51-
- Test code and test data are in the /tests/ directory.
52-
- Datasets and test data are in /data/ sub-directories.
53-
- Third-party components are vendored in the /thirdparty/ directory. ScanCode is self contained
54-
and should not require network access for installation or configuration of third-party libraries.
55-
- Additional pre-compiled vendored binaries are stored in bin/ sub-directories of the /src/
56-
directory with their sources in this repo: https://github.com/nexB/scancode-thirdparty-src/
57-
- Porting ScanCode to other OS (FreeBSD, etc.) is possible. Enter an issue for help.
58-
- Bugs and pull requests are welcomed.
59-
- See the wiki and CONTRIBUTING.rst for more info.
6059

61-
.. _scancode_toolkit_developement_running_tests:
60+
.. _scancode_toolkit_development_running_tests:
61+
6262

6363
Running tests
6464
-------------
6565

66-
ScanCode comes with over 13,000 unit tests to ensure detection accuracy and stability across Linux,
67-
Windows and macOS OSes: we kinda love tests, do we?
66+
ScanCode comes with over 29,000 unit tests to ensure detection accuracy and
67+
stability across Linux, Windows and macOS OSes: we kinda love tests, do we?
6868

69-
We use pytest to run the tests: call the ``py.test`` script to run the whole test suite. This is
70-
installed by ``pytest``, which is bundled with a ScanCode checkout and installed when you
71-
run ``./configure``).
69+
We use pytest to run the tests: call the ``pytest`` script to run the whole
70+
test suite. This is installed with the ``pytest`` package which is installed
71+
when you run ``./configure --dev``).
7272

7373
If you are running from a fresh git clone and you run ``./configure`` and then
74-
``source bin/activate`` the ``py.test`` command will be available in your path.
74+
``source bin/activate`` the ``pytest`` command will be available in your path.
7575

76-
Alternatively, if you have already configured but are not in an activated "virtualenv" the
77-
``py.test`` command is available under ``<root of your checkout>/bin/py.test``
76+
Alternatively, if you have already configured but are not in an activated
77+
"virtualenv" the ``pytest`` command is available under
78+
``<root of your checkout>/bin/pytest``
7879

7980
(Note: paths here are for POSIX, but mostly the same applies to Windows)
8081

81-
If you have a multiprocessor machine you might want to run the tests in parallel (and faster)
82-
For instance: ``py.test -n4`` runs the tests on 4 CPUs. We typically run the tests in
83-
verbose mode with ``py.test -vvs -n4``.
82+
If you have a multiprocessor machine you might want to run the tests in parallel
83+
(and faster). For instance: ``pytest -n4`` runs the tests on 4 CPUs. We
84+
typically run the tests in verbose mode with ``pytest -vvs -n4``.
8485

8586
You can also run a subset of the test suite as shown in the CI configs
8687
https://github.com/nexB/scancode-toolkit/blob/develop/appveyor.yml#L6 e,g,
87-
``py.test -n 2 -vvs tests/scancode`` runs only the test scripts present in the ``tests/scancode``
88-
directory. (You can pass a path to a specific test script file there too).
89-
90-
See also https://docs.pytest.org for details or use the ``py.test -h`` command to show the many
91-
other options available.
92-
93-
One useful option is to run a select subset of the test functions matching a pattern with the
94-
``-k`` option, for instance: ``py.test -vvs -k tcpdump`` would only run test functions that contain
95-
the string "tcpdump" in their name or their class name or module name .
96-
97-
Another useful option after a test run with some failures is to re-run only the failed tests with
98-
the ``--lf`` option, for instance: ``py.test -vvs --lf`` would only run only test functions that
99-
failed in the previous run.
100-
101-
.. _contrib_dev_pip_and_configure:
102-
103-
pip requirements and the configure script
104-
-----------------------------------------
105-
106-
ScanCode use the ``configure`` and ``configure.bat`` (and ``etc/configure.py`` behind the scenes)
107-
scripts to install a `virtualenv <https://virtualenv.pypa.io/en/stable/>`_ , install required
108-
packaged dependencies as `pip <https://github.com/pypa/pip>`_ requirements and more configure tasks
109-
such that ScanCode can be installed in a self-contained way with no network connectivity required.
110-
111-
Earlier unreleased versions of ScanCode where using ``buildout`` to install and configure
112-
eventually complex dependencies. We had some improvements that were merged in the upstream
113-
``buildout`` to support bootstrapping and installing without a network connection and When we
114-
migrated to use ``pip`` and ``wheels`` as new, improved and faster way to install and configure
115-
dependencies we missed some of the features of ``buildout`` like the ``recipes``, being able to
116-
invoke arbitrary Python or shell scripts after installing packages and have scripts or requirements
117-
that are operating system-specific.
118-
119-
ScanCode requirements and third-party Python libraries
120-
------------------------------------------------------
88+
``pytest -n 2 -vvs tests/scancode`` runs only the test scripts present in the
89+
``tests/scancode`` directory. (You can give the path to a specific test script
90+
file there too).
91+
92+
See also https://docs.pytest.org for details or use the ``pytest -h`` command
93+
to show the many other options available.
94+
95+
One useful option is to run a select subset of the test functions matching a
96+
pattern with the ``-k`` option, for instance: ``pytest -vvs -k tcpdump`` would
97+
only run test functions that contain the string "tcpdump" in their name or their
98+
class name or module name.
99+
100+
Another useful option after a test run with some failures is to re-run only the
101+
failed tests with the ``--lf`` option, for instance: ``pytest -vvs --lf`` would
102+
only run only test functions that failed in the previous run.
103+
104+
Because we have a lot of tests (over 29,000), we organized theses in test suites
105+
using pytest markers that are defined in the ``conftest.py`` pytest plugin.
106+
These are enabled by adding a ``--test-suite`` option to the pytest command.
107+
108+
- ``--test-suite=standard`` is the default and runs a decent but basic test suite
109+
- ``--test-suite=all`` runs the ``standard`` test and adds a comprehensive test suite
110+
- ``--test-suite=validate`` runs the ``standra`` and ``all`` test and adds
111+
extensive data-driven and data validations (for package, copyright and license
112+
detection)
113+
114+
115+
116+
.. _scancode_toolkit_development_thirdparty_libraries:
117+
118+
Thirdparty libraries and dependencies management
119+
-----------------------------------------------------
120+
121+
ScanCode uses the ``configure`` and ``configure.bat`` scripts to install a
122+
`virtualenv <https://virtualenv.pypa.io/en/stable/>`_ , install required
123+
packaged dependencies using `setuptools <https://github.com/pypa/setuptools>`_
124+
and such that ScanCode can be installed in a repeatable and consistent manner on
125+
all OSes and Python versions.
126+
127+
For this we maintain a ``setup.cfg`` with our direct dependencies with loose
128+
minimum version constraints; and we keep pinned exact versions of these
129+
dependencies in the ``requirements.txt`` and ``requirements-dev.txt`` (for
130+
testing and development).
131+
132+
Note: we also have a ``setup-mini.cfg`` used to create a ScanCode PyPI package
133+
with minimal dependencies (and limited features). This is mostly duplicated
134+
from ``setup.cfg``.
135+
136+
And to ensure that we also all use well known version of the core virtualenv,
137+
pip, setuptools and wheel libraries, we use the ``virtualenv.pyz`` Python
138+
zipp app from https://github.com/pypa/get-virtualenv/tree/master/public and
139+
store it in the Git repo in the ``etc/thirdparty`` directory.
140+
141+
We bundle pre-built bundled native binaries as plugins which are installed as
142+
wheels. These binaries are organized by OS and architecture; they ensure that
143+
ScanCode works out of the box either using a checkout or a download, without
144+
needing a compiler and toolchain to be installed.
145+
146+
The corresponding source code and build scripts for all for the
147+
pre-built binaries are stored in a separate repository at
148+
https://github.com/nexB/scancode-plugins
149+
150+
ScanCode app archives should not require network access for installation or
151+
configuration of its third-party libraries and dependencies. To enable this,
152+
we store bundled thirdparty components and libraries in the ``thirdparty``
153+
directory of released app archives; this is done at build time.
154+
These dependencies are stored as pre-built wheels. These wheels are sometimes
155+
built by us when there is no wheel available upstream on PyPI. We store all
156+
these prebuilt wheels with corresponding .ABOUT and .LICENSE files in
157+
https://github.com/nexB/thirdparty-packages/tree/main/pypi which is published
158+
for download at https://thirdparty.aboutcode.org/pypi/
159+
160+
Because this is used by the configure script, all the thirdparty dependencies
161+
used in ScanCode MUST be available there first. Therefore adding a new
162+
dependency means requesting a merge/PR in
163+
https://github.com/nexB/thirdparty-packages/ first that contains all the
164+
recursive dependencies.
165+
166+
There are utility scripts in ``etc/release`` that can help with the dependencies
167+
management process in particular to build or update wheels with native code for
168+
multiple OSes (Linux, macOS and Windows) and multiple Python versions (3.6+),
169+
which is not a completely simple operation (and requires eventually 12 wheels
170+
and one source distribution to be published as we support 3 OSes and 4 Python
171+
versions).
121172

122-
In a somewhat unconventional way, all the required libraries are bundled aka. Copied in the repo
123-
itself in the thirdparty/ directory. If ScanCode were only a library it would not make sense. But
124-
it is first an application and having a well defined frozen set of dependent packages is important
125-
for an app. The benefit of this approach (combined with the ``configure`` script) means that a mere
126-
checkout of the repository contains everything needed to run ScanCode except for a
127-
Python interpreter.
128173

129174
Using ScanCode as a Python library
130175
----------------------------------
131176

132-
ScanCode can be used alright as a Python library and is available as as a Python wheel in Pypi and
133-
installed with ``pip install scancode-toolkit``.
177+
ScanCode can be used alright as a Python library and is available as as a
178+
Python wheel in Pypi and installed with ``pip install scancode-toolkit`` or
179+
``pip install scancode-toolkit-mini``.

docs/source/contribute/contrib_doc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ That will create an ``/scancode-toolkit`` directory in your working directory.
1818
Now you can install the dependencies in a virtualenv::
1919

2020
cd scancode-toolkit
21-
virtualenv -p /usr/bin/python3.6 docs-venv
21+
virtualenv -p /usr/bin/python3 docs-venv
2222
source docs-venv/bin/activate
2323

2424
Now, the following prerequisites are installed

docs/source/contribute/long_running_issues.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ are considering, what the long-term goals are.
2222

2323
- :ref:`roadmap`
2424
- `Milestones <https://github.com/nexB/scancode-toolkit/milestones>`_
25-
- `v3.1 <https://github.com/nexB/scancode-toolkit/milestone/11>`_
26-
- `v3.2 <https://github.com/nexB/scancode-toolkit/milestone/12>`_
2725
- `Documentation Roadmap <https://github.com/nexB/scancode-toolkit/issues/1824>`_
2826

2927
.. _good_first_issue:

docs/source/explanations/overview.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ Overview
33

44
.. _explain_how_scancode_works:
55

6-
How does ScanCode work?
7-
-----------------------
6+
How does ScanCode detect licenses?
7+
--------------------------------------
88

99
For license detection, ScanCode uses a (large) number of license texts and license detection
1010
'rules' that are compiled in a search index. When scanning, the text of the target file is

0 commit comments

Comments
 (0)