4. pkg_utils package¶
4.1. Submodules¶
4.2. pkg_utils._version module¶
4.3. pkg_utils.core module¶
Utilities for linking setuptools with package version metadata, GitHub README.md files, requirements.txt files, and restoring overridden entry points during for editable installations.
- Author
Jonathan Karr <jonrkarr@gmail.com>
- Date
2017-12-03
- Copyright
2017, Karr Lab
- License
MIT
-
class
pkg_utils.core.
PackageMetadata
[source]¶ Bases:
object
Metadata about a package
-
pkg_utils.core.
add_console_scripts
(dirname, package_name, console_scripts)[source]¶ Add console scripts for a package
- Parameters
dirname (
str
) – path to the packagepackage_name (
str
) – package nameconsole_scripts (
dict
ofdict
) – console script names and functions
-
pkg_utils.core.
convert_readme_md_to_rst
(dirname)[source]¶ Convert the README.md to README.rst
- Parameters
dirname (
str
) – path to the package
-
pkg_utils.core.
expand_package_data_filename_patterns
(dirname, package_data_filename_patterns=None)[source]¶ Expand the package data filenames
:param
dict
: package data
-
pkg_utils.core.
get_console_scripts
(dirname, package_name)[source]¶ Get the console scripts for a package
- Parameters
dirname (
str
) – path to the packagepackage_name (
str
) – package name
- Returns
console script names and functions
- Return type
dict
ofdict
-
pkg_utils.core.
get_dependencies
(dirname, include_uri=False, include_extras=True, include_specs=True, include_markers=True)[source]¶ Parse required and optional dependencies from requirements.txt files
- Parameters
dirname (
str
) – path to the packageinclude_uri (
bool
, optional) – ifTrue
, include URI in the dependencies listinclude_extras (
bool
, optional) – ifTrue
, include extras in the dependencies listinclude_specs (
bool
, optional) – ifTrue
, include specifications in the dependencies listinclude_markers (
bool
, optional) – ifTrue
, include markers in the dependencies list
- Returns
requirements
list
ofstr
: extra/optional requirementslist
ofstr
: test requirementslist
ofstr
: dependency links- Return type
list
ofstr
-
pkg_utils.core.
get_long_description
(dirname)[source]¶ Get the long description of a package from its README.rst file
- Parameters
dirname (
str
) – path to the package- Returns
long description
- Return type
str
-
pkg_utils.core.
get_package_metadata
(dirname, package_name, package_data_filename_patterns=None)[source]¶ Get meta data about a package
- Parameters
dirname (
str
) – path to the packagepackage_name (
str
) – package namepackage_data_filename_patterns (
dict
, optional) – package name, optionally with glob patterns in the filenames
- Returns
meta data
- Return type
:raises
ValueError:
if test or documentation dependencies are defined in requirements.optional.txt:
-
pkg_utils.core.
get_version
(dirname, package_name)[source]¶ Get the version a package from its version file (
package/_version.py
)- Parameters
dirname (
str
) – path to the packagepackage_name (
str
) – package name
- Returns
version
- Return type
str
-
pkg_utils.core.
install_dependencies
(dependencies, upgrade=False)[source]¶ Install dependencies
- Parameters
dependencies (
list
) – list of dependenciesupgrade (
bool
, optional) – ifTrue
, upgrade package
-
pkg_utils.core.
parse_optional_requirements_file
(filename, include_uri=False, include_extras=True, include_specs=True, include_markers=True)[source]¶ Parse a requirements.optional.txt file into list of requirements and dependency links
- Parameters
filename (
str
) – path to requirements.txt fileinclude_uri (
bool
, optional) – ifTrue
, include URI in the dependencies listinclude_extras (
bool
, optional) – ifTrue
, include extras in the dependencies listinclude_specs (
bool
, optional) – ifTrue
, include specifications in the dependencies listinclude_markers (
bool
, optional) – ifTrue
, include markers in the dependencies list
- Returns
requirements
list
ofstr
: dependency links- Return type
dict
oflist
ofstr
- Raises
ValueError – if a line cannot be parsed
-
pkg_utils.core.
parse_requirement_line
(line, include_uri=False, include_extras=True, include_specs=True, include_markers=True)[source]¶ Parse lines from a requirements.txt file into list of requirements and dependency links
- Parameters
line (
str
) – line from a requirements.txt fileinclude_uri (
bool
, optional) – ifTrue
, include URI in the dependencies listinclude_extras (
bool
, optional) – ifTrue
, include extras in the dependencies listinclude_specs (
bool
, optional) – ifTrue
, include specifications in the dependencies listinclude_markers (
bool
, optional) – ifTrue
, include markers in the dependencies list
- Returns
requirement
str
: dependency link- Return type
str
-
pkg_utils.core.
parse_requirement_lines
(lines, include_uri=False, include_extras=True, include_specs=True, include_markers=True)[source]¶ Parse lines from a requirements.txt file into list of requirements and dependency links
- Parameters
lines (
list
ofstr
) – lines from a requirements.txt fileinclude_uri (
bool
, optional) – ifTrue
, include URI in the dependencies listinclude_extras (
bool
, optional) – ifTrue
, include extras in the dependencies listinclude_specs (
bool
, optional) – ifTrue
, include specifications in the dependencies listinclude_markers (
bool
, optional) – ifTrue
, include markers in the dependencies list
- Returns
requirements
list
ofstr
: dependency links- Return type
list
ofstr
-
pkg_utils.core.
parse_requirements_file
(filename, include_uri=False, include_extras=True, include_specs=True, include_markers=True)[source]¶ Parse a requirements.txt file into list of requirements and dependency links
- Parameters
filename (
str
) – path to requirements.txt fileinclude_uri (
bool
, optional) – ifTrue
, include URI in the dependencies listinclude_extras (
bool
, optional) – ifTrue
, include extras in the dependencies listinclude_specs (
bool
, optional) – ifTrue
, include specifications in the dependencies listinclude_markers (
bool
, optional) – ifTrue
, include markers in the dependencies list
- Returns
requirements
list
ofstr
: dependency links- Return type
list
ofstr