Skip to content

Commit

Permalink
Split ssh2-python into an extra dependency (#264)
Browse files Browse the repository at this point in the history
The intent of this change is to get us back to publishing Broker to
PyPi. In order to do this, I split the ssh2-python github dependency
from the main dependencies and into the the extras.
As part of this, this also allows users to choose their ssh2-python
backend (3.12 fork or 3.11 and earlier main package).
  • Loading branch information
JacobCallahan authored Feb 8, 2024
1 parent 4295397 commit 61ea8d5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ Install Broker either by cloning locally with `pip install .` or with `pip insta

Copy the example settings file to `broker_settings.yaml` and edit it.

(optional) If you are using Broker for ssh-based host interaction, install one of the supported ssh backends.
```
# For python 3.12+
pip install broker[ssh2]
# For python 3.11 and below
pip install broker[ssh2_py311]
```

(optional) If you are using the Container provider, install the extra dependency based on your container runtime of choice with either `pip install broker[podman]` or `pip install broker[docker]`.

(optional) If you are using the Beaker provider, install the extra dependency with `dnf install krb5-devel` and then `pip install broker[beaker]`.
Expand Down
27 changes: 16 additions & 11 deletions broker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,25 @@
import tempfile

from logzero import logger
from ssh2 import sftp as ssh2_sftp
from ssh2.session import Session as ssh2_Session

from broker import exceptions, helpers

SESSIONS = {}

SFTP_MODE = (
ssh2_sftp.LIBSSH2_SFTP_S_IRUSR
| ssh2_sftp.LIBSSH2_SFTP_S_IWUSR
| ssh2_sftp.LIBSSH2_SFTP_S_IRGRP
| ssh2_sftp.LIBSSH2_SFTP_S_IROTH
)
FILE_FLAGS = ssh2_sftp.LIBSSH2_FXF_CREAT | ssh2_sftp.LIBSSH2_FXF_WRITE
try:
from ssh2 import sftp as ssh2_sftp
from ssh2.session import Session as ssh2_Session

SFTP_MODE = (
ssh2_sftp.LIBSSH2_SFTP_S_IRUSR
| ssh2_sftp.LIBSSH2_SFTP_S_IWUSR
| ssh2_sftp.LIBSSH2_SFTP_S_IRGRP
| ssh2_sftp.LIBSSH2_SFTP_S_IROTH
)
FILE_FLAGS = ssh2_sftp.LIBSSH2_FXF_CREAT | ssh2_sftp.LIBSSH2_FXF_WRITE
except ImportError:
logger.warning(
"ssh2-python is not installed, ssh actions will not work.\n"
"To use ssh, run pip install broker[ssh2]."
)


def _create_connect_socket(host, port, timeout, ipv6=False, ipv4_fallback=True, sock=None):
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ dependencies = [
"packaging",
"pyyaml",
"setuptools",
"ssh2-python@git+https://github.com/jacobcallahan/ssh2-python.git"
]
dynamic = ["version"] # dynamic fields to update on build - version via setuptools_scm

[project.urls]
Repository = "https://github.com/SatelliteQE/broker"

[project.optional-dependencies]
beaker = ["beaker-client"]
dev = [
"pre-commit",
"pytest",
Expand All @@ -48,11 +48,12 @@ docker = [
"paramiko"
]
podman = ["podman-py"]
beaker = ["beaker-client"]
setup = [
"build",
"twine",
]
ssh2 = ["ssh2-python@git+https://github.com/jacobcallahan/ssh2-python.git"]
ssh2_py311 = ["ssh2-python"]

[project.scripts]
broker = "broker.commands:cli"
Expand Down

0 comments on commit 61ea8d5

Please sign in to comment.