venv_management.utilities module

Utility functions.

Summary

Functions:

compatible_versions

Determine whether two versions are equal.

parse_package_arg

Make a command-line argument string specifing whether and which verison of a package to install.

str_to_bool

Convert a string representation of truth to true (1) or false (0).

Reference

venv_management.utilities.compatible_versions(actual_version: str, required_version: str) bool[source]

Determine whether two versions are equal.

Only the dot separated elements in common are taken into account, so actual “3.7.4” compared with “3.7” will return True.

Parameters
  • actual_version – A dot separated version.

  • required_version – A dot separated version.

Returns

True if the actual_version is compatible with the required_version, otherwise False.

venv_management.utilities.parse_package_arg(name, arg)[source]

Make a command-line argument string specifing whether and which verison of a package to install.

Parameters
  • name – The name of the package.

  • arg – True if the package is required, False if the package is not required, or a string containing a version number if a specific version of the package is required.

Returns

A string which can be used as an argument to the virtualenv command.

venv_management.utilities.str_to_bool(val)[source]

Convert a string representation of truth to true (1) or false (0).

True values are ‘y’, ‘yes’, ‘t’, ‘true’, ‘on’, and ‘1’; false values are ‘n’, ‘no’, ‘f’, ‘false’, ‘off’, and ‘0’. Raises ValueError if ‘val’ is anything else.