2012-12-30 8 views
6

http://pythonpaste.org/script/developer.html#what-do-commands-look-likeの説明に従ってカスタムのpasterコマンドを作成しました。私のsetup.pyで私はこのようなエントリポイントを定義している:virtualenvでグローバルなpasterコマンドが見つかりません

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

私はアクティブにvirtualenvの内だと私は私のパッケージフォルダ内pasterしばらく実行した場合

python setup.py develop 

を経由して私のパッケージをインストールしています私のカスタムコマンドが表示され、paster xxx ...で実行できます。しかし、私がパッケージフォルダを残すと、pasterは私のコマンドをもう表示しません。私はwhich pasterをチェックして、それは私のvirtualenvのバージョンです。私はまた、Pythonインタプリタを起動し、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をインストールする必要があります。それでどこでも使えます。

関連する問題