Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing luma/__init__.py when installing with "setup.py install" #144

Closed
Gadgetoid opened this issue Jul 25, 2018 · 0 comments
Closed

Missing luma/__init__.py when installing with "setup.py install" #144

Gadgetoid opened this issue Jul 25, 2018 · 0 comments

Comments

@Gadgetoid
Copy link
Collaborator

I cloned luma.core onto a Pi 3B+ running Raspbian Stretch Lite and built/installed with "sudo python setup.py install" (setuptools 33.1.1) but receive an import error when trying to import the installed package.

  • git clone https://github.com/rm-hull/luma.core
  • cd luma.core
  • sudo python setup.py install
  • cd ~
  • python and import luma.core - "No module named luma.core"

The output of pip show luma.core shows it's installed in /usr/local/lib/python2.7/dist-packages/luma.core-1.7.2-py2.7.egg as I would expect.

Upon poking into this directory I find that the luma directory does not contain the __init__.py that it should, meaning it's not recognised as a namespace package.

This file is, however, present in the source luma directory and is a pkgutil style namespace package.

However you seem to be declaring this as a pkg_resources style namespace package with the namespace_packages=['luma'] line in setup.py. This looks like a conflation of both techniques.

The namespace_packages argument should be dropped, and the luma package added to packages=[].

luma.oled has this same issue.

See: https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages - which links to this example project: https://github.com/pypa/sample-namespace-packages/blob/master/pkgutil/pkg_a/setup.py

The example project uses find_packages() which adds both the main package and the namespace package to the packages argument.

pkg_resources style packages - compatible with only Python 3.x (afaik) - declare the package in both the packages and namespace_packages arguments but use a slightly different style of __init__.py which contains only: __import__('pkg_resources').declare_namespace(__name__).

TLDR: you need to remove namespace_packages=["luma"] from setup.py and simply add "luma" into packages=[]

Gadgetoid added a commit to Gadgetoid/luma.core that referenced this issue Jul 25, 2018
Change to correct use of pkgutil style namespace packages as documented https://packaging.python.org/guides/packaging-namespace-packages/#pkgutil-style-namespace-packages and illustrated in https://github.com/pypa/sample-namespace-packages/tree/master/pkgutil

Note: at the moment the `namespace_packages` directive is completely ignored, if you add the "luma" package to `packages` (in addition to `namespace_packages`) then `setup.py build` returns an error because it is expecting a pkg_resources style namespace package:

```
running build
running build_py
error: Namespace package problem: luma is a namespace package, but its
__init__.py does not call declare_namespace()! Please fix it.
(See the setuptools manual under "Namespace Packages" for details.)
```

Note: in the linked example the `find_packages()` method returns the "namespace" package as if it were an ordinary package.
Gadgetoid added a commit to Gadgetoid/luma.oled that referenced this issue Jul 25, 2018
See corresponding PR to luma.core - rm-hull/luma.core#145
Original issue and explanation - rm-hull/luma.core#144
Gadgetoid added a commit to Gadgetoid/luma.led_matrix that referenced this issue Jul 25, 2018
See corresponding PR to luma.core - rm-hull/luma.core#145
Original issue and explanation - rm-hull/luma.core#144
rm-hull pushed a commit to rm-hull/luma.led_matrix that referenced this issue Jul 25, 2018
* Correct implementation of pkgutil style namespace

See corresponding PR to luma.core - rm-hull/luma.core#145
Original issue and explanation - rm-hull/luma.core#144

* Update CONTRIBUTING.rst
rm-hull pushed a commit to rm-hull/luma.oled that referenced this issue Sep 7, 2018
* Correct implementation of pkgutil style namespace

See corresponding PR to luma.core - rm-hull/luma.core#145
Original issue and explanation - rm-hull/luma.core#144

* Update CONTRIBUTING.rst

* Update setup.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant