Skip to main content

Simple Python library to use the SCANOSS APIs.

Project description

SCANOSS Python Package

The SCANOSS python package provides a simple easy to consume library for interacting with SCANOSS APIs/Engine.

Installation

To install (from pypi.org), please run:

pip3 install scanoss

To upgrade an existing installation please run:

pip3 install --upgrade scanoss

Docker

Alternatively, there is a docker image of the compiled package. It can be found here. Details of how to run it can be found here.

Usage

The package can be run from the command line, or consumed from another Python script.

CLI Usage

The Python package manager (pip), will register the following command during installation:

scanoss-py

It is also possible to launch it using:

python3 -m scanoss.cli

Running the bare command will list the available sub-commands:

> scanoss-py

usage: scanoss-py [-h] {version,ver,scan,sc,fingerprint,fp,wfp,dependencies,dp,dep} ...

SCANOSS Python CLI. Ver: 0.9.0, License: MIT

optional arguments:
  -h, --help            show this help message and exit

Sub Commands:
  valid subcommands

  {version,ver,scan,sc,fingerprint,fp,wfp,dependencies,dp,dep}
                        sub-command help
    version (ver)       SCANOSS version
    scan (sc)           Scan source code
    fingerprint (fp, wfp)
                        Fingerprint source code
    dependencies (dp, dep)
                        Scan source code for dependencies

From there it is possible to scan a source code folder:

> scanoss-py scan -o scan-output.json <source-folder>

Scanning for Dependencies

The SCANOSS CLI supports dependency decoration. In order for this to work, it requires the installation of scancode:

pip install scancode-toolkit

Dependencies can then be decorated by adding the --dependencies option to the scanner:

> scanoss-py scan --dependencies -o scan-output.json <source-folder>

Package Usage

The scanoss package can also be used in other Python projects/scripts. A good example of how to consume it can be found here.

In general the easiest way to consume it is to import the required module as follows:

from scanoss.scanner import Scanner

def main():
    scanner = Scanner()
    scanner.scan_folder( '.' )
    
if __name__ == "__main__":
    main()

Scanning URL and API Key

By Default, scanoss uses the API URL endpoint for SCANOSS OSS KB: https://osskb.org/api/scan/direct. This API does not require an API key.

These values can be changed from the command line using:

> scanoss-py scan --apiurl <URL> --key <KEY>

From code, it would look like this:

from scanoss.scanner import Scanner

def main():
    scanner = Scanner(url='new-url', api_key='key')
    scanner.scan_folder( '.' )
    
if __name__ == "__main__":
    main()

Requirements

Python 3.7 or higher.

Source code

The source for this package can be found here.

Changelog

Details of each release can be found here.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scanoss-1.0.2.tar.gz (43.1 kB view details)

Uploaded Source

Built Distribution

scanoss-1.0.2-py3-none-any.whl (92.1 kB view details)

Uploaded Python 3

File details

Details for the file scanoss-1.0.2.tar.gz.

File metadata

  • Download URL: scanoss-1.0.2.tar.gz
  • Upload date:
  • Size: 43.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for scanoss-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f2b65869c65f2c87bec5533779d8484dc9d57675514f24dd23c74655c0e62c53
MD5 a5f27f2adf3d849c94484106c5e505f4
BLAKE2b-256 8e3a77609e0f0cb2917eab00ad0fe6bcc8dae8136c857641b30e7d64f9ba741a

See more details on using hashes here.

File details

Details for the file scanoss-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: scanoss-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 92.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for scanoss-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5d0a934c898cd50ef5ab474824016eb867b7d0eac19712fbbd5f2014b16ff733
MD5 84a1cfe89dee36cd0677411a6a7bb260
BLAKE2b-256 334a2c06021444d0615b1ae17463e94552f2b1b0b178db5c5019d34ac9c29fd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page