Main functions¶
feu ¶
Root package of feu
.
feu.compare_version ¶
compare_version(
package: str, op: Callable, version: str
) -> bool
Compare a package version to a given version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package
|
str
|
Specifies the package to check. |
required |
op
|
Callable
|
Specifies the comparison operator. |
required |
version
|
str
|
Specifies the version to compare with. |
required |
Returns:
Type | Description |
---|---|
bool
|
The comparison status. |
Example usage:
>>> import operator
>>> from feu.version import compare_version
>>> compare_version("pytest", op=operator.ge, version="7.3.0")
True
feu.get_package_version ¶
get_package_version(package: str) -> Version | None
Get the package version.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package
|
str
|
Specifies the package name. |
required |
Returns:
Type | Description |
---|---|
Version | None
|
The package version. |
Example usage:
>>> from feu.version import get_package_version
>>> get_package_version("pytest")
<Version('...')>
feu.install_package ¶
install_package(
installer: InstallerSpec, package: PackageSpec
) -> None
Install a package with the specified installer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
installer
|
InstallerSpec
|
The installer specification. |
required |
package
|
PackageSpec
|
The package specification. |
required |
Example usage:
>>> from feu.install import install_package
>>> from feu.utils.installer import InstallerSpec
>>> from feu.utils.package import PackageSpec
>>> install_package(
... installer=InstallerSpec("pip"), package=PackageSpec(name="pandas", version="2.2.2")
... ) # doctest: +SKIP
feu.install_package_closest_version ¶
install_package_closest_version(
installer: InstallerSpec, package: PackageSpec
) -> None
Install a package and associated packages by using the secified installer.
This function finds the closest valid version if the specified version is not compatible.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
installer
|
InstallerSpec
|
The installer specification. |
required |
package
|
PackageSpec
|
The package specification. |
required |
Example usage:
>>> from feu.install import install_package_closest_version
>>> from feu.utils.installer import InstallerSpec
>>> from feu.utils.package import PackageSpec
>>> install_package_closest_version(
... installer=InstallerSpec("pip"), package=PackageSpec(name="pandas", version="2.2.2")
... ) # doctest: +SKIP
feu.is_module_available
cached
¶
is_module_available(module: str) -> bool
Check if a module path is available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module
|
str
|
The module to check. |
required |
Example usage:
>>> from feu import is_module_available
>>> is_module_available("os")
True
>>> is_module_available("os.path")
True
>>> is_module_available("missing.module")
False
feu.is_package_available
cached
¶
is_package_available(package: str) -> bool
Check if a package is available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package
|
str
|
The package name to check. |
required |
Returns:
Type | Description |
---|---|
bool
|
|
Example usage:
>>> from feu import is_package_available
>>> is_package_available("os")
True
>>> is_package_available("os.path")
True
>>> is_package_available("my_missing_package")
False