Search code examples
pythonpippypi

Struggling with making a Python module accessible via PyPi


I wrote a simple Python interface for working with the Pushwoosh notification service a while back, which is at https://github.com/Astutech/Pushwoosh-Python-library and I've finally gotten around to publishing it so it can be installed using Pip. This is the first time I've published a Python library to PyPi and I'm in a bit of a muddle.

Trying to install it brings up the following error:

Collecting pushwoosh
  Using cached pushwoosh-1.0.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-5m3jj7uu/pushwoosh/setup.py", line 17, in <module>
        with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
      File "/usr/lib/python3.4/codecs.py", line 896, in open
        file = builtins.open(filename, mode, buffering)
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-5m3jj7uu/pushwoosh/DESCRIPTION.rst'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-5m3jj7uu/pushwoosh

It looks like some kind of path related issue. I'm not sure that pushwoosh.py is in the correct location. But if I move it to pushwoosh/pushwoosh.py, and add a pushwoosh/__init__.py fileI then need to import it as follows:

from pushwoosh.pushwoosh import Pushwoosh

This is obviously not ideal. From the documentation I can't see where I've gone wrong. What directory layout should I be using?

EDIT: I have now resolved the issue with DESCRIPTION.rst, but unless I move the pushwoosh.py file to a pushwoosh folder and add an __init__.py file, installing the library doesn't actually install pushwoosh.py so it doesn't work. How can I amend it so I can import it like this?

from pushwoosh import Pushwoosh

Solution

  • Figured it out in the end. It works if you put the file inside the module_name folder as __init__.py.