Skip to content

Commit 348f0c8

Browse files
authored
Merge pull request #13 from AyanSinhaMahapatra/master
Adds GitHub wiki of Scancode-Toolkit and Scancode-Workbench to the AboutCode readthedocs
2 parents f106356 + 154ab04 commit 348f0c8

24 files changed

Lines changed: 976 additions & 1 deletion

docs/source/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
1616

17+
# Adding Support for GIFs in Sphinx
18+
from sphinx.builders.html import StandaloneHTMLBuilder
19+
StandaloneHTMLBuilder.supported_image_types = [
20+
'image/svg+xml',
21+
'image/gif',
22+
'image/png',
23+
'image/jpeg'
24+
]
1725

1826
# -- Project information -----------------------------------------------------
1927

docs/source/doc_maintenance.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ Assuming that your Sphinx installation was successful, Sphinx should build a loc
4747

4848
open build/html/index.html
4949

50+
In case this command did not work, for example on Ubuntu 18.04 you may get a message like “Couldn’t get a file descriptor referring to the console”, try: ::
51+
52+
see build/html/index.html
53+
5054
You now have a local build of the AboutCode documents.
5155

5256
Improve AboutCode Documents

docs/source/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ Guide
55
*****
66

77
.. toctree::
8-
:maxdepth: 2
8+
:maxdepth: 3
99

10+
scancode-toolkit/index
11+
scancode-workbench/index
1012
license
1113
help
1214
doc_maintenance
3.63 KB
Loading
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
Comprehensive Installation
2+
==========================
3+
4+
ScanCode requires Python 2.7.x and is tested on Linux, Mac, and Windows. Make sure Python 2.7 is installed first.
5+
6+
System Requirements
7+
-------------------
8+
9+
- Hardware : ScanCode will run best with a modern X86 processor and at least 2GB of RAM and 250MB of disk.
10+
11+
- Supported operating systems : ScanCode should run on these OSes:
12+
13+
#. Linux: on most recent 64-bit Linux distributions (32-bit distros are only partially supported),
14+
#. Mac: on recent Mac OSX (10.6.8 and up),
15+
#. Windows: on Windows 7 and up (32- or 64-bit) using a 32-bit Python.
16+
17+
Prerequisites
18+
-------------
19+
ScanCode needs a Python 2.7 interpreter.
20+
21+
- On Linux: Use your package manager to install python2.7. If Python 2.7 is not available from your package manager, you must compile it from sources. For instance, visit https://github.com/dejacode/about-code-tool/wiki/BuildingPython27OnCentos6 for instructions to compile Python from sources on Centos.
22+
23+
- On Ubuntu 12.04, 14.04 and 16.04, you will need to install these packages first: ``python-dev bzip2 xz-utils zlib1g libxml2-dev libxslt1-dev``
24+
25+
- On Debian and Debian-based distros you will need to install these packages first: ``python-dev libbz2-1.0 xz-utils zlib1g libxml2-dev libxslt1-dev``
26+
27+
- On RPM-based distros, you will need to install these packages first: ``python-devel zlib bzip2-libs xz-libs libxml2-devel libxslt-devel``
28+
29+
- **On Windows**:
30+
31+
Use the Python 2.7 32-bit (e.g. the Windows x86 MSI installer) for X86 regardless of whether you run Windows on 32-bit or 64-bit. DO NOT USE Python X86_64 installer even if you run 64 bit Windows. Download Python from this url: https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi
32+
33+
Install Python on the c: drive and use all default installer options(scancode will try to find python just in c:\python27\python.exe). See the Windows installation section for more installation details.
34+
35+
- On Mac: Download and install Python from this url: https://www.python.org/ftp/python/2.7.13/python-2.7.13-macosx10.6.pkg
36+
37+
Do not use Unicode, non-ASCII in your installation Path
38+
-------------------------------------------------------
39+
There is a bug in underlying libraries that prevent this.
40+
41+
Installation on Linux and Mac
42+
-----------------------------
43+
44+
Download and extract the latest ScanCode release from:
45+
https://github.com/nexB/scancode-toolkit/releases/latest
46+
47+
Open a terminal in the extracted directory and run::
48+
49+
./scancode --help
50+
51+
This will configure ScanCode and display the command line help.
52+
53+
Installation on Windows
54+
-----------------------
55+
56+
- Download the latest ScanCode release zip file from https://github.com/nexB/scancode-toolkit/releases/latest
57+
58+
- In Windows Explorer (called File Explorer on Windows 10), select the downloaded ScanCode zip and right-click.
59+
60+
- In the pop-up menu select 'Extract All...'
61+
62+
- In the pop-up window 'Extract zip folders' ('Extract Compressed (Zipped) Folders' on Windows 10) use the default options to extract.
63+
64+
- Once the extraction is complete, a new Windows Explorer/File Explorer window will pop up.
65+
66+
- In this Explorer window, select the new folder that was created and right-click.
67+
68+
* On Windows 10, double-click the new folder, select one of the files inside the folder (e.g., 'setup.py'), and right-click.
69+
- In the pop-up menu select 'Properties'.
70+
71+
- In the pop-up window 'Properties', select the Location value. Copy this to the clipboard and close the 'Properties' window.
72+
73+
- Press the start menu button. (On Windows 10, click the search box or search icon in the taskbar.)
74+
75+
- In the search box type::
76+
77+
cmd
78+
79+
- Select 'cmd.exe' listed in the search results. (On Windows 10, you may see 'Command Prompt' instead -- select that.)
80+
81+
- A new 'cmd.exe' window ('Command Prompt' on Windows 10) pops up.
82+
83+
- In this window (aka a 'command prompt'), type the following (i.e., 'cd' followed by a space)::
84+
85+
cd
86+
87+
- Right-click in this window and select Paste. This will paste the path where you extracted ScanCode.
88+
89+
- Press Enter.
90+
91+
- This will change the current location of your command prompt to the root directory where scancode is installed.
92+
93+
- Then type::
94+
95+
scancode -h
96+
97+
- Press enter. This will configure your ScanCode installation.
98+
99+
- Several messages are displayed followed by the scancode command help.
100+
101+
- The installation is complete.
102+
103+
Un-installation
104+
---------------
105+
106+
- Delete the directory in which you extracted ScanCode.
107+
- Delete any temporary files created in your system temp directory under a scancode directory.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
Development
2+
===========
3+
4+
See CONTRIBUTING.rst for details: https://github.com/nexB/scancode-toolkit/blob/master/CONTRIBUTING.rst
5+
6+
Code layout and conventions
7+
---------------------------
8+
9+
Source code is in ``src/`` Tests are in ``tests/``.
10+
11+
There is one Python package for each major feature under ``src/`` and a corresponding directory with the same name under ``tests`` (but this is not a package by design).
12+
13+
Each test script is named ``test_XXXX`` and while we love to use ``py.test`` as a test runner, most tests have no dependencies on ``py.test``, only on the ``unittest`` module (with the exception of some command line tests that depend on pytest monkeypatching capabilities.
14+
15+
When source or tests need data files, we store these in a ``data`` subdirectory.
16+
17+
We use PEP8 conventions with a relaxed line length that can be up to 90'ish characters long when needed to keep the code clear and readable.
18+
19+
We store pre-built bundled native binaries in ``bin/`` sub-directories of each ``src/`` packages. These binaries are organized by OS and architecture. This ensure that ScanCode works out of the box either using a checkout or a download, without needing a compiler and toolchain to be installed. The corresponding source code for the pre-built binaries are store in a separate repository at https://github.com/nexB/scancode-thirdparty-src
20+
21+
We store bundled thirdparty components and libraries in the ``thirdparty`` directory. Python libraries are stored as wheels, eventually pre-built if the corresponding wheel is not available in the Pypi repository. Some of these components may be advanced builds with bug fixes or advanced patches.
22+
23+
We write tests, a lot of tests, thousands of tests. Several tests are data-driven and use data files as test input and sometimes data files as test expectation (in this case using either JSON or YAML files). The tests should pass on Linux 64 bits, Windows 32 and 64 bits and on MacOSX 10.6.8 and up. We maintain two CI loops with Travis (Linux) at https://travis-ci.org/nexB/scancode-toolkit and Appveyor (Windows) at https://ci.appveyor.com/project/nexB/scancode-toolkit
24+
25+
When finding bugs or adding new features, we add tests. See existing test code for examples.
26+
27+
Running tests
28+
-------------
29+
30+
ScanCode comes with over 13,000 unit tests to ensure detection accuracy and stability across Linux, Windows and macOS OSes: we kinda love tests, do we?
31+
32+
We use pytest to run the tests: call the ``py.test`` script to run the whole test suite. This is installed by ``pytest`` which is bundled with a ScanCode checkout and installed when you run ``./configure``).
33+
34+
If you are running from a fresh git clone and you run ``./configure`` and then ``source bin/activate`` the ``py.test`` command will be available in your path.
35+
36+
Alternatively if you have already configured but are not in an activated "virtualenv" the ``py.test`` command is available under ``<root of your checkout>/bin/py.test``
37+
38+
(Note: paths here are for POSIX, but mostly the same applies to Windows)
39+
40+
If you have a multiprocessor machine you might want to run the tests in parallel (and faster) For instance: ``py.test -n4`` runs the tests on 4 CPUs. We typically run the tests in verbose mode with ``py.test -vvs -n4``
41+
42+
You can also run a subset of the test suite as shown in the CI configs https://github.com/nexB/scancode-toolkit/blob/develop/appveyor.yml#L6 e,g, ``py.test -n 2 -vvs tests/scancode`` runs only the tests scripts present in the ``tests/scancode`` directory. (You can pass a path to a specific test script file there too).
43+
44+
See also https://docs.pytest.org for details or use the ``py.test -h`` command to show the many other options available.
45+
46+
One useful option is to run a select subset of the test functions matching a pattern with the ``-k`` option for instance: ``py.test -vvs -k tcpdump`` would only run test functions that contain the string "tcpdump" in their name or their class name or module name .
47+
48+
Another useful option after a test run with some failures is to re-run only the failed tests with the ``--lf`` option for instance: ``py.test -vvs --lf`` would only run only test functions that failed in the previous run.
49+
50+
pip requirements and the configure script
51+
-----------------------------------------
52+
53+
ScanCode use the ``configure`` and ``configure.bat`` (and ``etc/configure.py`` behind the scenes) scripts to install a `virtualenv <https://virtualenv.pypa.io/en/stable/>`_ , install required packaged dependencies as `pip <https://github.com/pypa/pip>`_ requirements and more configure tasks such that ScanCode can be installed in a self-contained way with no network connectivity required.
54+
55+
Earlier unreleased versions of ScanCode where using ``buildout`` to install and configure eventually complex dependencies. We had some improvements that were merged in the upstream ``buildout`` to support bootstrapping and installing without a network connection and When we migrated to use ``pip`` and ``wheels`` as new, improved and faster way to install and configure dependencies we missed some of the features of ``buildout`` like the ``recipes``, being able to invoke arbitrary Python or shell scripts after installing packages and have scripts or requirements that are operating system-specific.
56+
57+
ScanCode requirements and third-party Python libraries
58+
------------------------------------------------------
59+
60+
In a somewhat unconventional way, all the required libraries are bundled aka. copied in the repo itself in the thirdparty/ directory. If ScanCode were only a library it would not make sense. But its is first an application and having a well defined frozen set of dependent packages is important for an app. The benefit of this approach (combined with the ``configure`` script) means that a mere checkout of the repository contains everything needed to run ScanCode except for a Python interpreter.
61+
62+
Using ScanCode as a Python library
63+
----------------------------------
64+
65+
ScanCode can be used alright as a Python library and is available as as a Python wheel in Pypi and installed with ``pip install scancode-toolkit``.
66+
67+
Steps to cut a new release:
68+
---------------------------
69+
70+
- run bumpversion with major, minor or patch to bump the version in:
71+
72+
- ``src/scancode/__init__.py``
73+
- ``setup.py``
74+
- Update the CHANGELOG.rst
75+
76+
- commit changes and push changes to develop:
77+
78+
- ``git commit -m "commit message"``
79+
- ``git push --set-upstream origin develop``
80+
81+
- merge develop branch in master and tag the release.
82+
83+
- ``git checkout master``
84+
- ``git merge develop``
85+
- ``git tag -a v1.6.1 -m "Release v1.6.1"``
86+
- ``git push --set-upstream origin master``
87+
- ``git push --set-upstream origin v1.6.1``
88+
89+
- draft a new release in GitHub, using the previous release blurb as a base. Highlight new and noteworthy changes from the CHANGELOG.rst.
90+
91+
- run ``etc/release/release.sh`` locally.
92+
93+
- upload the release archives created in the ``dist/`` directory to the GitHub release page.
94+
95+
- save the release as a draft. Use the previous release notes to create notes in the same style. Ensure that the link to thirdparty source code is present.
96+
97+
- test the downloads.
98+
99+
- publish the release on GitHub
100+
101+
- then build and publish the released wheel on Pypi. For this you need your own Pypi credentials (and get authorized to publish Pypi release: ask @pombredanne) and you need to have the ``twine`` package installed and configured.
102+
103+
- Build a ``.whl`` with ``python setup.py bdist_wheel``
104+
- Run twine with ``twine upload dist/<path to the built wheel>``
105+
- Once uploaded check the published release at https://pypi.python.org/pypi/scancode-toolkit/
106+
- Then create a new fresh local virtualenv and test the wheel installation with: ``pip install scancode-toolkit``
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Documentation
2+
=============
3+
4+
This page provides an index of current ScanCode user documentation.
5+
6+
Download
7+
--------
8+
9+
Download the latest release of ScanCode from our `release page <https://github.com/nexB/scancode-toolkit/releases.>`_
10+
11+
Installation
12+
------------
13+
14+
See https://github.com/nexB/scancode-toolkit/blob/master/README.rst for more.
15+
16+
User Guide
17+
----------
18+
19+
The goal of ScanCode is to help you detect accurately provenance information in a codebase.
20+
The output of the scan is either a JSON file, an HTML app or a plain HTML file. You can visualize the HTML format in a tree view format.
21+
This view contains the following elements:
22+
23+
- Code tree view - On the left side, you are able to navigate the code tree to understand what ScanCode has detected in each file.
24+
- Path - The directory path of the analyzed file.
25+
- Start/End Line - The line number where the Copyright or License has been detected.
26+
- What - The type of detection, either Copyright or a License.
27+
- Info - The name of the detected output.
28+
29+
You can sort any column by clicking on its title. Search is also available in the top right corner for faster access to a specified resource or a type of detected license or copyright.
2.18 KB
Loading

0 commit comments

Comments
 (0)