2

Here is my project code structure:

pynique
├── cli
│   ├── __init__.py
│   └── pynique_ops.py
├── pynique
│   ├── __init__.py
├── README.md
├── setup.cfg
└── setup.py

My setup.py content is:

from setuptools import (
    find_packages,
    setup
)
print find_packages()

setup(
    name='pynique',
    version='0.1.1.dev1',
    description='pynique app',
    classifiers=[
        'Development Status :: 2 - Pre-Alpha',
        'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)'
    ],
    packages=find_packages(exclude=['tests']),
    include_package_data=True,
    install_requires=[
        'jinja2',
        'PyYAML',
        'Click'
    ],
    entry_points='''
        [console_scripts]
        start-pynique=pynique.cli.pynique_ops:start
    ''',
)

I've done this inside pynique top folder project: - pip install -e .

But my start-pynique is not working, it throws this error:

Traceback (most recent call last):
  File "/home/agung/.virtualenvs/pynique/bin/start-pynique", line 11, in <module>
    load_entry_point('pynique', 'console_scripts', 'start-pynique')()
  File "/home/agung/.virtualenvs/pynique/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/agung/.virtualenvs/pynique/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/home/agung/.virtualenvs/pynique/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/home/agung/.virtualenvs/pynique/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named cli.pynique_ops
(pynique) 

Do you know why it failed to have module named cli.pynique_ops? Is there anything wrong with my setup.py?

1 Answer 1

3

I finally know the fix. Python setup.py install will publish all directory inside root directory (pynique) as a package name.

So if I was still using the same folder structure as the question stated, cli, pynique will be installed as python package. So the fix should be like this start-pynique=cli.pynique_ops:start.

But, instead of using that folder structure, I change it to be like this:

pynique
├── pynique
│   ├── cli
│   │   ├── __init__.py
│   │   ├── pynique_ops.py
├── README.md
├── setup.cfg
├── setup.py

So, I can still use start-pynique=pynique.cli.pynique_ops:start as the valid setup.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.