Skip to main content

No project description provided

Project description

🐎 Horse with no namespace

PyPI - Version PyPI - Python Version


horse-with-no-namespace is a tool which converts pkg_resources namespace packages to be compatible with PEP 420 implicit namespace packages.

Why is it needed?

The Python ecosystem provides several implementations of namespace packages, which make it possible to split the modules within a single package to be distributed in multiple distribution packages.

See https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ for more background on namespace packages and their various implementations.

The pkg_resources-style namespace packages are considered obsolete, but it is difficult to incrementally migrate a namespace using them to native namespace packages, because there are situations where not all of the packages will be found. For example, this happens if one package within the namespace uses pkg_resources-style namespace packages but another package uses one of the other styles, and they are not installed in the same path.

The goal of horse-with-no-namespace is to provide a temporary solution that can be installed to make things work during the interim period while existing releases of some packages in a namespace still use the pkg_resources style, but other packages are already in the process of being converted to native namespaces packages. Once all packages in the namespace have been converted, horse-with-no-namespace is no longer needed.

How does it work?

horse-with-no-namespace interferes with both of the ways that pkg_resources-style namespace packages can be loaded.

  • For packages that are installed into a site-packages directory, there is a file ending in -nspkg.pth which is automatically loaded by Python's site module to create the namespace package in sys.modules. horse-with-no-namespace removes these namespace packages from sys.modules, so that the namespace packages can be reloaded later without using the .pth machinery. (horse-with-no-namespace actually uses a similar hack with its own .pth file to do this, but arranges for it to be loaded later.)
  • For packages imported from somewhere else in sys.path, pkg_resources-style namespace packages are set up by a call to pkg_resources.declare_namespace from __init__.py. horse-with-no-namespace replaces pkg_resources.declare_namespace with a shim that instead initializes a pkgutil-style namespace package (which is compatible with native namespace packages).

Can I use it with Buildout?

This approach can also help with packages installed using zc.buildout. However, horse-with-no-namespace itself must not be installed using Buildout, but should be installed using pip into the same virtualenv where zc.buildout is installed. If horse-with-no-namespace is installed using Buildout, then its .pth file will not be loaded, since it is not in the site-packages folder.

Installation

pip install horse-with-no-namespace

License

horse-with-no-namespace is distributed under the terms of the MIT license.

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

horse_with_no_namespace-20250626.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

horse_with_no_namespace-20250626.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file horse_with_no_namespace-20250626.0.tar.gz.

File metadata

File hashes

Hashes for horse_with_no_namespace-20250626.0.tar.gz
Algorithm Hash digest
SHA256 e7675e3d3aa80446e83c3b194b0c150880a3151a5e9b5b914f2fdcb820563fbd
MD5 3696f3f9895f11216a812e338a188ef3
BLAKE2b-256 cc6173e77aa5e66a2e111b7159975bac7b243f4f740f74369db519cd31e9e655

See more details on using hashes here.

Provenance

The following attestation bundles were made for horse_with_no_namespace-20250626.0.tar.gz:

Publisher: publish.yml on davisagli/horse-with-no-namespace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file horse_with_no_namespace-20250626.0-py3-none-any.whl.

File metadata

File hashes

Hashes for horse_with_no_namespace-20250626.0-py3-none-any.whl
Algorithm Hash digest
SHA256 509d9427a4cc5b38b5f72ba831f797327c5cc9521d7e9e39b3fa9f0d87e7be00
MD5 67ea6c63485ebe3ea13eb36cb885ee00
BLAKE2b-256 5fabb014faedf824757e8d21be0a7c50d7ff7155e6b62a4651ddcc6a7dbe8335

See more details on using hashes here.

Provenance

The following attestation bundles were made for horse_with_no_namespace-20250626.0-py3-none-any.whl:

Publisher: publish.yml on davisagli/horse-with-no-namespace

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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