Skip to content

Commit

Permalink
Remove download docker client functionality (#633)
Browse files Browse the repository at this point in the history
Removes dependency on typer/tqdm/requests by dropping support for
downloading the docker client.

Initially agreed at
#512 (comment),
this has been deprecated since
#577 (v0.71.0
released in April 2024), and agreed we can now remove at
#552 (comment).
If accepted, this supercedes
#513 as a
resolution to
#512. We
will also be able to close
#575.
  • Loading branch information
LewisGaul authored Oct 13, 2024
1 parent 30f2905 commit 2e08c98
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 304 deletions.
26 changes: 11 additions & 15 deletions docs/template/docker_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,25 @@ In the end, unless you use this type of logic in your code,
Python-on-whales is safe to use with multithreading and multiprocessing.


# The Docker CLI
# The Docker/Podman CLI

Python-on-whales needs the Docker CLI to work (unlike docker-py).
Python-on-whales needs the Docker or Podman CLI to work (unlike docker-py).
Most of the time, users already have the CLI installed on their machines. It's possible to
verify that the CLI is there by doing `docker --help` in the command line.
verify that the CLI is there by doing `docker --help` (or `podman --help`) in the command line.

Sometimes, the CLI might not be available on the system, it can happen if you want to control
Docker from within a container with `-v /var/run/docker.sock:/var/run/docker.sock`, or if you
want to connect to a remote daemon with the `host` argument.

In this case, when using python-on-whales, the CLI will be downloaded automatically
(it's a single binary), and will be put in
```python
pathlib.Path.home() / ".cache/python-on-whales/docker"
```
Since it's not in the PATH and was not downloaded with the package manager, it's only seen and
used by python-on-whales.
Instructions for installing Docker can be found at <https://docs.docker.com/engine/install/>,
and Podman at <https://podman.io/docs/installation/>. Note that if connecting to Docker/Podman
remotely then the Docker daemon (`dockerd`) is not needed, and similarly for Podman it is
possible to use `podman-remote` (available as a static binary from
<https://github.com/containers/podman/releases/latest>).

Previously, when using python-on-whales, the Docker CLI was downloaded automatically, but
this functionality was removed under <https://github.com/gabrieldemarmiesse/python-on-whales/pull/633>.

If you want to trigger the download manually (to avoid downloading the CLI at runtime),
you can run from your shell:
```bash
python-on-whales download-cli
```

# Handling an unavailable client

Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ dev = ["ruff==0.5.6"]
"Documentation" = "https://gabrieldemarmiesse.github.io/python-on-whales/"
"Bug Tracker" = "https://github.com/gabrieldemarmiesse/python-on-whales/issues"

[project.scripts]
python-on-whales = "python_on_whales.command_line_entrypoint:main"

[tool.setuptools.packages.find]
exclude = ["tests*", "docs*"]

Expand Down
38 changes: 7 additions & 31 deletions python_on_whales/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@

import pydantic

from python_on_whales.download_binaries import (
download_docker_cli,
get_docker_binary_path_in_cache,
)

from . import utils
from .utils import ValidPath, run, to_list

Expand Down Expand Up @@ -92,32 +87,13 @@ def get_client_call_with_path(self) -> List[Union[Path, str]]:

def _get_docker_path(self) -> str:
which_result = shutil.which(self.client_call[0])
if which_result is not None:
return which_result
if self.client_call[0] == "docker":
if not get_docker_binary_path_in_cache().exists():
warnings.warn(
"The docker client binary file was not found on your system. \n"
"Docker on whales will try to download it for you. \n"
"Don't worry, it "
"won't be in the PATH and won't have anything to do with "
"the package manager of your system. \n"
"Note: We are not installing the docker daemon, which is a lot "
"heavier and harder to install. We're just downloading a single "
"standalone binary file.\n"
"If you want to trigger the download of the client binary file "
"manually (for example if you want to do it in a Dockerfile), "
"you can run the following command:\n "
"$ python-on-whales download-cli \n"
)
download_docker_cli()
return get_docker_binary_path_in_cache()

raise ClientNotFoundError(
f"The binary '{self.client_call[0]}' could not be found on your PATH. "
f"Please ensure that your PATH is has the directory of the binary you're looking for. "
f"You can use `print(os.environ['PATH'])` to verify what directories are in your PATH."
)
if which_result is None:
raise ClientNotFoundError(
f"The binary '{self.client_call[0]}' could not be found on your PATH. "
"Please ensure that your PATH has the directory of the binary you're looking for. "
"You can use `print(os.environ['PATH'])` to verify what directories are in your PATH."
)
return which_result

@property
def docker_cmd(self) -> Command:
Expand Down
63 changes: 0 additions & 63 deletions python_on_whales/command_line_entrypoint.py

This file was deleted.

137 changes: 0 additions & 137 deletions python_on_whales/download_binaries.py

This file was deleted.

3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
pydantic>=2,<3,!=2.0.*
requests
tqdm
typer>=0.4.1
typing_extensions
52 changes: 0 additions & 52 deletions tests/python_on_whales/test_download_binaries.py

This file was deleted.

0 comments on commit 2e08c98

Please sign in to comment.