Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setuptools console_script entry point not found with install but it's found with develop

My package has a entry point defined in it's setup.py:

# -*- coding: utf-8 -*-
from setuptools import setup

setup(
    name='fbuildbot',
    version='0.1',
    ...
    entry_points={
        'console_scripts': [
            'create = create:main',
        ],
    },
    install_requires=[
        "cookiecutter",
    ],
)

Thing is, If I do python setup.py develop, I can run the command just fine, but if I do install it with python setup.py install the install procedure runs correctly but the console script fails with ImportError:

Traceback (most recent call last):
  File "/home/matias/.venvs/fbuild/bin/create", line 8, in <module>
    load_entry_point('fbuildbot==0.1', 'console_scripts', 'create')()
  File "/home/matias/.venvs/fbuild/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
  File "/home/matias/.venvs/fbuild/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2221, in load_entry_point
  File "/home/matias/.venvs/fbuild/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1954, in load
ImportError: No module named create

Clearly it's failing to setup the package correctly on the pythonpath. I thought it was because I have the script barely at the top level. So I tried adding wrapping it all in a package, moving all important parts to a inner module and changing the setup.py accordingly:

# -*- coding: utf-8 -*-
from setuptools import setup

setup(
    name='fbuildbot',
    version='0.1',
    description="Buildbot configuration generator for fbuild",
    ...
    packages=['fbuildbot', ],
    entry_points={
        'console_scripts': [
            'create = fbuildbot.create:main',
        ],
    },
    install_requires=[
        "cookiecutter",
    ],
)

But it fails with the same message (with updated path, obviously).

Clearly I'm doing something wrong here. What could it be?

like image 422
tutuca Avatar asked Jan 09 '14 18:01

tutuca


People also ask

How do I install Python setuptools?

Follow the below steps to install the Setuptools package on Linux using the setup.py file: Step 1: Download the latest source package of Setuptools for Python3 from the website. Step 3: Go to the setuptools-60.5. 0 folder and enter the following command to install the package.

How do I set up setuptools for Python on Windows?

Step 1: Download the latest source package of Setuptools for Python3 from here. Step 2: Extract the downloaded package using the given command. Step 3: Go to the setuptools-60.2. 0 folder and enter the following command to install the package.

Does PIP require setuptools?

A Python file that relies only on the standard library can be redistributed and reused without the need to use setuptools. But for projects that consist of multiple files, need additional libraries, or need a specific version of Python, setuptools will be required.

Is setuptools included in Python?

the setuptools is not part of the python vanilla codebase, hence not a vanilla modules. python.org installers or mac homebrew will install it for you, but if someone compile the python by himself or install it on some linux distribution he may not get it and will need to install it by himself.


1 Answers

The problem is in your packages argument. You only specify:

packages=['fbuildbot', ],

not

packages=['fbuildbot', 'fbuildbot.create'],

so your setup is not actually installing the "create" module. Makes sense that it could not be found.

I would recommend the find_packages utility

from setuptools import setup, find_packages

setup(
    ...
    packages=find_packages(),
    entry_points={
        'console_scripts': [
            'create = fbuildbot.create:main',
        ],
    },
    ...
)

which will handle all of it for you.

like image 167
Justin Avatar answered Sep 28 '22 16:09

Justin