From 6846b27585bd1b86fe9fc8974c63d1799a498149 Mon Sep 17 00:00:00 2001 From: Artur Barseghyan Date: Wed, 21 Aug 2019 22:45:53 +0200 Subject: [PATCH] Python packaging --- .gitignore | 1 + README.md | 49 +++++++++++++++-------- podman-compose.py => podman_compose.py | 0 scripts/clean_up.sh | 11 ++++++ scripts/make_release.sh | 5 +++ scripts/uninstall.sh | 3 ++ setup.cfg | 2 + setup.py | 54 ++++++++++++++++++++++++++ 8 files changed, 109 insertions(+), 16 deletions(-) rename podman-compose.py => podman_compose.py (100%) create mode 100755 scripts/clean_up.sh create mode 100755 scripts/make_release.sh create mode 100755 scripts/uninstall.sh create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 894a44c..6621793 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ parts/ sdist/ var/ wheels/ +.idea/ *.egg-info/ .installed.cfg *.egg diff --git a/README.md b/README.md index 22705d2..fcecc16 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,38 @@ -# PodMan-Compose +# podman-compose A script to run `docker-compose.yml` using [podman](https://podman.io/), doing necessary mapping to make it work rootless. -## NOTE + Note, that it's still under development and might not work well yet. -it's still underdevelopment and does not work yet. +## Installation + +Install latest stable version from PyPI: + +``` +pip install podman-compose +``` + +Or latest stable version from GitHub: + +``` +pip install https://github.com/muayyad-alsadi/podman-compose/archive/master.tar.gz +``` + +Or latest development version from GitHub: + +``` +pip install https://github.com/muayyad-alsadi/podman-compose/archive/devel.tar.gz +``` ## Mappings -* `1podfw` - create all containers in one pod (inter-container communication is done via `localhost`), doing port mapping in that pod -* `1pod` - create all containers in one pod, doing port mapping in each container -* `identity` - no mapping -* `hostnet` - use host network, and inter-container communication is done via host gateway and published ports -* `cntnet` - create a container and use it via `--network container:name` (inter-container communication via `localhost`) -* `publishall` - publish all ports to host (using `-P`) and communicate via gateway +* `1podfw` - create all containers in one pod (inter-container communication is done via `localhost`), doing port mapping in that pod. +* `1pod` - create all containers in one pod, doing port mapping in each container. +* `identity` - no mapping. +* `hostnet` - use host network, and inter-container communication is done via host gateway and published ports. +* `cntnet` - create a container and use it via `--network container:name` (inter-container communication via `localhost`). +* `publishall` - publish all ports to host (using `-P`) and communicate via gateway. ## Examples @@ -22,30 +40,29 @@ When testing the `AWX`, if you got errors just wait for db migrations to end. ### Working Example -Tested on latest podman (commit `349e69..` on 2019-03-11) +*Tested on latest ``podman`` (commit `349e69..` on 2019-03-11).* -By using many containers on a single pod that shares the network (services talk via localhost) +By using many containers on a single pod that shares the network (services talk +via localhost): ``` ./podman-compose.py -t 1podfw -f examples/awx3/docker-compose.yml up ``` -Or by reusing a container network and `--add-host` +Or by reusing a container network and `--add-host`: ``` $ ./podman-compose.py -t cntnet -f examples/awx3/docker-compose.yml up ``` -Or by using host network and localhost works as in +Or by using host network and localhost works as follows: ``` $ ./podman-compose.py -t hostnet -f examples/awx3-hostnet-localhost/docker-compose.yml up ``` -### in progress work - +### Work in progress ``` ./podman-compose.py -t 1pod -f examples/awx3/docker-compose.yml up ``` - diff --git a/podman-compose.py b/podman_compose.py similarity index 100% rename from podman-compose.py rename to podman_compose.py diff --git a/scripts/clean_up.sh b/scripts/clean_up.sh new file mode 100755 index 0000000..c83b831 --- /dev/null +++ b/scripts/clean_up.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +find . -name "*.pyc" -exec rm -rf {} \; +find . -name "__pycache__" -exec rm -rf {} \; +find . -name "*.orig" -exec rm -rf {} \; +rm -rf .cache/ +rm -rf build/ +rm -rf builddocs/ +rm -rf dist/ +rm -rf deb_dist/ +rm src/podman-compose.egg-info -rf +rm builddocs.zip diff --git a/scripts/make_release.sh b/scripts/make_release.sh new file mode 100755 index 0000000..0ec6595 --- /dev/null +++ b/scripts/make_release.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +./scripts/uninstall.sh +./scripts/clean_up.sh +python setup.py register +python setup.py sdist bdist_wheel upload diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh new file mode 100755 index 0000000..613747b --- /dev/null +++ b/scripts/uninstall.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +pip uninstall podman-compose -y +./scripts/clean_up.sh diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2a9acf1 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e408068 --- /dev/null +++ b/setup.py @@ -0,0 +1,54 @@ +import os +from setuptools import setup, find_packages + +try: + readme = open(os.path.join(os.path.dirname(__file__), 'README.md')).read() +except: + readme = '' + +version = '0.1' + +setup( + name='podman-compose', + version=version, + description="A script to run docker-compose.yml using podman", + long_description=readme, + classifiers=[ + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Development Status :: 3 - Alpha", + "Topic :: Software Development :: Build Tools", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + ], + keywords='podman, podman-compose', + author='Artur Barseghyan', + author_email='artur.barseghyan@gmail.com', + url='https://github.com/barseghyanartur/tld', + package_dir={'': '.'}, + py_modules=['podman_compose'], + packages=find_packages(where='./src'), + entry_points={ + 'console_scripts': [ + 'podman-compose = podman_compose:main' + ] + }, + include_package_data=True, + license='GPL-2.0-only', + install_requires=[ + 'pyyaml' + ], + # test_suite='tests', + # tests_require=[ + # 'coverage', + # 'pytest-cov', + # 'pytest', + # 'tox', + # ] +)