cape.attdb.vendorutils: Package Vendorization Utilities

This module provides some CAPE-specific alterations to the vendorize package available from PyPI

class cape.attdb.vendorutils.VendorizeConfig(fname=None, **kw)

Common methods for two vendorize options file formats

Call:
>>> opts = VendorizeConfig(fname=None, **kw)
>>> opts = VendorizeConfig(d, **kw)
Inputs:
fname: {None} | str

Name of file from which to read

d: dict

If first input is a dict, copy options from it

kw: dict

Additional inputs to override first two

Outputs:
opts: VendorizeConfig

TOML vendorization options interface

Versions:
  • 2021-08-23 @ddalle: Version 1.0

get_package_list(**kw)

Get list of package names from full requirements

Call:
>>> pkgs = opts.get_package_list(**kw)
Inputs:
opts: VendorizeConfig

Vendorization options interface

re, regex: {None} | str

Include packages matching optional regular expression

Outputs:
pkgs: list[str]

List of package base names

Versions:
  • 2021-08-23 @ddalle: Version 1.0

vendorize(**kw)

Get list of package names from full requirements

Call:
>>> opts.vendorize(**kw)
Inputs:
opts: VendorizeConfig

Vendorization options interface

re, regex: {None} | str | list

Include packages matching optional regular expression

check: True | {False}

Option to only list packages and not install

install: {True} | False

Opposite of check

Versions:
  • 2021-08-23 @ddalle: Version 1.0

vendorize_requirement(req)

Vendorize one package, updating if necessary

This slightly modifies the function of the same name from vendorize.

Call:
>>> ierr = opts.vendorize_requirement(req)
Inputs:
opts: VendorizeConfig

Vendorization options interface

req: str

Package to install with pip

Outputs:
ierr: int

Exit code from pip.main()

Versions:
  • 2021-08-23 @ddalle: Version 1.0

class cape.attdb.vendorutils.VendorizeJSON(fname=None, **kw)

Common methods from vendorize.json file

Call:
>>> opts = VendorizeTOML(ftoml=None, **kw)
>>> opts = VendorizeTOML(d, **kw)
Inputs:
ftoml: {None} | str

Name of file from which to read

d: dict

If first input is a dict, copy options from it

kw: dict

Additional inputs to override first two

Outputs:
opts: VendorizeConfig

TOML vendorization options interface

Versions:
  • 2021-08-23 @ddalle: Version 1.0

read(fjson)

Read a vendorize.json file

Call:
>>> opts.read(ftoml)
Inputs:
opts: VendorizeJSON

JSON vendorization options interface

fjson: str

Name of file to read

Versions:
  • 2021-08-23 @ddalle: Version 1.0

vendorize_requirement(req)

Vendorize one package, updating if necessary

This slightly modifies the function of the same name from vendorize.

Call:
>>> ierr = opts.vendorize_requirement(req)
Inputs:
opts: VendorizeJSON

Vendorization options interface

req: str

Package to install with pip

Outputs:
ierr: int

Exit code from pip.main()

Versions:
  • 2021-08-23 @ddalle: Version 1.0

class cape.attdb.vendorutils.VendorizeTOML(fname=None, **kw)

Common methods from vendorize.toml file

Call:
>>> opts = VendorizeTOML(ftoml=None, **kw)
>>> opts = VendorizeTOML(d, **kw)
Inputs:
ftoml: {None} | str

Name of file from which to read

d: dict

If first input is a dict, copy options from it

kw: dict

Additional inputs to override first two

Outputs:
opts: VendorizeConfig

TOML vendorization options interface

Versions:
  • 2021-08-23 @ddalle: Version 1.0

read(ftoml)

Read a vendorize.toml file

Call:
>>> opts.read(ftoml)
Inputs:
opts: VendorizeTOML

TOML vendorization options interface

ftoml: str

Name of file to read

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.find_top_level_packages(target)

Find top-level packages in a folder

Call:
>>> pkgs = find_top_level_packages(target)
Inputs:
target: str

Name of folder to look in

Outputs:
pkgs: list[str]

List of top-level packages in target

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.find_vendors(where='.', **kw)

Find packages that have vendorization inputs

This looks for all packages that have either

  • vendorize.json

  • vendorize.toml

files in them.

Call:
>>> pkgs = find_vendors(where=".", **kw)
Inputs:
where: {"."} | str

Location from which to search for packages

exclude: {()} | tuple[str]

List of globs to exclude from package search

include: {("*",)} | tuple[str]

List of globs to include during package search

re, regex, {None} | str

Only include packages including regular expression regex

f, json: {"vendorize.json"} | str

Name of JSON vendorize inputs file

toml: {"vendorize.toml"} | str

Name of TOML vendorize inputs file

Outputs:
pkgs: list[str]

List of packages with vendorization inputs (the package '' means the current folder has vendor inputs)

Versions:
  • 2021-08-23 @ddalle: Version 1.0

  • 2022-09-30 @ddalle: Version 1.1; add f, etc.

cape.attdb.vendorutils.get_package_name(req)

Get package name from full pip requirement

Call:
>>> pkg = get_package_name(req)
Inputs:
req: str

Any full requirement for pip install

Outputs:
pkg: str

Name of package provided by install

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.main()

Main command-line interface for vendorize command

Call:
>>> main()
Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.parse_dist_info(req, target)

Get version number, git commit hash, etc. from wheel info

Call:
>>> meta = parse_dist_info(req, target)
Inputs:
req: str

Package to install with pip

target: str

Folder in which to install vendorized packages

Outputs:
meta: dict

Metadata from .dist-info/ folder

meta[“url”]: str

Full string from which package was cloned

meta[“vcs_info”]: dict

Commit ID and version control software type dict

meta[“version”]: None | str

Version number read from METADATA file

Versions:
  • 2023-04-20 @ddalle: v1.0

cape.attdb.vendorutils.update_dist_info(req, target)

Save version number, git commit hash, etc. for a vendor

Call:
>>> update_dist_info(req, target)
Inputs:
req: str

Package to install with pip

target: str

Folder in which to install vendorized packages

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.vendorize_json(fjson, **kw)

Vendorize packages using vendorize.json file

Call:
>>> vendorize_json(fjson)
Inputs:
fjson: str

Absolute path to a vendorize.json path

re, regex: {None} | str

Include packages matching optional regular expression

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.vendorize_repo(*a, **kw)

Vendorize in all repos

Call:
>>> vendorize_repo(*a, **kw)
Inputs:
a: tuple[str]

Regular expressions for vendorized package(s)

cwd, where: {"."} | str

Location from which to search for target packages

t, target: {None} | str

Regular expression for packages in which to vendor

f, json: {"vendorize.json"} | str

Name of JSON vendorize inputs file

toml: {"vendorize.toml"} | str

Name of TOML vendorize inputs file

Versions:
  • 2021-08-23 @ddalle: Version 1.0

  • 2022-09-30 @ddalle: Version 1.1; add f, etc.

cape.attdb.vendorutils.vendorize_requirement(req, target)

Vendorize one package, updating if necessary

This slightly modifies the function of the same name from vendorize.

Call:
>>> ierr = vendorize_requirement(req, target)
Inputs:
req: str

Package to install with pip

target: str

Folder in which to install vendorized packages

Outputs:
ierr: int

Exit code from pip.main()

Versions:
  • 2021-08-23 @ddalle: Version 1.0

cape.attdb.vendorutils.vendorize_toml(ftoml, **kw)

Vendorize packages using vendorize.toml file

Call:
>>> vendorize_toml(ftoml)
Inputs:
ftmol: str

Absolute path to a vendorize.toml path

re, regex: {None} | str

Include packages matching optional regular expression

Versions:
  • 2021-08-23 @ddalle: Version 1.0