2

For my Trac plugin, I want to pack my scripts and data together as an egg file. I used multiple different examples I found online as reference, but my egg file was not recognized by Trac.

I looked inside the egg file with 7zip, and all of the files seem to be in there, so I think it might be a problem with the meta data. The plugin itself works if I use just the .py script or an egg-link with absolute paths.

My project structure looks like this:

ticket-printer-plugin (the project root)
    |
    ---setup.py
    ---ticketprinter
        |
        ---__init__.py
        ---ticketprinter_admin.py
        ---ticketprinter_export.py
        ---htdocs
            |
            ---css
            |   |
            |   ---ticketformat.css
            |
            ---templates
                |
                ---admin_panel.html

The init file in the ticketprinter package contains the following:

from ticketprinter_export import *
from ticketprinter_admin import *

The setup.py script looks like this:

from setuptools import setup

setup(
    name='TracTicketPrinter', version='0.1',
    packages=['ticketprinter'],
    package_data={'ticketprinter': [
        'htdocs/css/*.css',
        'htdocs/templates/*.html']},
    entry_points={
        'trac.plugins': [
            'ticketprinter = ticketprinter',
        ],
    },
)

I checked the logs and there were no errors. It looks like Trac doesn't even recognize the egg file, so it might be a problem with the paths or the dependencies, but I can't find the mistake.

Raimund Krämer
  • 1,255
  • 1
  • 11
  • 29
  • It looks perfect to me python - wise, so it must be an issue with Trac. Do they recommend setuptools? – Alvaro Sep 30 '15 at 12:07
  • It's the standard way for multi file Trac plugins. – Raimund Krämer Sep 30 '15 at 12:09
  • 1
    I'm wondering whether this could be an issue with the `*` star import in `__init__.py` and the entry point. Did you try explicitly specifying the dotted name to the module(s) that contain classes implementing a `Component`? Like `'ticketprinter_export = ticketprinter.ticketprinter_export'`? – Lukas Graf Sep 30 '15 at 12:11
  • Also note that when you make changes to your entry points, you need to rebuild the `.egg-info`, for example by re-running `python setup.py develop`. – Lukas Graf Sep 30 '15 at 12:15
  • @LukasGraf I tried that, too. It also doesn't work. I'm curious why the egg-link works, but the egg file doesn't. – Raimund Krämer Sep 30 '15 at 12:50
  • Where are you locating the egg when you install it? Are you installing to your site-packages directory using `python setup.py install`? Or are you building the egg using `python setup.py bdist_egg` and copying the egg from the `dist` directory to Trac's `plugins` directory? – RjOllos Sep 30 '15 at 17:17
  • I recommend following the advice of @LukasGraf, using `['ticketprinter_export = ticketprinter.ticketprinter_export', 'ticketprinter_admin = ticketprinter.ticketprinter_admin']`. – RjOllos Sep 30 '15 at 17:49
  • That was the problem, it works now. – Raimund Krämer Oct 02 '15 at 09:09

0 Answers0