Questions tagged [namespace-package]

In Python, namespace packages have subpackages different locations. It allows different projects to use the same package name.

Namespace packages are Python packages whose subpackages are in different directories.

It allows different projects to use the same package. For example, many components of are developed in different projects with different release cycles. Yet, all of them are expected to be imported from a submodule of a zope package. Without namespace packages, it would be impossible: Python does not allow a package to have its code in multiple locations.

provides namespace packages. PEP 420 proposes a way of adding it into Python 3.3.

More can be found in setuptools documentation.

49 questions
37
votes
2 answers

Python Namespace Packages in Python3

The topic of namespace packages seems a bit confusing for the uninitiated, and it doesn't help that prior versions of Python have implemented it in a few different ways or that a lot of the Q&A on StackOverflow are dated. I am looking for a…
Bobby
  • 1,439
  • 2
  • 16
  • 30
14
votes
1 answer

The way to make namespace packages in Python

From Namespace Packages in distribute, I know I can make use of namespace packages to separate a big Python package into several smaller ones. It is really awesome. The document also mentions: Note, by the way, that your project’s source tree must…
Drake Guan
  • 14,514
  • 15
  • 67
  • 94
14
votes
2 answers

Current state of python namespace packages

I would like to have several python sub modules inside a main module, but I want to distribute them as separated python packages. So package A should provide 'my_data.source_a', package B should provide 'my_data.source_b', ... and so on. I found out…
Achim
  • 15,415
  • 15
  • 80
  • 144
10
votes
0 answers

What is the correct setup for namespace packages, both installed and as source package?

I have a Python 3.6 virtual environment in which (among others) two libraries are installed that share a common top directory shared_name. It does not contain a __init__.py. As far as I understand it, that should be an implicit namespace package…
user1010997
  • 523
  • 5
  • 13
10
votes
2 answers

Namespace packages with a core part?

This question follows up The way to make namespace packages in Python and How do I create a namespace package in Python?. Note PEP 420, and the distribute docs, which state: You must NOT include any other code and data in a namespace package’s…
jbenet
  • 3,030
  • 3
  • 22
  • 25
9
votes
1 answer

How to manage several python subprojects with setuptools?

I'm wondering about the correct/easiest/most pythonic way of dealing with subprojects that you want have using the same base package. We currently have a file structure like this: trunk\ proj1\setup.py company_name\__init__.py +…
8
votes
1 answer

Python 3.6.0 implicit namespace package

I've found strange behavior with implicit namespace package in Python 3.6.0rc1. Could you please tell me if I am wrong or is it a Python 3.6 bug? I am working with namespace package marrow which has two separated packages marrow.util and…
6
votes
1 answer

Python: multiple packages with multiple setup.py files

I'm having a hard time constructing my Python setup.py files to do what I want. I have one pacakge set up like this: somestuff_root/ setup.py myutils/ __init__.py a/ __init__.py somestuff.py I have…
PythonSlacker
  • 61
  • 1
  • 1
  • 2
6
votes
1 answer

How to resolve this import error in Python 3.6?

I have a very simple namespace package (contents included below, as well as the directory layout). If I try to import namespace_repro.module, I got the following error: AttributeError: module 'namespace_repro' has no attribute 'module'. As far as I…
5
votes
1 answer

mypy and distributing a namespace package

I have a set of namespace packages that are meant to run in a python3.6 environment. They are each set up as follows: if sys.version_info < (3, 6): print("Python versions < 3.6 unsupported", file=sys.stderr) sys.exit(1) setup( …
mgilson
  • 300,191
  • 65
  • 633
  • 696
5
votes
1 answer

Distributing a namespace package submodules

I've reorganized my Python project to be under a same name umbrella. My project can now be seen as multiple subsystems than can depend on each other. That means that every submodule can now be distributed alone so that only required dependencies can…
Spack
  • 464
  • 4
  • 22
4
votes
1 answer

relative position and content of namespace packages in Python >= 3.3

I read the docs and quite some stackoverflow posts, but did not find an explicit answer to my doubts. I think I understand what namespace packages are for. I am only interested in Python>=3.3 and the implicit namespace packages - folders without the…
4
votes
1 answer

pytest before 4.6 was able to import from a local package with the same name as an installed namespace package, and now it isn't. Is that a bug?

I clone this toy repository that demonstrates how namespace packages work: C:\workspace>git clone https://github.com/pypa/sample-namespace-packages.git Specifically, I'll use its pkg_resources directory, which has the structure pkg_a/ setup.py …
ben-g-
  • 131
  • 9
4
votes
1 answer

With setuptools, when does namespace packages __init__.py files disappears?

The setuptools documentation is very explicit about adding code to __init__.py files from namespaces: You must NOT include any other code and data in a namespace package's __init__.py. Even though it may appear to work during development, or when…
brandizzi
  • 26,083
  • 8
  • 103
  • 158
4
votes
1 answer

Developing with Python Namespaced Packages

I am having an issue with python namespaced packages and am wondering what is a good solution. My project structure is similar to the following project_name/ext/app_ext That is the project I'm working on. It has dependencies that are also in the…
Aaron
  • 4,206
  • 3
  • 24
  • 28
1
2 3 4