No project description provided
Project description
🐎 Horse with no namespace
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'ssite
module to create the namespace package insys.modules
.horse-with-no-namespace
removes these namespace packages fromsys.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 topkg_resources.declare_namespace
from__init__.py
.horse-with-no-namespace
replacespkg_resources.declare_namespace
with a shim that instead initializes apkgutil
-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file horse_with_no_namespace-20250408.0.tar.gz
.
File metadata
- Download URL: horse_with_no_namespace-20250408.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
d09810685faf6c4ffcc20f22b0ff320fe267fb75bd46ebfe7dc86b64e0a04b1d
|
|
MD5 |
3ad07aae577983f361c9616c4ee06b05
|
|
BLAKE2b-256 |
e666681ab7f36264b8b287c9900f7382ce0539a0c139c609a63befd84c1e58f2
|
Provenance
The following attestation bundles were made for horse_with_no_namespace-20250408.0.tar.gz
:
Publisher:
publish.yml
on davisagli/horse-with-no-namespace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
horse_with_no_namespace-20250408.0.tar.gz
-
Subject digest:
d09810685faf6c4ffcc20f22b0ff320fe267fb75bd46ebfe7dc86b64e0a04b1d
- Sigstore transparency entry: 194098515
- Sigstore integration time:
-
Permalink:
davisagli/horse-with-no-namespace@aec69f89fd20f267a71b0d6219b5384f71704d20
-
Branch / Tag:
refs/tags/v20250408.0
- Owner: https://github.com/davisagli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish.yml@aec69f89fd20f267a71b0d6219b5384f71704d20
-
Trigger Event:
push
-
Statement type:
File details
Details for the file horse_with_no_namespace-20250408.0-py3-none-any.whl
.
File metadata
- Download URL: horse_with_no_namespace-20250408.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0f7913947abbc4c7e9fac015d8b2a14b5fc69cfa0d3665071cf6c94670e870bc
|
|
MD5 |
8235398738ab6d1995063f73a2846f9e
|
|
BLAKE2b-256 |
87c809ded92d5fbf4c6c0948a16869090f98608a4a2913ef569a81f175af433c
|
Provenance
The following attestation bundles were made for horse_with_no_namespace-20250408.0-py3-none-any.whl
:
Publisher:
publish.yml
on davisagli/horse-with-no-namespace
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
horse_with_no_namespace-20250408.0-py3-none-any.whl
-
Subject digest:
0f7913947abbc4c7e9fac015d8b2a14b5fc69cfa0d3665071cf6c94670e870bc
- Sigstore transparency entry: 194098517
- Sigstore integration time:
-
Permalink:
davisagli/horse-with-no-namespace@aec69f89fd20f267a71b0d6219b5384f71704d20
-
Branch / Tag:
refs/tags/v20250408.0
- Owner: https://github.com/davisagli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish.yml@aec69f89fd20f267a71b0d6219b5384f71704d20
-
Trigger Event:
push
-
Statement type: