diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index a9c6be8..3b82e9b 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -51,7 +51,7 @@ jobs: python -m pip install -U build - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: Build a binary wheel and a source tarball run: >- @@ -90,7 +90,7 @@ jobs: python -m pip install -U -r requirements/packaging.txt - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: Generates Executable run: python -O ./builder/pyinstaller_build_macos.py @@ -123,7 +123,7 @@ jobs: python -m pip install -U -r requirements/packaging.txt - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: Generates Executable run: python -O ./builder/pyinstaller_build_ubuntu.py @@ -157,7 +157,7 @@ jobs: python -m pip install -U -r requirements/packaging.txt - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: Generates MS Version Info run: python .\builder\version_info_templater.py diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 5179303..500de64 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -53,7 +53,7 @@ jobs: python -m pip install -U -r requirements.txt - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: Génère les exemples de sortie env: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de1f916..7425e69 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,7 +44,7 @@ jobs: python -m pip install -U -r requirements/testing.txt - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: Unit tests run: pytest @@ -76,7 +76,7 @@ jobs: python -m pip install -U -r requirements.txt - name: Install project as a package - run: python -m pip install -e . + run: python -m pip install -e .[all] - name: CLI - Echoing version run: geotribu --version diff --git a/docs/development/setup.md b/docs/development/setup.md index cb3476b..effae69 100644 --- a/docs/development/setup.md +++ b/docs/development/setup.md @@ -26,6 +26,6 @@ source .venv/bin/activate python -m pip install -U pip setuptools wheel # installation des dépendances de base python -m pip install -U -r requirements.txt -# installation du projet en mode développement -python -m pip install -e . +# installation du projet en mode développement avec toutes les dépendances fonctionnelles +python -m pip install -e .[all,dev,doc,test] ``` diff --git a/docs/usage/installation.md b/docs/usage/installation.md index 7dcb715..10fd607 100644 --- a/docs/usage/installation.md +++ b/docs/usage/installation.md @@ -27,7 +27,7 @@ MacOS version is not tested and is just here to encourage beta-testing and feedb ### Installer ```sh -pip install --user --upgrade geotribu +pip install --upgrade geotribu ``` L'outil est désormais disponible en ligne de commande. Voir les [exemples](/usage/examples). diff --git a/geotribu_cli/images/images_optimizer.py b/geotribu_cli/images/images_optimizer.py index 77762d0..a7854ae 100644 --- a/geotribu_cli/images/images_optimizer.py +++ b/geotribu_cli/images/images_optimizer.py @@ -12,9 +12,10 @@ from pathlib import Path # package +from geotribu_cli.__about__ import __package_name__ from geotribu_cli.console import console from geotribu_cli.constants import GeotribuDefaults -from geotribu_cli.images.optim_tinify import optimize_with_tinify +from geotribu_cli.images.optim_tinify import TINIFY_INSTALLED, optimize_with_tinify from geotribu_cli.utils.check_path import check_path from geotribu_cli.utils.start_uri import open_uri from geotribu_cli.utils.str2bool import str2bool @@ -109,6 +110,15 @@ def run(args: argparse.Namespace): # check Tinify API KEY if args.tool_to_use == "tinypng": + if not TINIFY_INSTALLED: + logger.critical( + "Tinify n'est pas installé, le service ne peut donc pas être utilisé. " + "Pour l'utiliser, installer l'outil avec les dépendances " + f"supplémentaires : pip install {__package_name__}[img-remote] ou " + f"pip install {__package_name__}[all]" + ) + sys.exit(1) + if not getenv("TINIFY_API_KEY"): logger.critical( "La clé d'API de Tinify n'est pas configurée en variable " diff --git a/geotribu_cli/images/optim_tinify.py b/geotribu_cli/images/optim_tinify.py index 15ed695..ac3380c 100644 --- a/geotribu_cli/images/optim_tinify.py +++ b/geotribu_cli/images/optim_tinify.py @@ -13,7 +13,12 @@ from urllib.parse import unquote, urlsplit # 3rd party -import tinify +try: + import tinify + + TINIFY_INSTALLED = True +except ImportError: + TINIFY_INSTALLED = False # package from geotribu_cli.constants import GeotribuDefaults diff --git a/requirements/base.txt b/requirements/base.txt index 9efe15a..84aff7f 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -5,5 +5,4 @@ orjson>=3.8,<3.10 packaging>=20,<24 rich_argparse>=0.6,<1.4 python-frontmatter>=1,<2 -tinify>=1.6,<2 typing-extensions>=4,<5 ; python_version < '3.11' diff --git a/requirements/extra.img-remote.txt b/requirements/extra.img-remote.txt new file mode 100644 index 0000000..7fa1fa2 --- /dev/null +++ b/requirements/extra.img-remote.txt @@ -0,0 +1 @@ +tinify>=1.6,<2 diff --git a/setup.py b/setup.py index 7074477..453111d 100644 --- a/setup.py +++ b/setup.py @@ -100,9 +100,15 @@ def load_requirements(requirements_files: Union[Path, list[Path]]) -> list: include_package_data=True, install_requires=load_requirements(HERE / "requirements/base.txt"), extras_require={ + # tooling "dev": load_requirements(HERE / "requirements/development.txt"), "doc": load_requirements(HERE / "requirements/documentation.txt"), "test": load_requirements(HERE / "requirements/testing.txt"), + # functional + "all": load_requirements( + list(HERE.joinpath("requirements").glob("extra.*.txt")) + ), + "img-remote": load_requirements(HERE / "requirements/extra.img-remote.txt"), }, # cli entry_points={