A python project to use as a template when developing a Python application.
project
βββ README.md
βββ example
βΒ Β βββ __init__.py
βΒ Β βββ package_1
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ awesome_module.py
βΒ Β βΒ Β βββ ...
βΒ Β βΒ Β βββ awesome_module_n.py
βΒ Β βββ package_2
βΒ Β βββ __init__.py
βΒ Β βββ module.py
βββ setup.py
βββ tests
βββ __init__.py
- For Python3 users:
pip install virtualenvvirtualenv venv_namesource path/to/venv_name activate
- For Anaconda users:
conda create --name conda_envconda activate conda_envconda install pip
Next you need to create a setup.py file in the root folder. It should be similar to the one presented below:
from distutils.core import setup
from setuptools import setup, find_packages
setup(
name='example',
version='0.1dev0',
author='Author Name',
author_email='author_email@mail.com',
packages=find_packages(),
long_description=open('README.md').read()
)
You need to create an __init__.py file in the /example directory where you should import the packages (i.e. package_1, and package_2):
# example/__init__.py
from . import package_1, package_2
An example.egg-info directory should now be created in the root directory:
project
βββ README.md
βββ example
βΒ Β βββ __init__.py
βΒ Β βββ package_1
βΒ Β βΒ Β βββ __init__.py
βΒ Β βΒ Β βββ awesome_module.py
βΒ Β βΒ Β βββ ...
βΒ Β βΒ Β βββ awesome_module_n.py
βΒ Β βββ package_2
βΒ Β βββ __init__.py
βΒ Β βββ module.py
βββ example.egg-info
β βββ dependency_links.txt
β βββ PKG_INFO
β βββ SOURCES.txt
β βββ top_level.txt
βββ setup.py
βββ tests
βββ __init__.py
If everything when according to plan, you should be able to use the modules you developed in the package_1 from the package_2 directory likewise:
# example/package_2/module.py
from example.package_1.awesome_module import hello