Changes between Version 24 and Version 25 of DevGuide
- Timestamp:
- Dec 17, 2016, 2:33:54 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevGuide
v24 v25 85 85 == Assert Minimum Trac Version Requirement 86 86 87 A common method of specifying a minimum required Trac version is to add an installation requirement in `setup.py`, for example: `install_requires = ['Trac >= 0.12']`. However, 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).87 A common method of specifying a minimum required Trac version is to add an installation requirement in `setup.py`, for example: `install_requires = ['Trac >= 0.12']`. However, 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 during installation of a plugin. The result can be an unintended upgrade of a user's installation (#10607). 88 88 89 89 A better approach is to place the following in the package `__init__.py`, modifying `min_trac_version` as appropriate for your plugin: 90 90 {{{#!python 91 91 import pkg_resources 92 min_trac_version = '0.12' 93 pkg_resources.require('Trac >= %s' % min_trac_version) 92 pkg_resources.require('Trac >= 1.0') 94 93 }}} 95 94 96 You may still want tospecify that Trac is an installation requirement, but without enforcing a version requirement: `install_requires = ['Trac']`.95 You should still specify that Trac is an installation requirement, but without enforcing a version requirement: `install_requires = ['Trac']`. 97 96 98 97 The check in `__init__.py` is performed at runtime, so the egg can be built in an environment that does not satisfy the installation requirements. One use-case for this behavior 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: