pythainer 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. pythainer-0.0.1/.flake8 +5 -0
  2. pythainer-0.0.1/.gitignore +160 -0
  3. pythainer-0.0.1/.pylintrc +11 -0
  4. pythainer-0.0.1/CHANGELOG.md +10 -0
  5. pythainer-0.0.1/CONTRIBUTING.md +39 -0
  6. pythainer-0.0.1/LICENSE +21 -0
  7. pythainer-0.0.1/MAINTAINERS +1 -0
  8. pythainer-0.0.1/PKG-INFO +107 -0
  9. pythainer-0.0.1/README.md +93 -0
  10. pythainer-0.0.1/ROADMAP.md +5 -0
  11. pythainer-0.0.1/pyproject.toml +35 -0
  12. pythainer-0.0.1/scripts/all_checks.sh +37 -0
  13. pythainer-0.0.1/scripts/install_venv.sh +22 -0
  14. pythainer-0.0.1/scripts/list_missing_copyright.sh +18 -0
  15. pythainer-0.0.1/src/pythainer/__init__.py +2 -0
  16. pythainer-0.0.1/src/pythainer/builders/__init__.py +490 -0
  17. pythainer-0.0.1/src/pythainer/builders/cmds.py +132 -0
  18. pythainer-0.0.1/src/pythainer/builders/utils.py +222 -0
  19. pythainer-0.0.1/src/pythainer/examples/__init__.py +2 -0
  20. pythainer-0.0.1/src/pythainer/examples/builders/__init__.py +262 -0
  21. pythainer-0.0.1/src/pythainer/examples/installs/__init__.py +114 -0
  22. pythainer-0.0.1/src/pythainer/examples/runners/__init__.py +115 -0
  23. pythainer-0.0.1/src/pythainer/runners/__init__.py +293 -0
  24. pythainer-0.0.1/src/pythainer/sysutils.py +127 -0
  25. pythainer-0.0.1/usecases/itf_container.py +216 -0
  26. pythainer-0.0.1/usecases/mcgraph_container.py +64 -0
  27. pythainer-0.0.1/usecases/pi5rtlinux_container.py +109 -0
  28. pythainer-0.0.1/usecases/rtde_container.py +100 -0
  29. pythainer-0.0.1/usecases/safebot_container.py +222 -0
  30. pythainer-0.0.1/usecases/ultrascale_container.py +53 -0
  31. pythainer-0.0.1/usecases/ursim_container.py +72 -0
@@ -0,0 +1,5 @@
1
+ [flake8]
2
+ #ignore = E203, W503
3
+ max-line-length = 100
4
+ exclude =
5
+ venv/,
@@ -0,0 +1,160 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/#use-with-ide
110
+ .pdm.toml
111
+
112
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113
+ __pypackages__/
114
+
115
+ # Celery stuff
116
+ celerybeat-schedule
117
+ celerybeat.pid
118
+
119
+ # SageMath parsed files
120
+ *.sage.py
121
+
122
+ # Environments
123
+ .env
124
+ .venv
125
+ env/
126
+ venv/
127
+ ENV/
128
+ env.bak/
129
+ venv.bak/
130
+
131
+ # Spyder project settings
132
+ .spyderproject
133
+ .spyproject
134
+
135
+ # Rope project settings
136
+ .ropeproject
137
+
138
+ # mkdocs documentation
139
+ /site
140
+
141
+ # mypy
142
+ .mypy_cache/
143
+ .dmypy.json
144
+ dmypy.json
145
+
146
+ # Pyre type checker
147
+ .pyre/
148
+
149
+ # pytype static type analyzer
150
+ .pytype/
151
+
152
+ # Cython debug symbols
153
+ cython_debug/
154
+
155
+ # PyCharm
156
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
159
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
+ .idea/
@@ -0,0 +1,11 @@
1
+ [BASIC]
2
+ #good-names=x,y,m,gd,df,p,s,i,r,d,k,cd,d1,d2,ip,vn,x0,x1,y0,y1,dd,xs,i,j,tz
3
+ ignore-paths=
4
+ venv/,
5
+
6
+ [MESSAGE-CONTROL]
7
+ disable=
8
+ too-many-instance-attributes,
9
+ too-many-arguments,
10
+ too-few-public-methods,
11
+ unspecified-encoding,
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to benchkit will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.0.1] - 2024-04-22
9
+
10
+ Initial version.
@@ -0,0 +1,39 @@
1
+ # Contributing to pythainer
2
+
3
+ Contributions are welcome.
4
+ Contact the [maintainer](MAINTAINERS) for more information.
5
+
6
+ ### Source organization
7
+
8
+ Source organization is already documented for users in the [README](README.md).
9
+
10
+ ### Modifying the core
11
+
12
+ The core is the `pythainer/` directory.
13
+
14
+ ### Conventions
15
+
16
+ When defining a class, the following order of functions should be respected:
17
+
18
+ 1. `__new__` (static) method
19
+ 2. `__init__` method
20
+ 3. `__post_init__` method
21
+ 4. Properties (`@property`)
22
+ 5. Static methods (`@staticmethod`)
23
+ 6. Class methods (`@classmethod`)
24
+ 7. Normal methods
25
+ 8. Protected or private methods (with the name starting with `_`)
26
+
27
+
28
+ ### Check list to modify a python file
29
+
30
+ - if the file is executable, the shebang must be the first line: `#!/usr/bin/env python3`
31
+ - type hinting is correct & complete (to a _reasonable_ extent)
32
+ - sorting imports: `isort --profile black .`
33
+ - formatting: `black -l 100 .`
34
+ - checking: `pylint`
35
+ - checking: `flake8`
36
+
37
+ ### Reviews
38
+
39
+ All contributions require to be reviewed by the [maintainer](MAINTAINERS).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Antonio Paolillo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ Antonio Paolillo
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.3
2
+ Name: pythainer
3
+ Version: 0.0.1
4
+ Summary: A pythonic toolkit for composing, managing, and deploying Docker images and containers.
5
+ Project-URL: Homepage, https://github.com/apaolillo/pythainer
6
+ Project-URL: Issues, https://github.com/apaolillo/pythainer/issues
7
+ Author-email: Antonio Paolillo <antonio@paolillo.be>
8
+ License-File: LICENSE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+
15
+ # Pythainer
16
+
17
+ Pythainer is an open-source Python package designed to facilitate the creation,
18
+ management, composition and deployment of Docker containers for various use
19
+ cases, with a focus on ease of use and automation.
20
+
21
+ ## Features
22
+
23
+ - **Docker Image Building**: Simplify Docker image construction with
24
+ pre-defined Python scripts.
25
+ - **Project Examples**: Includes examples for building, installing, and
26
+ running applications within Docker containers.
27
+ - **Extensible**: Easily extendable to include more features or adapt
28
+ existing ones to different environments or requirements.
29
+
30
+ ## Getting Started
31
+
32
+ ### Prerequisites
33
+
34
+ - Python 3.10 or later
35
+ - [Docker](https://docs.docker.com/engine/install/)
36
+
37
+ ### Installation
38
+
39
+ To get started with Pythainer, clone this repository and set up a virtual
40
+ environment:
41
+
42
+ ```bash
43
+ git clone https://github.com/apaolillo/pythainer.git
44
+ cd pythainer
45
+ ./scripts/install_venv.sh
46
+ ```
47
+
48
+ ### Usage
49
+
50
+ Here is a simple example of how to use Pythainer to build a Docker container:
51
+
52
+ ```python3
53
+ from pythainer.builders import UbuntuDockerBuilder
54
+ from pythainer.runners import ConcreteDockerRunner
55
+
56
+ image_name = "pythainertest"
57
+ builder = UbuntuDockerBuilder(tag=image_name, ubuntu_base_tag="ubuntu:22.04")
58
+ builder.add_packages(packages=["vim", "git", "tmux"])
59
+ runner = ConcreteDockerRunner(image=image_name)
60
+
61
+ builder.build()
62
+ runner.run()
63
+ ```
64
+
65
+ ## High-level source organization
66
+
67
+ The source code of this repository is organized as follows:
68
+ ```
69
+ pythainer
70
+ ├── pythainer Core package containing all the essential modules for the framework.
71
+ │ ├── builders Modules responsible for building Docker images through automated scripts.
72
+ │ │ ├── cmds.py Defines command classes that translate high-level actions into Dockerfile commands.
73
+ │ │ └── utils.py Provides utility functions supporting Docker image construction.
74
+ │ ├── examples Contains various examples demonstrating the use of Pythainer components.
75
+ │ │ ├── builders Examples showcasing how to use the builders module to create Docker images.
76
+ │ │ ├── installs Examples demonstrating how to handle software installations inside Docker containers.
77
+ │ │ └── runners Examples illustrating how to execute and manage Docker containers for specific tasks.
78
+ │ ├── runners Contains utilities for running Docker containers.
79
+ │ └── sysutils.py Provides system utilities such as shell command execution and directory management.
80
+ └── scripts Directory containing scripts that facilitate development and operational tasks.
81
+ ```
82
+
83
+ ## Contributing
84
+
85
+ Contributions to Pythainer are welcome! If you have suggestions for
86
+ improvements or new features, please open an issue or submit a pull request.
87
+
88
+ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process.
89
+
90
+ ## Roadmap
91
+
92
+ Check out the [ROADMAP.md](ROADMAP.md) file to see the plans for future
93
+ releases.
94
+
95
+ ## License
96
+
97
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE)
98
+ file for details.
99
+
100
+ ## Maintainers
101
+
102
+ For major changes and guidance, the list of active maintainers is available in
103
+ the [MAINTAINERS](MAINTAINERS) file.
104
+
105
+ ## Support
106
+
107
+ For support, raise an issue in the GitHub issue tracker.
@@ -0,0 +1,93 @@
1
+ # Pythainer
2
+
3
+ Pythainer is an open-source Python package designed to facilitate the creation,
4
+ management, composition and deployment of Docker containers for various use
5
+ cases, with a focus on ease of use and automation.
6
+
7
+ ## Features
8
+
9
+ - **Docker Image Building**: Simplify Docker image construction with
10
+ pre-defined Python scripts.
11
+ - **Project Examples**: Includes examples for building, installing, and
12
+ running applications within Docker containers.
13
+ - **Extensible**: Easily extendable to include more features or adapt
14
+ existing ones to different environments or requirements.
15
+
16
+ ## Getting Started
17
+
18
+ ### Prerequisites
19
+
20
+ - Python 3.10 or later
21
+ - [Docker](https://docs.docker.com/engine/install/)
22
+
23
+ ### Installation
24
+
25
+ To get started with Pythainer, clone this repository and set up a virtual
26
+ environment:
27
+
28
+ ```bash
29
+ git clone https://github.com/apaolillo/pythainer.git
30
+ cd pythainer
31
+ ./scripts/install_venv.sh
32
+ ```
33
+
34
+ ### Usage
35
+
36
+ Here is a simple example of how to use Pythainer to build a Docker container:
37
+
38
+ ```python3
39
+ from pythainer.builders import UbuntuDockerBuilder
40
+ from pythainer.runners import ConcreteDockerRunner
41
+
42
+ image_name = "pythainertest"
43
+ builder = UbuntuDockerBuilder(tag=image_name, ubuntu_base_tag="ubuntu:22.04")
44
+ builder.add_packages(packages=["vim", "git", "tmux"])
45
+ runner = ConcreteDockerRunner(image=image_name)
46
+
47
+ builder.build()
48
+ runner.run()
49
+ ```
50
+
51
+ ## High-level source organization
52
+
53
+ The source code of this repository is organized as follows:
54
+ ```
55
+ pythainer
56
+ ├── pythainer Core package containing all the essential modules for the framework.
57
+ │ ├── builders Modules responsible for building Docker images through automated scripts.
58
+ │ │ ├── cmds.py Defines command classes that translate high-level actions into Dockerfile commands.
59
+ │ │ └── utils.py Provides utility functions supporting Docker image construction.
60
+ │ ├── examples Contains various examples demonstrating the use of Pythainer components.
61
+ │ │ ├── builders Examples showcasing how to use the builders module to create Docker images.
62
+ │ │ ├── installs Examples demonstrating how to handle software installations inside Docker containers.
63
+ │ │ └── runners Examples illustrating how to execute and manage Docker containers for specific tasks.
64
+ │ ├── runners Contains utilities for running Docker containers.
65
+ │ └── sysutils.py Provides system utilities such as shell command execution and directory management.
66
+ └── scripts Directory containing scripts that facilitate development and operational tasks.
67
+ ```
68
+
69
+ ## Contributing
70
+
71
+ Contributions to Pythainer are welcome! If you have suggestions for
72
+ improvements or new features, please open an issue or submit a pull request.
73
+
74
+ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process.
75
+
76
+ ## Roadmap
77
+
78
+ Check out the [ROADMAP.md](ROADMAP.md) file to see the plans for future
79
+ releases.
80
+
81
+ ## License
82
+
83
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE)
84
+ file for details.
85
+
86
+ ## Maintainers
87
+
88
+ For major changes and guidance, the list of active maintainers is available in
89
+ the [MAINTAINERS](MAINTAINERS) file.
90
+
91
+ ## Support
92
+
93
+ For support, raise an issue in the GitHub issue tracker.
@@ -0,0 +1,5 @@
1
+ # Roadmap
2
+
3
+ [ ] Document installation of CUDA dependencies on the host, i.e. install
4
+ container-toolkit to run CUDA application inside the container:
5
+ https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
@@ -0,0 +1,35 @@
1
+ [project]
2
+ name = "pythainer"
3
+ version = "0.0.1"
4
+ authors = [
5
+ { name="Antonio Paolillo", email="antonio@paolillo.be" },
6
+ ]
7
+ description = "A pythonic toolkit for composing, managing, and deploying Docker images and containers."
8
+ readme = "README.md"
9
+ requires-python = ">=3.10"
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3",
12
+ "License :: OSI Approved :: MIT License",
13
+ "Operating System :: OS Independent",
14
+ ]
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/apaolillo/pythainer"
18
+ Issues = "https://github.com/apaolillo/pythainer/issues"
19
+
20
+ [build-system]
21
+ requires = ["hatchling"]
22
+ build-backend = "hatchling.build"
23
+
24
+ [tool.black]
25
+ line-length = 100
26
+ target-version = ['py310']
27
+
28
+ exclude = '''venv'''
29
+
30
+ [tool.isort]
31
+ profile = "black"
32
+ skip = [
33
+ "venv"
34
+ ]
35
+ skip_glob = ["**/venv/**/*"]
@@ -0,0 +1,37 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ script_dir=$(readlink -e "$(dirname "$0")")
5
+ pythainer_root_dir=$(readlink -e "${script_dir}/..")
6
+ venv_dir=$(readlink -f "${pythainer_root_dir}/venv")
7
+
8
+ (
9
+ cd "${pythainer_root_dir}"
10
+
11
+ if [ ! -d "${venv_dir}" ]
12
+ then
13
+ echo "-- venv in root dir of benchkit not present. Creating one. --"
14
+ ./scripts/install_venv.sh
15
+ echo "-- venv created. --"
16
+ fi
17
+
18
+ pylint=$(readlink -f "${venv_dir}/bin/pylint")
19
+ flake8=$(readlink -f "${venv_dir}/bin/flake8")
20
+ isort=$(readlink -f "${venv_dir}/bin/isort")
21
+ black=$(readlink -f "${venv_dir}/bin/black")
22
+
23
+ echo "-- check copyright. --"
24
+ ./scripts/list_missing_copyright.sh
25
+
26
+ echo "-- running pylint. --"
27
+ ${pylint} pythainer/ || true
28
+
29
+ echo "-- running flake8. --"
30
+ ${flake8} pythainer/ || true
31
+
32
+ echo "-- running isort. --"
33
+ ${isort} --profile=black pythainer/
34
+
35
+ echo "-- running black. --"
36
+ ${black} -l 100 .
37
+ )
@@ -0,0 +1,22 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ script_dir=$(dirname "$(readlink -f "$0")")
5
+
6
+ python_exec=python3.10
7
+
8
+ ${python_exec} -m venv venv
9
+
10
+ pip_execs=$(find venv/ -name "pip3*")
11
+ pip_exec=$(echo "${pip_execs}" | head -n 1)
12
+
13
+ ${pip_exec} install --upgrade pip
14
+ ${pip_exec} install --upgrade setuptools
15
+ ${pip_exec} install --upgrade wheel
16
+ ${pip_exec} install --upgrade pycodestyle isort pylint black black[d] black[jupyter] flake8 docopt
17
+
18
+ requirement_file="requirements.txt"
19
+ if [ -e "${requirement_file}" ]
20
+ then
21
+ ${pip_exec} install --upgrade --requirement "${requirement_file}"
22
+ fi
@@ -0,0 +1,18 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ copyright_line1="# Copyright (C) 2024 Antonio Paolillo. All rights reserved."
5
+ copyright_line2="# SPDX-License-Identifier: MIT"
6
+
7
+ # Iterate over all .py files in the current directory and its subdirectories, excluding venv/
8
+ find . -type d -name "venv" -prune -o -type f -name "*.py" -print | while IFS= read -r file; do
9
+ header=$(head -n 3 "$file")
10
+ case "$header" in
11
+ *"$copyright_line1"*|*"$copyright_line2"*)
12
+ # Do nothing if match found
13
+ ;;
14
+ *)
15
+ echo "$file does not have the copyright header" >&2
16
+ ;;
17
+ esac
18
+ done
@@ -0,0 +1,2 @@
1
+ # Copyright (C) 2024 Antonio Paolillo. All rights reserved.
2
+ # SPDX-License-Identifier: MIT