Skip to main content

Simple Python library to leverage 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

Fast Winnowing

To take advantage of faster fingerprinting, please install the optional scanoss_winnowing package:

pip3 install scanoss_winnowing

Or directly using:

pip3 install scanoss[fast_winnowing]

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.

Externally Managed Environments on Linux

If installing on Ubuntu 2023.04, Fedora 38, Debian 11, etc. a few additional steps are required before installing scanoss-py. More details can be found here.

The recommended method is to install pipx and use it to install scanoss-py:

sudo apt install pipx
pipx ensurepath

This will install the pipx package manager, which can then be used to install scanoss-py:

pipx install scanoss[fast_winnowing]

This will install the scanoss-py app in a separate virtual environment and create a link to the local path for execution.

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]
                  {version,ver,scan,sc,fingerprint,fp,wfp,dependencies,dp,dep,file_count,fc,convert,cv,cnv,cvrt,component,comp,utils,ut}
                  ...

SCANOSS Python CLI. Ver: 1.6.1, License: MIT, Fast Winnowing: True

options:
  -h, --help            show this help message and exit
  --version, -v         Display version details

Sub Commands:
  valid subcommands

  {version,ver,scan,sc,fingerprint,fp,wfp,dependencies,dp,dep,file_count,fc,convert,cv,cnv,cvrt,component,comp,utils,ut}
                        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, but do not decorate them
    file_count (fc)     Search the source tree and produce a file type summary
    convert (cv, cnv, cvrt)
                        Convert file format
    component (comp)    Component support commands
    utils (ut)          General utility support commands

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 base URL for SCANOSS OSS KB: https://api.osskb.org. The /scan/direct endpoint is automatically appended. 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.9 or higher.

Source code

The source for this package can be found here.

Documentation

For client usage help please look 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.47.0.tar.gz (242.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scanoss-1.47.0-py3-none-any.whl (291.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scanoss-1.47.0.tar.gz
  • Upload date:
  • Size: 242.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scanoss-1.47.0.tar.gz
Algorithm Hash digest
SHA256 b78d0247c2bbdd780daa6e7d0947e9e7711ee65f64a3e135c9f429b5e6ccb579
MD5 7d0d3bb7288a3987473390fc450392a4
BLAKE2b-256 1e976cbff5ec396206aee1282c93cdd36628767a15fc1b02f32b0c9063445020

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scanoss-1.47.0-py3-none-any.whl
  • Upload date:
  • Size: 291.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scanoss-1.47.0-py3-none-any.whl
Algorithm Hash digest
SHA256 669521f9baddf7c254d4e96f825e9afbf91648790a4c0dd820d0ba13386511f8
MD5 fa55e091dcdcfa3669f829ba51372a5b
BLAKE2b-256 4e1f7da9c73890606417a6bd83cb9bdb2540d60e9eac11419361565f9f489989

See more details on using hashes here.

Supported by

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