Question

I created a custom paster command as described in http://pythonpaste.org/script/developer.html#what-do-commands-look-like. In my setup.py I have defined the entry point like this:

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

I'm inside an activated virtualenv and have installed my package via

python setup.py develop

If I run paster while inside my package folder, I see my custom command and I can run it via paster xxx .... But if I leave my package folder paster does not display my command anymore. I checked which paster and it's the version of my virtualenv. I also started a python interpreter and imported xxxconf and it works fine.

I have no idea why my global command is not recognized when I'm outside my package folder!?

Était-ce utile?

La solution

You are doing something wrong, it should work. This is the minimal working example, you can test it with your 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: empty.

Now testing:

$ 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

Autres conseils

You should install your paster_script in the active virtualenv. Then you can use it anywhere.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top