mirror of
https://github.com/containers/podman.git
synced 2025-06-23 10:38:20 +08:00
[WIP] Refactor and simplify python builds
* pypodman namespaced in site-packages * version numbers pulled from requirements.txt * add python-podman spec file to install eggs Signed-off-by: Jhon Honce <jhonce@redhat.com> Closes: #1106 Approved by: rhatdan
This commit is contained in:
@ -2,7 +2,11 @@ PYTHON ?= /usr/bin/python3
|
||||
|
||||
.PHONY: python-podman
|
||||
python-podman:
|
||||
$(PYTHON) setup.py bdist
|
||||
$(PYTHON) setup.py sdist bdist
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
$(PYTHON) -m pylint podman
|
||||
|
||||
.PHONY: integration
|
||||
integration:
|
||||
@ -10,12 +14,18 @@ integration:
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
$(PYTHON) setup.py install --user
|
||||
$(PYTHON) setup.py install
|
||||
|
||||
.PHONY: clobber
|
||||
clobber: uninstall clean
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
$(PYTHON) -m pip uninstall --yes podman ||:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(PYTHON) setup.py clean --all
|
||||
pip3 uninstall podman ||:
|
||||
rm -rf podman.egg-info dist
|
||||
find . -depth -name __pycache__ -exec rm -rf {} \;
|
||||
find . -depth -name \*.pyc -exec rm -f {} \;
|
||||
|
@ -6,11 +6,12 @@ See [libpod](https://github.com/projectatomic/libpod)
|
||||
|
||||
## Releases
|
||||
|
||||
To build the podman egg:
|
||||
To build the podman egg and install as user:
|
||||
|
||||
```sh
|
||||
cd ~/libpod/contrib/python
|
||||
python3 setup.py clean -a && python3 setup.py bdist
|
||||
cd ~/libpod/contrib/python/podman
|
||||
python3 setup.py clean -a && python3 setup.py sdist bdist
|
||||
python3 setup.py install --user
|
||||
```
|
||||
|
||||
## Code snippets/examples:
|
||||
|
@ -4,7 +4,7 @@ import pkg_resources
|
||||
from .client import Client
|
||||
from .libs import datetime_format, datetime_parse
|
||||
from .libs.errors import (ContainerNotFound, ErrorOccurred, ImageNotFound,
|
||||
RuntimeError)
|
||||
PodmanError)
|
||||
|
||||
try:
|
||||
__version__ = pkg_resources.get_distribution('podman').version
|
||||
@ -18,5 +18,5 @@ __all__ = [
|
||||
'datetime_parse',
|
||||
'ErrorOccurred',
|
||||
'ImageNotFound',
|
||||
'RuntimeError',
|
||||
'PodmanError',
|
||||
]
|
||||
|
@ -43,7 +43,7 @@ class ErrorOccurred(VarlinkErrorProxy):
|
||||
pass
|
||||
|
||||
|
||||
class RuntimeError(VarlinkErrorProxy):
|
||||
class PodmanError(VarlinkErrorProxy):
|
||||
"""Raised when Client fails to connect to runtime."""
|
||||
|
||||
pass
|
||||
@ -53,7 +53,7 @@ error_map = {
|
||||
'io.projectatomic.podman.ContainerNotFound': ContainerNotFound,
|
||||
'io.projectatomic.podman.ErrorOccurred': ErrorOccurred,
|
||||
'io.projectatomic.podman.ImageNotFound': ImageNotFound,
|
||||
'io.projectatomic.podman.RuntimeError': RuntimeError,
|
||||
'io.projectatomic.podman.RuntimeError': PodmanError,
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
varlink>=26.1.0
|
||||
setuptools>=39.2.0
|
||||
python-dateutil>=2.7.3
|
||||
python-dateutil
|
||||
setuptools>=39
|
||||
varlink
|
||||
|
@ -15,24 +15,22 @@ with open(os.path.join(root, 'requirements.txt')) as r:
|
||||
setup(
|
||||
name='podman',
|
||||
version=os.environ.get('PODMAN_VERSION', '0.0.0'),
|
||||
description='A client for communicating with a Podman server',
|
||||
long_description=readme,
|
||||
description='A library for communicating with a Podman server',
|
||||
author='Jhon Honce',
|
||||
author_email='jhonce@redhat.com',
|
||||
url='http://github.com/projectatomic/libpod',
|
||||
license='Apache Software License',
|
||||
python_requires='>=3',
|
||||
long_description=readme,
|
||||
include_package_data=True,
|
||||
install_requires=requirements,
|
||||
packages=find_packages(exclude=['test']),
|
||||
python_requires='>=3',
|
||||
zip_safe=True,
|
||||
url='http://github.com/projectatomic/libpod',
|
||||
keywords='varlink libpod podman',
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
'Topic :: Software Development',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Topic :: Software Development',
|
||||
])
|
||||
# Not supported
|
||||
# long_description_content_type='text/markdown',
|
||||
|
@ -1 +1,2 @@
|
||||
prune test/
|
||||
include README.md
|
||||
|
@ -2,7 +2,11 @@ PYTHON ?= /usr/bin/python3
|
||||
|
||||
.PHONY: python-pypodman
|
||||
python-pypodman:
|
||||
$(PYTHON) setup.py bdist
|
||||
$(PYTHON) setup.py sdist bdist
|
||||
|
||||
.PHONY: lint
|
||||
lint:
|
||||
$(PYTHON) -m pylint pypodman
|
||||
|
||||
.PHONY: integration
|
||||
integration:
|
||||
@ -10,12 +14,17 @@ integration:
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
$(PYTHON) setup.py install --user
|
||||
$(PYTHON) setup.py install
|
||||
|
||||
.PHONY: clobber
|
||||
clobber: uninstall clean
|
||||
|
||||
.PHONY: uninstall
|
||||
$(PYTHON) -m pip uninstall --yes pypodman ||:
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(PYTHON) setup.py clean --all
|
||||
pip3 uninstall pypodman ||:
|
||||
rm -rf pypodman.egg-info dist
|
||||
find . -depth -name __pycache__ -exec rm -rf {} \;
|
||||
find . -depth -name \*.pyc -exec rm -f {} \;
|
||||
|
@ -1,17 +1,19 @@
|
||||
# pypodman - CLI interface for podman written in python
|
||||
# pypodman - CLI for podman written in python
|
||||
|
||||
## Status: Active Development
|
||||
|
||||
See [libpod](https://github.com/projectatomic/libpod/contrib/python/cmd)
|
||||
See [libpod](https://github.com/projectatomic/libpod/contrib/python/pypodman)
|
||||
|
||||
## Releases
|
||||
|
||||
To build the pypodman egg:
|
||||
To build the pypodman egg and install as user:
|
||||
|
||||
```sh
|
||||
cd ~/libpod/contrib/python/cmd
|
||||
python3 setup.py clean -a && python3 setup.py bdist
|
||||
cd ~/libpod/contrib/python/pypodman
|
||||
python3 setup.py clean -a && python3 setup.py sdist bdist
|
||||
python3 setup.py install --user
|
||||
```
|
||||
Add `~/.local/bin` to your `PATH` to run pypodman command.
|
||||
|
||||
## Running command:
|
||||
|
||||
|
96
contrib/python/pypodman/docs/man1/pypodman.1
Normal file
96
contrib/python/pypodman/docs/man1/pypodman.1
Normal file
@ -0,0 +1,96 @@
|
||||
.TH pypodman 1 2018-07-20 0.7.3
|
||||
.SH NAME
|
||||
pypodman \- CLI management tool for containers and images
|
||||
.SH SYNOPSIS
|
||||
\f[B]pypodman\f[] [\f[I]global options\f[]] \f[I]command\f[] [\f[I]options\f[]]
|
||||
.SH DESCRIPTION
|
||||
pypodman is a simple client only tool to help with debugging issues when daemons
|
||||
such as CRI runtime and the kubelet are not responding or failing.
|
||||
.P
|
||||
pypodman uses a VarLink API to commicate with a podman service running on either
|
||||
the local or remote machine. pypodman uses ssh to create secure tunnels when
|
||||
communicating with a remote service.
|
||||
.SH GLOBAL OPTIONS
|
||||
.PP
|
||||
\f[B]\[en]help, \-h\f[]
|
||||
.PP
|
||||
Print usage statement.
|
||||
.PP
|
||||
\f[B]\[en]version\f[]
|
||||
.PP
|
||||
Print program version number and exit.
|
||||
.PP
|
||||
\f[B]\[en]config\-home\f[]
|
||||
.PP
|
||||
Directory that will be namespaced with \f[C]pypodman\f[] to hold
|
||||
\f[C]pypodman.conf\f[].
|
||||
See FILES below for more details.
|
||||
.PP
|
||||
\f[B]\[en]log\-level\f[]
|
||||
.PP
|
||||
Log events above specified level: DEBUG, INFO, WARNING (default), ERROR,
|
||||
or CRITICAL.
|
||||
.PP
|
||||
\f[B]\[en]run\-dir\f[]
|
||||
.PP
|
||||
Directory that will be namespaced with \f[C]pypodman\f[] to hold local socket
|
||||
bindings. The default is `\f[C]$XDG_RUNTIME_DIR\\\f[].
|
||||
.PP
|
||||
\f[B]\[en]user\f[]
|
||||
.PP
|
||||
Authenicating user on remote host. \f[C]pypodman\f[] defaults to the logged in
|
||||
user.
|
||||
.PP
|
||||
\f[B]\[en]host\f[]
|
||||
.PP
|
||||
Name of remote host. There is no default, if not given \f[C]pypodman\f[]
|
||||
attempts to connect to \f[C]\-\-remote\-socket\-path\f[] on local host.
|
||||
.PP
|
||||
\f[B]\[en]remote\-socket\-path\f[]
|
||||
.PP
|
||||
Path on remote host for podman service's \f[C]AF_UNIX\f[] socket. The default is
|
||||
\f[C]/run/podman/io.projectatomic.podman\f[].
|
||||
.PP
|
||||
\f[B]\[en]identity\-file\f[]
|
||||
.PP
|
||||
The optional \f[C]ssh\f[] identity file to authenicate when tunnelling to remote
|
||||
host. Default is None and will allow \f[C]ssh\f[] to follow it's default methods
|
||||
for resolving the identity and private key using the logged in user.
|
||||
.SH COMMANDS
|
||||
.PP
|
||||
See podman(1) (podman.1.md)
|
||||
.SH FILES
|
||||
.PP
|
||||
\f[B]pypodman/pypodman.conf\f[]
|
||||
(\f[C]Any\ element\ of\ XDG_CONFIG_DIRS\f[] and/or
|
||||
\f[C]XDG_CONFIG_HOME\f[] and/or \f[B]\[en]config\-home\f[])
|
||||
.PP
|
||||
pypodman.conf is one or more configuration files for running the pypodman
|
||||
command. pypodman.conf is a TOML file with the stanza \f[C][default]\f[], with a
|
||||
map of \f[C]option: value\f[].
|
||||
.PP
|
||||
pypodman follows the XDG (freedesktop.org) conventions for resolving it's
|
||||
configuration. The list below are read from top to bottom with later items
|
||||
overwriting earlier. Any missing items are ignored.
|
||||
.IP \[bu] 2
|
||||
\f[C]pypodman/pypodman.conf\f[] from any path element in
|
||||
\f[C]XDG_CONFIG_DIRS\f[] or \f[C]\\etc\\xdg\f[]
|
||||
.IP \[bu] 2
|
||||
\f[C]XDG_CONFIG_HOME\f[] or $HOME/.config + \f[C]pypodman/pypodman.conf\f[]
|
||||
.IP \[bu] 2
|
||||
From \f[C]\-\-config\-home\f[] command line option + \f[C]pypodman/pypodman.conf\f[]
|
||||
.IP \[bu] 2
|
||||
From environment variable, for example: RUN_DIR
|
||||
.IP \[bu] 2
|
||||
From command line option, for example: \[en]run\-dir
|
||||
.PP
|
||||
This should provide Operators the ability to setup basic configurations
|
||||
and allow users to customize them.
|
||||
.PP
|
||||
\f[B]XDG_RUNTIME_DIR\f[] (\f[C]XDG_RUNTIME_DIR/io.projectatomic.podman\f[])
|
||||
.PP
|
||||
Directory where pypodman stores non\-essential runtime files and other file
|
||||
objects (such as sockets, named pipes, \&...).
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
\f[C]podman(1)\f[], \f[C]libpod(8)\f[]
|
@ -1,82 +0,0 @@
|
||||
% pypodman "1"
|
||||
|
||||
## NAME
|
||||
|
||||
pypodman - Simple management tool for containers and images
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
**pypodman** [*global options*] _command_ [*options*]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
pypodman is a simple client only tool to help with debugging issues when daemons
|
||||
such as CRI runtime and the kubelet are not responding or failing. pypodman uses
|
||||
a VarLink API to commicate with a podman service running on either the local or
|
||||
remote machine. pypodman uses ssh to create secure tunnels when communicating
|
||||
with a remote service.
|
||||
|
||||
## GLOBAL OPTIONS
|
||||
|
||||
**--help, -h**
|
||||
|
||||
Print usage statement.
|
||||
|
||||
**--version**
|
||||
|
||||
Print program version number and exit.
|
||||
|
||||
**--config-home**
|
||||
|
||||
Directory that will be namespaced with `pypodman` to hold `pypodman.conf`. See FILES below for more details.
|
||||
|
||||
**--log-level**
|
||||
|
||||
Log events above specified level: DEBUG, INFO, WARNING (default), ERROR, or CRITICAL.
|
||||
|
||||
**--run-dir**
|
||||
|
||||
Directory that will be namespaced with `pypodman` to hold local socket bindings. The default is ``$XDG_RUNTIME_DIR\`.
|
||||
|
||||
**--user**
|
||||
|
||||
Authenicating user on remote host. `pypodman` defaults to the logged in user.
|
||||
|
||||
**--host**
|
||||
|
||||
Name of remote host. There is no default, if not given `pypodman` attempts to connect to `--remote-socket-path` on local host.
|
||||
|
||||
**--remote-socket-path**
|
||||
|
||||
Path on remote host for podman service's `AF_UNIX` socket. The default is `/run/podman/io.projectatomic.podman`.
|
||||
|
||||
**--identity-file**
|
||||
|
||||
The optional `ssh` identity file to authenicate when tunnelling to remote host. Default is None and will allow `ssh` to follow it's default methods for resolving the identity and private key using the logged in user.
|
||||
|
||||
## COMMANDS
|
||||
|
||||
See [podman(1)](podman.1.md)
|
||||
|
||||
## FILES
|
||||
|
||||
**pypodman/pypodman.conf** (`Any element of XDG_CONFIG_DIRS` and/or `XDG_CONFIG_HOME` and/or **--config-home**)
|
||||
|
||||
pypodman.conf is one or more configuration files for running the pypodman command. pypodman.conf is a TOML file with the stanza `[default]`, with a map of option: value.
|
||||
|
||||
pypodman follows the XDG (freedesktop.org) conventions for resolving it's configuration. The list below are read from top to bottom with later items overwriting earlier. Any missing items are ignored.
|
||||
|
||||
- `pypodman/pypodman.conf` from any path element in `XDG_CONFIG_DIRS` or `\etc\xdg`
|
||||
- `XDG_CONFIG_HOME` or $HOME/.config + `pypodman/pypodman.conf`
|
||||
- From `--config-home` command line option + `pypodman/pypodman.conf`
|
||||
- From environment variable, for example: RUN_DIR
|
||||
- From command line option, for example: --run-dir
|
||||
|
||||
This should provide Operators the ability to setup basic configurations and allow users to customize them.
|
||||
|
||||
**XDG_RUNTIME_DIR** (`XDG_RUNTIME_DIR/io.projectatomic.podman`)
|
||||
|
||||
Directory where pypodman stores non-essential runtime files and other file objects (such as sockets, named pipes, ...).
|
||||
|
||||
## SEE ALSO
|
||||
`podman(1)`, `libpod(8)`
|
0
contrib/python/pypodman/pypodman/__init__.py
Normal file
0
contrib/python/pypodman/pypodman/__init__.py
Normal file
@ -1,3 +1,4 @@
|
||||
"""Parse configuration while building subcommands."""
|
||||
import argparse
|
||||
import curses
|
||||
import getpass
|
||||
@ -7,7 +8,6 @@ import os
|
||||
import sys
|
||||
|
||||
import pkg_resources
|
||||
|
||||
import pytoml
|
||||
|
||||
# TODO: setup.py and obtain __version__ from rpm.spec
|
||||
@ -38,7 +38,6 @@ class PodmanArgumentParser(argparse.ArgumentParser):
|
||||
def __init__(self, **kwargs):
|
||||
"""Construct the parser."""
|
||||
kwargs['add_help'] = True
|
||||
kwargs['allow_abbrev'] = True
|
||||
kwargs['description'] = __doc__
|
||||
kwargs['formatter_class'] = HelpFormatter
|
||||
|
||||
@ -88,7 +87,7 @@ class PodmanArgumentParser(argparse.ArgumentParser):
|
||||
|
||||
# pull in plugin(s) code for each subcommand
|
||||
for name, obj in inspect.getmembers(
|
||||
sys.modules['lib.actions'],
|
||||
sys.modules['pypodman.lib.actions'],
|
||||
lambda member: inspect.isclass(member)):
|
||||
if hasattr(obj, 'subparser'):
|
||||
try:
|
@ -2,15 +2,14 @@
|
||||
|
||||
import abc
|
||||
|
||||
import _collections_abc
|
||||
|
||||
try:
|
||||
from contextlib import AbstractContextManager
|
||||
assert AbstractContextManager
|
||||
except ImportError:
|
||||
# Copied from python3.7 library as "backport"
|
||||
class AbstractContextManager(abc.ABC):
|
||||
"""An abstract base class for context managers."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def __enter__(self):
|
||||
"""Return `self` upon entering the runtime context."""
|
||||
return self
|
||||
@ -19,11 +18,3 @@ except ImportError:
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
"""Raise any exception triggered within the runtime context."""
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def __subclasshook__(cls, C):
|
||||
"""Check whether subclass is considered a subclass of this ABC."""
|
||||
if cls is AbstractContextManager:
|
||||
return _collections_abc._check_methods(C, "__enter__",
|
||||
"__exit__")
|
||||
return NotImplemented
|
@ -1,14 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Remote podman client."""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
import lib.actions
|
||||
from lib import PodmanArgumentParser
|
||||
|
||||
assert lib.actions # silence pyflakes
|
||||
from .lib import PodmanArgumentParser
|
||||
|
||||
|
||||
def main():
|
0
contrib/python/pypodman/test/test_report.py → contrib/python/pypodman/pypodman/test/test_report.py
0
contrib/python/pypodman/test/test_report.py → contrib/python/pypodman/pypodman/test/test_report.py
@ -1,4 +1,4 @@
|
||||
humanize
|
||||
podman
|
||||
pytoml
|
||||
setuptools>=39.2.0
|
||||
setuptools>=39
|
||||
|
@ -10,6 +10,7 @@ with open(os.path.join(root, 'README.md')) as me:
|
||||
with open(os.path.join(root, 'requirements.txt')) as r:
|
||||
requirements = r.read().splitlines()
|
||||
|
||||
|
||||
setup(
|
||||
name='pypodman',
|
||||
version=os.environ.get('PODMAN_VERSION', '0.0.0'),
|
||||
@ -19,15 +20,15 @@ setup(
|
||||
license='Apache Software License',
|
||||
long_description=readme,
|
||||
entry_points={'console_scripts': [
|
||||
'pypodman = lib.pypodman:main',
|
||||
'pypodman = pypodman.main:main',
|
||||
]},
|
||||
include_package_data=True,
|
||||
install_requires=requirements,
|
||||
keywords='varlink libpod podman pypodman',
|
||||
packages=find_packages(exclude=['test']),
|
||||
python_requires='>=3',
|
||||
zip_safe=True,
|
||||
url='http://github.com/projectatomic/libpod',
|
||||
keywords='varlink libpod podman pypodman',
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
@ -36,7 +37,7 @@ setup(
|
||||
'Operating System :: MacOS :: MacOS X',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: POSIX',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Topic :: System :: Systems Administration',
|
||||
'Topic :: Utilities',
|
||||
])
|
||||
|
Reference in New Issue
Block a user