Skip to main content

license_scanner

Creating a package

Fork this repo. Next up make sure there are 2 remote repositories connected. In vscode:

  • ctrl + shift + P
  • Git: Add remote
  • origin_basic_function_package
  • https://cytosmart.visualstudio.com/CytoSmartImageAnalysis/_git/basic_function_package

Next steps are only if you need to connect it to an existing repo.

  • Open terminal (ctrl + shift + `)
  • git pull origin_basic_function_package master --allow-unrelated-histories

You now can git > pull from.. and choose to pull from origin or origin_basic_function_package. By choosing origin_basic_function_package you will update your package.

Rename variables

  • Search for 'license_scanner' and replace it with the package name of your choosing.
    • Don't forget to change the folder name too!
  • Search for 'Tom Nijhof' and replace it with your name.
  • Search for 'Scans your environment for all needed licenses' and replace it with a small description of what the package does

Adding code to the package

The init.py will be used to navigate easily through functions. You can also add a function of collection.

You import the whole function in license_scanner.init.py. Every function has its own folder. Within this folder is a:

  • main.py for the function itself.
  • __init__.py for importing the code
  • test_FUNCTION_NAME.py for the unit tests

Example function:

# license_scanner folder
- __init__.py
-- from .FUNCTION_NAME import FUNCTION_NAME
- FUNCTION_NAME (folder)
-- __init__.py
--- from .main import FUNCTION_NAME
-- main.py
--- def FUNCTION_NAME(...):
-- test_FUNCTION_NAME.py
--- class test_FUNCTION_NAME(TestCase)

This will import all function on COLLECTION_NAME to license_scanner. Using license_scanner will now look like this

# Using of license_scanner
from license_scanner import FUNCTION_NAME

Example collection:

# license_scanner folder
- __init__.py
-- from .FUNCTION_NAME import FUNCTION_NAME
- FUNCTION_NAME (folder)
-- __init__.py
--- from .main import FUNCTION_NAME
-- main.py
--- def FUNCTION_NAME(...):
-- test_FUNCTION_NAME.py
--- class test_FUNCTION_NAME(TestCase)

This will import all function on COLLECTION_NAME to license_scanner. Using license_scanner will now look like this

# Using of license_scanner
from license_scanner.COLLECTION_NAME import FUNCTION_NAME

testing the build of your package

To test if you function build correctly open your terminal.

  • Go to the root folder of your package (where setup.py is located)
  • run 'python setup.py sdist'

You will now get a /dist/license_scanner-0.0.1.tar.gz

  • copy its location
  • create a new empty python environment (e.q. conda create -n NAMENEWENV python=3.7)
  • Go in this new env (e.q. conda activate NAMENEWENV)
  • Install your package (pip install [pathToPackage]/dist/license_scanner-0.0.1.tar.gz)
  • Try importing function from your package
    • python
    • from license_scanner import license_scanner
    • license_scanner.calculate
    • should return <function license_scanner.calculate at [pointer]>
    • expands these test to make sure it works
  • Possible errors:
    • missing package [depPackage]
      • add [depPackage] to setup.py -> requirements
    • ImportError: cannot import name 'license_scanner'
      • check if init.py imports the function

testing your code

You should have writing some unit test well creating your functions. In order to run them you can use pytest in the terminal or with the vscode extension.

setup build pipeline

The file 'azure-pipelines.yml' contains the full pipeline.

  • To activate it go to devops (cytosmart.visualstudio.com)
  • goto Pipelines -> builds -> new -> new build pipeline
  • Select your repo
  • Done
  • possible errors
    • pytest 1 error code '5'
      • This happens if you have zero unit tests

Last step

Delete all instruction from creating a package till here.

Usage

Scans your environment for all needed licenses

Install

To install this package follow the these steps:

1. Create/Edit your pip configuration file:
        a. Windows users: %APPDATA%\pip\pip.ini
        b. MacOS users: $HOME/Library/Application Support/pip/pip.conf
            if directory $HOME/Library/Application Support/pip exists
            else $HOME/.config/pip/pip.conf
        c. Linux users: $HOME/.config/pip/pip.conf

For windows. Make sure you create the file via vscode.
If not the file might become a text document.

Wrong

2. Get access token
   1. Go to User Settings > Personal Access Token
   2. New Token
   3. Set a name
   4. Set expiration date (max a year in the future)
   5. Give code Read & Write Access
   6. Give packing Read Access
   7. Create
   8. Copy token

Gif

3. Open pip.ini and add
[global]
extra-index-url=https://ImageAnalysisArtifacts:ACCESTOKEN@cytosmart.pkgs.visualstudio.com/_packaging/ImageAnalysisArtifacts@Local/pypi/simple/
Replace the ACCESTOKEN for what you copied in step 2

4. DONE

Features

Credits

  • Tom Nijhof

History

0.0.1 (2023-01-10)

  • Add license scanner
  • Find all licenses in your env

0.0.0 (1970-01-01)

  • Copied basic package a start of license_scanner

Metadata

Release files for license_scanner 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for license_scanner 0.0.1
File Size Uploaded Provenance Actions
license_scanner-0.0.1.tar.gz 9.3 kB Without provenance Details for license_scanner-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for license_scanner 0.0.1
File Interpreter ABI Platform Actions
license_scanner-0.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for license_scanner-0.0.1-py2.py3-none-any.whl

Total release size: 17.0 kB

Release files / license_scanner-0.0.1.tar.gz

Download URL license_scanner-0.0.1.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5eb9c7bed33141ed5fd8877036ddef6490417a1ebd06508918e68f086f0904e6
BLAKE2b-256 checksum
How to use checksums
901469f6d6cd1421416d7fae0559511cf5af831322b626508cec7010560fa5ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / license_scanner-0.0.1-py2.py3-none-any.whl

Download URL license_scanner-0.0.1-py2.py3-none-any.whl
Size 7.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7002dd45c8c9165e7787b7b72244027582ea0ba751a37ed1d78b8cd8144e144c
BLAKE2b-256 checksum
How to use checksums
a47e2a3467206696b1d6b12b2545b1c98745290aae339f482f781a2b5dbb9cfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for license_scanner 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page