Changes between Version 3 and Version 4 of DevGuide


Ignore:
Timestamp:
Apr 12, 2014, 10:03:23 PM (10 years ago)
Author:
Ryan J Ollos
Comment:

Assert minimum Trac version requirement. Refs #9800.

Legend:

Unmodified
Added
Removed
Modified
  • DevGuide

    v3 v4  
    4242Authors are encouraged to conform to the [trac:TracDev/CodingStyle Trac Style Guide] and [http://legacy.python.org/dev/peps/pep-0008/ PEP-0008 style guide].
    4343
     44== Assert Minimum Trac Version Requirement
     45
     46The most common method employed to specify a minimum required Trac version is to add an installation requirement in `setup.py`. For example: `install_required = ['Trac >= 0.12']`. This causes numerous problems, some of which are documented in #9800, and is not recommended. One of the most negative consequences is that setuptools may download and install a newer version of Trac. The result can be an unintended upgrade of a user's installation (#10607).
     47
     48A better approach place the following in the package `__init__.py`, modifying `min_trac_version` as appropriate for your plugin:
     49{{{#!python
     50import pkg_resources
     51min_trac_version = '0.12'
     52pkg_resources.require('Trac >= %s' % min_trac_version)
     53}}}
     54
     55The check if performed at runtime, so the egg can be built in an environment that does not satisfy the installation requirements. One use-case is building the egg on a development computer and uploading it through the plugin admin page. An error such as the following will be seen in the logs if the plugin fails to load due to a failed requirement:
     56{{{
     5702:39:22 PM Trac[loader] DEBUG: Loading changelog.ChangeLogMacro from /home/user/Workspace/clm/lib/python2.7/site-packages/ChangeLogMacro-0.2-py2.7.egg
     5802:39:22 PM Trac[loader] ERROR: Skipping "changelog.ChangeLogMacro = changelog.ChangeLogMacro": (version conflict "VersionConflict: (Trac 0.12 (/home/user/Workspace/clm/trac-0.12), Requirement.parse('Trac>=1.0'))")
     59}}}