Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Distribute entry points #18

Closed
rduplain opened this issue Feb 29, 2012 · 3 comments
Closed

Distribute entry points #18

rduplain opened this issue Feb 29, 2012 · 3 comments

Comments

@rduplain
Copy link
Collaborator

I like to keep the manager in my app package and use distribute entry points:

# myapp/manage.py
def main():
    manager.run()

# setup.py
entry_points={
    'console_scripts': [
        'myappctl = myapp.manage:main',
    ],
},

The downside is that it relies on distribute and for your app to be installed or pseudoinstalled (developer mode) but the upside is that it lets your app actually work like a proper distributable package, not relying on being in the source directory or even even having the source directory. Just install and use myappctl. I also like having code related to my package //in// my actual package.

Often you might just have development stuff in your manage.py but maybe you have deployment stuff such as creating tables in a database etc. This way you can just put an sdist with fabric, easy_install it and your manager is just there.

Maybe this method should be documented as an alternative?

(Even without entry points, this still lets you do python -m myapp.manage outside of the source dir or python myapp/manage.py inside it.)


@rduplain
Copy link
Collaborator Author


Original Comment By: Dag Odenhall

@techniq techniq closed this as completed May 20, 2013
@sssilver
Copy link

sssilver commented Oct 6, 2015

Why was this closed?

I'm still running into being unable to properly package my app using setuptools when using flask-script and manage.py:

import distutils.core
import setuptools


distutils.core.setup(
    name='Angler Rod',
    version='2.0',
    packages=setuptools.find_packages(),

    long_description=open('README.txt').read(),
    author='sssilver',
    author_email='sssilver@gmail.com',

    install_requires={
        'flask>=0.10',
        'flask-login',
        'flask-script',
        'flask-cors',
        'flask-sqlalchemy',
        'flask-bcrypt',
        'pyyaml',
        'psycopg2',
        'sqlalchemy',
        'marshmallow-sqlalchemy',
        'python-dateutil'
    },

    entry_points = {
        'console_scripts': [
            'angler-rod = rod.manage:main',
        ],
    }
)

Running the app:

root@6a82e08503e4:~# angler-rod
Traceback (most recent call last):
  File "/usr/local/bin/angler-rod", line 9, in <module>
    load_entry_point('Angler-Rod==2.0', 'console_scripts', 'angler-rod')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
    ['__name__'])
ImportError: No module named manage

@davidism
Copy link

davidism commented Oct 6, 2015

This works fine for me. Try using from setuptools import setup.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants