2012-12-30 23 views
6

http://pythonpaste.org/script/developer.html#what-do-commands-look-like'da açıklandığı gibi özel bir paster komutu oluşturdum. Benim setup.py dosyası olarak böyle giriş noktası tanımlamış:virtualenv içinde global paster komutu bulunamadı

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

Bir aktive virtualenv içindeyim ve ben paster çalıştırırsanız

python setup.py develop 

aracılığıyla paketimi yüklemiş paketim klasörünün içindeyken Özel komutumu görüyorum ve paster xxx ... aracılığıyla çalıştırabilirim. Ama eğer paket klasörümü terk edersem paster artık benim komutumu göstermiyor. which paster'u kontrol ettim ve sanalenv'imin sürümü. Ayrıca bir python yorumlayıcısına başladım ve xxxconf'u aldım ve iyi çalışıyor.

Paket klasörümün dışına çıktığımda global komutumu neden tanınmadığımı bilmiyorum !?

cevap

6

Yanlış bir şey yapıyorsunuz, işe yaramalı. Bu minimal çalışma örneğidir, kendi virtualenv ile test edebilirsiniz:

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: boş.

Şimdi test:

$ 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

Etkin virtualenv sizin paster_script yüklemeniz gerekir. Sonra her yerde kullanabilirsiniz.