feu 0.0.8a0__tar.gz → 0.0.8a2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: feu
3
- Version: 0.0.8a0
3
+ Version: 0.0.8a2
4
4
  Summary: A light library to help to manage packages
5
5
  Home-page: https://github.com/durandtibo/feu
6
6
  License: BSD-3-Clause
@@ -21,6 +21,8 @@ Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Topic :: Scientific/Engineering
23
23
  Classifier: Topic :: Software Development :: Libraries
24
+ Provides-Extra: all
25
+ Requires-Dist: fire (>=0.6.0,<1.0) ; extra == "all"
24
26
  Requires-Dist: packaging (>=21.0,<25.0)
25
27
  Project-URL: Repository, https://github.com/durandtibo/feu
26
28
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "feu"
3
- version = "0.0.8a0"
3
+ version = "0.0.8a2"
4
4
  description = "A light library to help to manage packages"
5
5
  readme = "README.md"
6
6
  authors = ["Thibaut Durand <durand.tibo+gh@gmail.com>"]
@@ -33,7 +33,11 @@ packages = [
33
33
  python = ">=3.9,<3.13"
34
34
  packaging = ">=21.0,<25.0"
35
35
 
36
+ # Optional dependencies
37
+ fire = { version = ">=0.6.0,<1.0", optional = true }
38
+
36
39
  [tool.poetry.extras]
40
+ all = ["fire"]
37
41
 
38
42
  [tool.poetry.group.docs]
39
43
  optional = true
@@ -82,6 +86,10 @@ addopts = "--color yes --durations 10 -rf"
82
86
  # Configuration of the short test summary info
83
87
  # https://docs.pytest.org/en/stable/usage.html#detailed-summary-report
84
88
 
89
+ filterwarnings = [
90
+ "ignore::DeprecationWarning:fire.*",
91
+ ]
92
+
85
93
  [tool.black]
86
94
  line-length = 100
87
95
  target-version = ["py39", "py310", "py311", "py312"]
@@ -2,8 +2,9 @@ r"""Contain to check if a package or module is available."""
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- __all__ = ["is_module_available", "is_package_available"]
5
+ __all__ = ["is_module_available", "is_package_available", "check_fire", "is_fire_available"]
6
6
 
7
+ from contextlib import suppress
7
8
  from functools import lru_cache
8
9
  from importlib import import_module
9
10
  from importlib.util import find_spec
@@ -33,10 +34,9 @@ def is_package_available(package: str) -> bool:
33
34
 
34
35
  ```
35
36
  """
36
- try:
37
+ with suppress(Exception):
37
38
  return find_spec(package) is not None
38
- except Exception: # noqa: BLE001
39
- return False
39
+ return False
40
40
 
41
41
 
42
42
  @lru_cache
@@ -67,3 +67,51 @@ def is_module_available(module: str) -> bool:
67
67
  except (ImportError, ModuleNotFoundError):
68
68
  return False
69
69
  return True
70
+
71
+
72
+ ################
73
+ # fire #
74
+ ################
75
+
76
+
77
+ @lru_cache
78
+ def is_fire_available() -> bool:
79
+ r"""Indicate if the ``fire`` package is installed or not.
80
+
81
+ Returns:
82
+ ``True`` if ``fire`` is available otherwise ``False``.
83
+
84
+ Example usage:
85
+
86
+ ```pycon
87
+
88
+ >>> from feu.imports import is_fire_available
89
+ >>> is_fire_available()
90
+
91
+ ```
92
+ """
93
+ return is_package_available("fire")
94
+
95
+
96
+ def check_fire() -> None:
97
+ r"""Check if the ``fire`` package is installed.
98
+
99
+ Raises:
100
+ RuntimeError: if the ``fire`` package is not installed.
101
+
102
+ Example usage:
103
+
104
+ ```pycon
105
+
106
+ >>> from feu.imports import check_fire
107
+ >>> check_fire()
108
+
109
+ ```
110
+ """
111
+ if not is_fire_available():
112
+ msg = (
113
+ "'fire' package is required but not installed. "
114
+ "You can install 'fire' package with the command:\n\n"
115
+ "pip install fire\n"
116
+ )
117
+ raise RuntimeError(msg)
@@ -26,8 +26,13 @@ from typing import ClassVar
26
26
 
27
27
  from packaging.version import Version
28
28
 
29
+ from feu.imports import check_fire, is_fire_available
30
+
29
31
  logger = logging.getLogger(__name__)
30
32
 
33
+ if is_fire_available():
34
+ import fire
35
+
31
36
 
32
37
  def run_bash_command(cmd: str) -> None:
33
38
  r"""Execute a bash command.
@@ -284,3 +289,8 @@ def install_package(package: str, version: str) -> None:
284
289
  ```
285
290
  """
286
291
  PackageInstaller.install(package, version)
292
+
293
+
294
+ if __name__ == "__main__": # pragma: no cover
295
+ check_fire()
296
+ fire.Fire(install_package)
@@ -16,6 +16,13 @@ class PackageConfig:
16
16
  """Implement the main package config registry."""
17
17
 
18
18
  registry: ClassVar[dict[str, dict[str, dict[str, str]]]] = {
19
+ # https://pypi.org/project/jaxlib/#history
20
+ "jax": {
21
+ "3.12": {"min": "0.4.17", "max": None},
22
+ "3.11": {"min": "0.4.6", "max": None},
23
+ "3.10": {"min": "0.4.6", "max": None},
24
+ "3.9": {"min": "0.4.6", "max": "0.4.30"},
25
+ },
19
26
  # https://numpy.org/devdocs/release.html
20
27
  "numpy": {
21
28
  "3.12": {"min": "1.26.0", "max": None},
@@ -23,11 +30,26 @@ class PackageConfig:
23
30
  "3.10": {"min": "1.21.3", "max": None},
24
31
  "3.9": {"min": "1.19.3", "max": "2.0.2"},
25
32
  },
33
+ # https://github.com/pandas-dev/pandas/releases
34
+ # https://pandas.pydata.org/docs/whatsnew/index.html
35
+ "pandas": {
36
+ "3.12": {"min": "2.1.0", "max": None},
37
+ "3.11": {"min": None, "max": None},
38
+ "3.10": {"min": None, "max": None},
39
+ "3.9": {"min": None, "max": None},
40
+ },
41
+ # https://arrow.apache.org/release/
42
+ "pyarrow": {
43
+ "3.12": {"min": "14.0.0", "max": None},
44
+ "3.11": {"min": "10.0.1", "max": None},
45
+ "3.10": {"min": "6.0.0", "max": None},
46
+ "3.9": {"min": "3.0.0", "max": "16.1.0"},
47
+ },
26
48
  # https://github.com/pytorch/pytorch/releases
27
49
  "torch": {
28
50
  "3.12": {"min": "2.4.0", "max": None},
29
51
  "3.11": {"min": "1.13.0", "max": None},
30
- "3.10": {"min": None, "max": None},
52
+ "3.10": {"min": "1.11.0", "max": None},
31
53
  "3.9": {"min": None, "max": None},
32
54
  },
33
55
  }
@@ -0,0 +1,11 @@
1
+ r"""Define some utility functions for testing."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __all__ = ["fire_available"]
6
+
7
+ import pytest
8
+
9
+ from feu.imports import is_fire_available
10
+
11
+ fire_available = pytest.mark.skipif(not is_fire_available(), reason="Requires fire")
File without changes
File without changes
File without changes
File without changes