Package
feu.package ¶
Contain functions to check a package configuration.
feu.package.PackageConfig ¶
Implement the main package config registry.
feu.package.PackageConfig.add_config
classmethod
¶
add_config(
pkg_name: str,
pkg_version_min: str | None,
pkg_version_max: str | None,
python_version: str,
exist_ok: bool = False,
) -> None
Add a new package configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
pkg_version_min
|
str | None
|
The minimum valid package version for
this configuration. |
required |
pkg_version_max
|
str | None
|
The maximum valid package version for
this configuration. |
required |
python_version
|
str
|
The python version. |
required |
exist_ok
|
bool
|
If |
False
|
Raises:
Type | Description |
---|---|
RuntimeError
|
if a package configuration is already
registered and |
Example usage:
>>> from feu.package import PackageConfig
>>> PackageConfig.add_config(
... pkg_name="my_package",
... python_version="3.11",
... pkg_version_min="1.2.0",
... pkg_version_max="2.0.2",
... exist_ok=True,
... )
feu.package.PackageConfig.find_closest_version
classmethod
¶
find_closest_version(
pkg_name: str, pkg_version: str, python_version: str
) -> str
Find the closest valid version given the package name and version, and python version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
pkg_version
|
str
|
The package version to check. |
required |
python_version
|
str
|
The python version. |
required |
Returns:
Type | Description |
---|---|
str
|
The closest valid version. |
Example usage:
>>> from feu.package import PackageConfig
>>> PackageConfig.find_closest_version(
... pkg_name="numpy",
... pkg_version="2.0.2",
... python_version="3.11",
... )
2.0.2
>>> PackageConfig.find_closest_version(
... pkg_name="numpy",
... pkg_version="1.0.2",
... python_version="3.11",
... )
1.23.2
feu.package.PackageConfig.get_config
classmethod
¶
get_config(
pkg_name: str, python_version: str
) -> dict[str, str]
Get a package configuration given the package name and python version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
python_version
|
str
|
The python version. |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
The package configuration. |
Example usage:
>>> from feu.package import PackageConfig
>>> PackageConfig.get_config(
... pkg_name="numpy",
... python_version="3.11",
... )
{'min': '1.23.2', 'max': None}
feu.package.PackageConfig.get_min_and_max_versions
classmethod
¶
get_min_and_max_versions(
pkg_name: str, python_version: str
) -> tuple[Version | None, Version | None]
Get the minimum and maximum versions for the given package name and python version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
python_version
|
str
|
The python version. |
required |
Returns:
Type | Description |
---|---|
tuple[Version | None, Version | None]
|
A tuple with the minimum and maximum versions.
The version is set to |
Example usage:
>>> from feu.package import PackageConfig
>>> PackageConfig.get_min_and_max_versions(
... pkg_name="numpy",
... python_version="3.11",
... )
(<Version('1.23.2')>, None)
feu.package.PackageConfig.is_valid_version
classmethod
¶
is_valid_version(
pkg_name: str, pkg_version: str, python_version: str
) -> bool
Indicate if the specified package version is valid for the given Python version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
pkg_version
|
str
|
The package version to check. |
required |
python_version
|
str
|
The python version. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
Example usage:
>>> from feu.package import PackageConfig
>>> PackageConfig.is_valid_version(
... pkg_name="numpy",
... pkg_version="2.0.2",
... python_version="3.11",
... )
True
>>> PackageConfig.is_valid_version(
... pkg_name="numpy",
... pkg_version="1.0.2",
... python_version="3.11",
... )
False
feu.package.find_closest_version ¶
find_closest_version(
pkg_name: str, pkg_version: str, python_version: str
) -> str
Find the closest valid version given the package name and version, and python version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
pkg_version
|
str
|
The package version to check. |
required |
python_version
|
str
|
The python version. |
required |
Returns:
Type | Description |
---|---|
str
|
The closest valid version. |
Example usage:
>>> from feu.package import find_closest_version
>>> find_closest_version(
... pkg_name="numpy",
... pkg_version="2.0.2",
... python_version="3.11",
... )
2.0.2
>>> find_closest_version(
... pkg_name="numpy",
... pkg_version="1.0.2",
... python_version="3.11",
... )
1.23.2
feu.package.is_valid_version ¶
is_valid_version(
pkg_name: str, pkg_version: str, python_version: str
) -> bool
Indicate if the specified package version is valid for the given Python version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pkg_name
|
str
|
The package name. |
required |
pkg_version
|
str
|
The package version to check. |
required |
python_version
|
str
|
The python version. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
Example usage:
>>> from feu.package import is_valid_version
>>> is_valid_version(
... pkg_name="numpy",
... pkg_version="2.0.2",
... python_version="3.11",
... )
True
>>> is_valid_version(
... pkg_name="numpy",
... pkg_version="1.0.2",
... python_version="3.11",
... )
False