Skip to content

Commit d50c996

Browse files
committed
init ghoshell container refacting from ghostos_container
0 parents  commit d50c996

25 files changed

+2446
-0
lines changed

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# ide
2+
.idea/
3+
dist
4+
debug.log
5+
.DS_Store
6+
*.thread.yml
7+
# Byte-compiled / optimized / DLL files
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
.ghostos.yml
12+
ghostos_ws/
13+
14+
# C extensions
15+
*.so
16+
17+
# Distribution / packaging
18+
.Python
19+
.python-version
20+
build/
21+
develop-eggs/
22+
dist/
23+
downloads/
24+
eggs/
25+
.eggs/
26+
lib/
27+
lib64/
28+
parts/
29+
sdist/
30+
var/
31+
wheels/
32+
share/python-wheels/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
MANIFEST
37+
38+
# PyInstaller
39+
# Usually these files are written by a python script from a template
40+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
41+
*.manifest
42+
*.spec
43+
44+
# Installer logs
45+
pip-log.txt
46+
pip-delete-this-directory.txt
47+
48+
# Unit test / coverage reports
49+
htmlcov/
50+
.tox/
51+
.nox/
52+
.coverage
53+
.coverage.*
54+
.cache
55+
nosetests.xml
56+
coverage.xml
57+
*.cover
58+
*.py,cover
59+
.hypothesis/
60+
.pytest_cache/
61+
cover/
62+
63+
# Translations
64+
*.mo
65+
*.pot
66+
67+
# Django stuff:
68+
*.log
69+
local_settings.py
70+
db.sqlite3
71+
db.sqlite3-journal
72+
73+
# Flask stuff:
74+
instance/
75+
.webassets-cache
76+
77+
# Scrapy stuff:
78+
.scrapy
79+
80+
# Sphinx documentation
81+
docs/_build/
82+
83+
# PyBuilder
84+
.pybuilder/
85+
target/
86+
87+
# Jupyter Notebook
88+
.ipynb_checkpoints
89+
.pdm-build
90+
91+
# IPython
92+
profile_default/
93+
ipython_config.py
94+
95+
# pyenv
96+
# For a library or package, you might want to ignore these files since the code is
97+
# intended to run in multiple environments; otherwise, check them in:
98+
# .python-version
99+
100+
# pipenv
101+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
102+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
103+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
104+
# install all needed dependencies.
105+
#Pipfile.lock
106+
107+
# poetry
108+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
109+
# This is especially recommended for binary packages to ensure reproducibility, and is more
110+
# commonly ignored for libraries.
111+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
112+
poetry.lock
113+
114+
uv.lock
115+
116+
# pdm
117+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
118+
#pdm.lock
119+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
120+
# in version control.
121+
# https://pdm.fming.dev/#use-with-ide
122+
.pdm.toml
123+
124+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
125+
__pypackages__/
126+
127+
# Celery stuff
128+
celerybeat-schedule
129+
celerybeat.pid
130+
131+
# SageMath parsed files
132+
*.sage.py
133+
134+
# Environments
135+
.env
136+
.venv
137+
env/
138+
venv/
139+
ENV/
140+
env.bak/
141+
venv.bak/
142+
143+
# Spyder project settings
144+
.spyderproject
145+
.spyproject
146+
147+
# Rope project settings
148+
.ropeproject
149+
150+
# mkdocs documentation
151+
/site
152+
153+
# mypy
154+
.mypy_cache/
155+
.dmypy.json
156+
dmypy.json
157+
158+
# Pyre type checker
159+
.pyre/
160+
161+
# pytype static type analyzer
162+
.pytype/
163+
164+
# Cython debug symbols
165+
cython_debug/
166+
167+
# PyCharm
168+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
169+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
170+
# and can be added to the global gitignore or merged into this file. For a more nuclear
171+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
172+
#.idea/
173+
174+
.vscode/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 ghost-in-moss
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.

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Ghoshell Container
2+
3+
IoC container for [GhostInShells](https://github.com/GhostInShells).
4+
5+
## IoC Container
6+
7+
`GhostInShells` follows the concept of `interface-oriented programming` to build the project.
8+
Most modules are divided into `interface` and `implementation`.
9+
Register and get implementations by IoC Container.
10+
11+
About IoC: [Inverse of Control](https://en.wikipedia.org/wiki/Inversion_of_control)
12+
13+
## Installation
14+
15+
`pip install ghoshell-container`
16+
17+
## Features
18+
19+
* `set` and `get`, and type check by `fetch`, `force_fetch`
20+
* `alias`: set alias for contract
21+
* `bind` with factory function, subclass, instance e.t.c
22+
* dict interface
23+
* factory class `Provider` registrar
24+
* `boostrap` and `shutdown`
25+
* container bloodline inheritance
26+
* `make`: recursively dependencies injection for class
27+
* `call`: recursively dependencies injection for function
28+
* `get_container` and `set_container` by contextvars
29+
* `depends`: function decorator
30+
* `Inject` : class property injection
31+
* `DeclaredContainer`: auto bindings by property
32+
33+
see them in [examples](tests/examples)

RELEASES.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 0.3.0
2+
3+
## 0.3.0-dev
4+
5+
refact from `ghostos_container`
6+
7+
# 0.2.0
8+
9+
prepare uv and monorepo.
10+
11+
## 0.2.7
12+
13+
add `join` to `shutdown` lifecycle.
14+
15+
## 0.2.6
16+
17+
fix bootstrapper lifecycle wrong.
18+
19+
## 0.2.5
20+
21+
add method `set_parent` to container.
22+
23+
## 0.2.4
24+
25+
fix `get_caller_info` backtrace more than stack

pyproject.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[project]
2+
name = "ghoshell-container"
3+
version = "0.3.0-dev"
4+
description = "the ioc container useful for Interface oriented programming"
5+
authors = [
6+
{ name = "thirdgerb", email = "thirdgerb@gmail.com" }
7+
]
8+
license = { text = "MIT" }
9+
readme = "README.md"
10+
requires-python = ">=3.10"
11+
dependencies = [
12+
"typing-extensions>=4.15.0",
13+
]
14+
15+
[tool.setuptools]
16+
packages = [
17+
{ include = "src" },
18+
]
19+
20+
[project.urls]
21+
Homepage = "https://github.com/GhostInShells/ghoshell-container"
22+
Repository = "https://github.com/GhostInShells/ghoshell-container"
23+
24+
[tool.pdm.build]
25+
includes = []
26+
27+
28+
[build-system]
29+
requires = ["pdm-backend"]
30+
build-backend = "pdm.backend"
31+
32+
[dependency-groups]
33+
dev = [
34+
"pytest>=8.3.5",
35+
]

src/ghoshell_container/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from ghoshell_container.abcd import (
2+
IoCContainer,
3+
INSTANCE, BINDING, ABSTRACT,
4+
FactoryFunc, BootstrapFunc, ShutdownFunc,
5+
Bootstrapper,
6+
Provider, BootstrapProvider,
7+
)
8+
from ghoshell_container.containers import Container, DeclaredContainer, Inject
9+
from ghoshell_container.utils import (
10+
provide, get_caller_info, get_container, set_container, depends,
11+
)
12+
13+
set_container(Container(name='ghoshell_container.root'))

0 commit comments

Comments
 (0)