Skip to main content

A small example package

Project description

Namespace Distribution

The purpose of the distribution is to demonstrate how to install namespace packages. Namespace packages do not require __init__.py files and allow modules to be stored in separate directories but logically appear to look as if they are installed in one directory.

To understand Git Mark down files click here

1. What does it do?

This python distribution installs two namespace packages called SampleDistribution_1/pkg1 and SampleDistribution_2/pkg1. The two pkg1 directories logically look like one directory even though physically they are separate. Notice how the module SampleDistribution_2/pkg1/mod2 imports mod3 with the code "from . import mod3".

2. How is this accomplished.

The python search path, sys.path, is modified to include the directories ...\PythonXX\site-packages\SampleDistribution_1 and ...\PythonXX\site-packages\SampleDistribution_2. The logic is coded in SampleDistribution_1/pkg2/main so that the environment varible PYTHONPATH does not have to be manually changed.

3. What versions of python support namespace packages

python 3.3 and later

4. How to install

pip install NamespaceDistribution

5. How do you run it?

SDRun

6. What is the output?

in mod1.py
...\PythonXX\site-packages\SampleDistribution_1\pkg1\mod3.py
...\PythonXX\site-packages\SampleDistribution_2\pkg1\mod2.py

7. Why is the program named SDRun.

SDRun is short for Sample Distribution Run. Instead of running python -m SampleDistribution_1/pkg2/main, the console script entry point SDRun has been created for ease of use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NamespaceDistribution-0.0.2.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

NamespaceDistribution-0.0.2-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page