mypythontools_cicd.packages package¶
For example you can work with requirements or with versions here. Usually used in ‘setup.py’.
- mypythontools_cicd.packages.get_package_setup_args(name: str, development_status: Literal['alpha', 'beta', 'stable'] = 'alpha') dict[str, Any] [source]¶
Get setup args, that usually repeats across projects.
- Parameters
name (str) – Name used to generate some params.
development_status (Literal['alpha', 'beta', 'stable']) – Project phase. Defaults to ‘alpha’.
- Returns
- Attributes used in setup.py. E.g. license, platform
or long_description_content_type.
- Return type
dict[str, Any]
- mypythontools_cicd.packages.get_readme() str [source]¶
Get README content into variable usually used in setup.py.
- Returns
Content.
- Return type
str
- mypythontools_cicd.packages.get_requirements(files: Literal['infer'] | PathLike | Sequence[PathLike], path: PathLike = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mypythontools-cicd/checkouts/latest/docs/source')) list[str] [source]¶
Get requirements into variable usually used in setup.py.
- Parameters
files (Literal["infer"] | PathLike | Sequence[PathLike]) – E.g. [“requirements.txt”, “requirements_dev.txt”]. If ‘infer’, then every file where requirements is in the name is used. It can be also absolute paths.
path (PathLike, optional) – If using just names or relative path, and not found, define the root. It’s also necessary when using another referenced files. If inferring files, it’s used to search. Defaults to PROJECT_PATHS.root.
- Returns
List of requirements
- Return type
list[str]
- Raises
RuntimeError – If no requirements files found with ‘infer’.
- mypythontools_cicd.packages.get_requirements_files(requirements: Literal['infer'] | PathLike | Sequence[PathLike], path: PathLike = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/mypythontools-cicd/checkouts/latest/docs/source')) list[Path] [source]¶
Consolidate requirements into list of paths.
- Parameters
requirements (Literal["infer"] | PathLike | Sequence[PathLike]) – E.g. [“requirements.txt”, “requirements_dev.txt”]. If ‘infer’, then every file where requirements is in the name is used. It working with one level of nested folder if requirements is in the name of the file or folder.
path (PathLike, optional) – If using just names or relative path, and not found, define the root. It’s also necessary when using another referenced files. If inferring files, it’s used to search. Defaults to PROJECT_PATHS.root.
- Returns
List of paths to requirements files.
- Return type
list[Path]
- Raises
RuntimeError – If no requirements found with ‘infer’.
- mypythontools_cicd.packages.get_version(init_path: None | PathLike = None) str [source]¶
Get version info from __init__.py file.
- Parameters
init_path (None | PathLike, optional) – Path to __init__.py file. If None, will be inferred. Defaults to None.
- Returns
String of version from __init__.py.
- Return type
str
- Raises
ValueError – If no __version__ is find. Try set init_path…
Example
>>> version = get_version() >>> len(version.split(".")) == 3 and all([i.isdecimal() for i in version.split(".")]) True
- mypythontools_cicd.packages.increment_version(version: str) str [source]¶
Increment patch version by one.
- Parameters
version (str) – String format. It can include ‘v’ prefix.
- Returns
Incremented version
- Return type
str
Example
>>> increment_version("1.2.3") '1.2.4' >>> increment_version("v1.2.3") 'v1.2.4'
- mypythontools_cicd.packages.set_version(version: str = 'increment', init_path: None | PathLike = None) None [source]¶
Change your version in your __init__.py file.
- Parameters
version (str, optional) – Form that is used in __init__, so for example “1.2.3”. Do not use ‘v’ appendix. If version is ‘increment’, it will increment your __version__ in you __init__.py by 0.0.1. Defaults to “increment”.
init_path (None | PathLike, optional) – Path of file where __version__ is defined. Usually __init__.py. If None, will be inferred. Defaults to None.
- Raises
ValueError – If no __version__ is find.