Skip to main content

A template to structure your Python application

A python project to use as a template when developing a Python application.

In order to create a Python project with a similar structure you need to do the following:

The structure of the project should be as follows:

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

(Optional) Create a Python environment:

  • For Python3 users:
    • pip install virtualenv
    • virtualenv venv_name
    • source path/to/venv_name activate
  • For Anaconda users:
    • conda create --name conda_env
    • conda activate conda_env
    • conda 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 

After that, you need to run the setup.py as follows:

While being in the root of the folder run the following command: pip install -e .

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

Metadata

Release files for PaperLibCollect 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PaperLibCollect 0.1
File Size Uploaded Provenance
PaperLibCollect-0.1.tar.gz 5.6 kB Without provenance Details

Release files / PaperLibCollect-0.1.tar.gz

Download URL PaperLibCollect-0.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e7ae7437f381c8a1dd7b3fbb10f1c419d99cf40d3568cd9b1ac11e3e351e1e53
BLAKE2b-256 checksum
How to use checksums
87bada9e7d3870bdb827f0dfbbc30b73f39913bed03795a7130db61748eeebb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.1

Security for PaperLibCollect 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page