2012-12-30 11 views
6

में नहीं मिला मैं http://pythonpaste.org/script/developer.html#what-do-commands-look-like में वर्णित के रूप में एक कस्टम paster आदेश बनाया। मेरी setup.py में मैं इस तरह प्रवेश बिंदु को परिभाषित किया है:वैश्विक paster आदेश virtualenv

entry_points={ 
    'paste.global_paster_command' : [ 
    'xxx_new = xxxconf.main:NewXxx' 
    ] 
} 

मैं एक सक्रिय virtualenv अंदर हूँ और के माध्यम से

python setup.py develop 

अपने पैकेज स्थापित किया है मैं paster चलाने जबकि मेरी पैकेज फ़ोल्डर के अंदर , मैं अपना कस्टम कमांड देखता हूं और मैं इसे paster xxx ... के माध्यम से चला सकता हूं। लेकिन अगर मैं अपना पैकेज फ़ोल्डर paster छोड़ देता हूं तो अब मेरा आदेश प्रदर्शित नहीं करता है। मैंने which paster चेक किया और यह मेरे वर्चुअलएन्व का संस्करण है। मैंने एक पायथन दुभाषिया भी शुरू किया और xxxconf आयात किया और यह ठीक काम करता है।

मैं पता नहीं क्यों मेरे वैश्विक आदेश मान्यता प्राप्त नहीं है जब मैं अपने पैकेज फ़ोल्डर के बाहर हूँ है !?

उत्तर

6

आप कुछ गलत कर रहे हैं, यह काम करना चाहिए। यह कम से कम काम कर रहे उदाहरण है, आप इसे अपने virtualenv के साथ परीक्षण कर सकते हैं:

blah/setup.py:

from setuptools import setup, find_packages 

setup(name='blah', 
     version='0.1', 
     packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), 
     include_package_data=True, 
     zip_safe=False, 
     entry_points={'paste.global_paster_command': [ "xxx_new = blah.xxx:NewXxx", ] }, 
    ) 

blah/blah/xxx.py:

from paste.script import command 

class NewXxx(command.Command): 
    usage = "PREFIX" 
    summary = "some command" 
    group_name = "my group" 

blah/blah/__init__.py: खाली।

अब परीक्षण:

$ pwd 
/tmp 
$ virtualenv paster 
New python executable in paster/bin/python 
Installing setuptools............done. 
Installing pip...............done. 
$ . paster/bin/activate 
(paster)$ pip install PasteScript 
Downloading/unpacking PasteScript 
[... skipping long pip output here ...] 
(paster)$ paster 
[...] 
Commands: 
    create  Create the file layout for a Python distribution 
    help   Display help 
    make-config Install a package and create a fresh config file/directory 
    points  Show information about entry points 
    post   Run a request for the described application 
    request  Run a request for the described application 
    serve  Serve the described application 
    setup-app Setup an application, given a config file 

(paster)$ cd blah/ 
(paster)$ python setup.py develop 
running develop 
[... skipping setup.py output...] 
(paster)$ paster 
[...] 
Commands: 
    create  Create the file layout for a Python distribution 
    help   Display help 
    make-config Install a package and create a fresh config file/directory 
    points  Show information about entry points 
    post   Run a request for the described application 
    request  Run a request for the described application 
    serve  Serve the described application 
    setup-app Setup an application, given a config file 

my group: 
    xxx_new  some command 
(paster)$ cd ~ 
(paster)$ paster 
[...] 
Commands: 
[...] 
    setup-app Setup an application, given a config file 

my group: 
    xxx_new  some command 
0

आप सक्रिय virtualenv में अपने paster_script स्थापित करना चाहिए। फिर आप इसे कहीं भी इस्तेमाल कर सकते हैं।

संबंधित मुद्दे