I'm attempting to release a command line program written in Python to the public, but would first like to test it to make sure that the program works as I intend. To do so, I create a simple wheel distribution of the program, create a virtualenv instance in another directory, and install the wheel into said environment. Easy, right?
Not so.
When I attempt to call the program in the testing environment, I receive this error message:
Traceback (most recent call last):
File "~/testing/bin/leprechaun", line 7, in <module>
from leprechaun.main import main
File "~/testing/lib/python3.4/site-packages/leprechaun/main.py", line 8, in <module>
import generator
ImportError: No module named 'generator'
So, it seems that the generator.py file isn't being imported for some reason. What's strange, however, is that generator.py and main.py (the main entry point to the program) exist in the same directory.
For reference, here's my project's tree hierarchy:
├── leprechaun
│ ├── data
│ │ └── A bunch of text files that aren't important
│ ├── db.py
│ ├── generator.py
│ ├── __init__.py
│ ├── main.py
│ └── rainbow.py
├── LICENSE.txt
├── MANIFEST.in
├── README.rst
└── setup.py
And, for kicks, my setup.py script:
#!/usr/bin/env python3
import re
from setuptools import setup, find_packages
version = re.search("^__version__\s*=\s*\"(.*)\"$",
open("leprechaun/__init__.py").read(), re.M).group(1)
setup(
name='leprechaun',
version=version,
description="A simple rainbow table generator",
long_description=open("README.rst", encoding="utf-8").read(),
author="My Name",
author_email="My Email",
url="https://github.com/zcdziura/leprechaun",
license="MIT",
packages=find_packages(),
package_data={
"leprechaun": ["data/wordlist*"]
},
entry_points={
"console_scripts": [
"leprechaun = leprechaun.main:main"
]
}
)
I assumed that the entry-point script that is generated would simply call the main function from my package, which would then be able to import modules from the same directory. However, that doesn't seem to be the case.
How would I fix this?