, Python!
# 1:
init.py, ( )?:
, , :
. PEP 420 Python 3.3 . , - Python 3 pip.
pkgutil. , Python 2 3, pip python setup.py.
pkg_resources. , , , zip-safe.
# 2 (pkgutil-style) # 3 (pkg_resources-style), __init__.py. , __init__.py.
# 2:
setup.py, namespace_modules, , namespace_modules = ['org.common'] namespace_modules = ['org', 'common']?
, , namespace_packages setup().
# 3:
, ? , - ""?
python, , , , , , Python - . .
, :
PEP420, Python, , , . , , , . Git, .
, . setuptools.setup(package=[]), . / . , , setuptools find_namespace_package(),
:
find_namespace_packages() ( setuptools , 40.1.0): https://setuptools.readthedocs.io/en/latest/setuptools.html#find-namespace-packages
(08/09/2019):
, .
Python 3. 3+,
Python 3.5 , .
:
/ Python: org
: org_client, org_common
Python: 3.3+
setuptools: 40.1.0
from org.client.client1 import mod1
from org.common import config
, . org_client_client1_mod1 org_common_config,
1:
org_client_client1_mod1/
setup.py
org/
client/
client1/
__init__.py
submod1/
__init__.py
mod1/
__init__.py
somefile.py
file1.py
setup.py
from setuptools import find_namespace_packages, setup
setup(
name="org_client",
...
packages=find_namespace_packages(),
...
)
2:
org_common_config/
setup.py
org/
common/
__init__.py
config/
__init__.py
someotherfile.py
setup.py:
from setuptools import find_namespace_packages, setup
setup(
name="org_common",
...
packages=find_namespace_packages(),
...
)
( pip):
(venv) $ pip3 install org_common_config/
(venv) $ pip3 install org_client_client1_mod1/
:
(venv) $ pip3 list
...
org_client
org_common
...
, , org.client org.common.
, ( , venv):
(venv) $ cd venv/lib/python3.5/site-packages/
(venv) $ ls -l | grep org
, org_client org_common, .
(venv) $ cd venv/lib/python3.5/site-packages/org/
(venv) $ ls -l
client/
common/
...