Changes between Version 5 and Version 6 of TracPlugins
- Timestamp:
- 09/05/24 03:39:58 (2 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracPlugins
v5 v6 7 7 == Plugin discovery 8 8 9 From the user's point of view, a plugin is either a single .py file or a package (.egg or .whl). Trac looks for plugins in Python's `site-packages` directory, the [TracIni#GlobalConfiguration global shared] `plugins` directory and the [TracEnvironment project environment] `plugins` directory. Plugins installed to the project environment `plugins` directory are enabled, unless explicitly disabled in the `[components]` section of the `trac.ini` file. Plugins installed elsewhere must be explicitly enabled in the [[TracIni#components-section| [components] ]] section of the `trac.ini` file.9 A plugin is either a single .py file or a package (.egg or .whl). Trac looks for plugins in Python's `site-packages` directory, the [TracIni#GlobalConfiguration global shared] `plugins` directory and the [TracEnvironment project environment] `plugins` directory. Plugins installed to the project environment `plugins` directory are enabled, unless explicitly disabled in the `[components]` section of the `trac.ini` file. Plugins installed elsewhere must be explicitly enabled in the [TracIni#components-section "[components]"] section of the `trac.ini` file. 10 10 11 11 == Installing a Trac plugin 12 12 13 The instructions below are applicable to aplugins installed as packages. Plugins implemented as a single `py` file should be downloaded and copied to the [TracEnvironment project environment] `plugins` directory or the [TracIni#GlobalConfiguration global shared] plugins directory.13 The instructions below are applicable to plugins installed as packages. Plugins implemented as a single `py` file should be downloaded and copied to the [TracEnvironment project environment] `plugins` directory or the [TracIni#GlobalConfiguration global shared] plugins directory. 14 14 15 15 === For a single project 16 16 17 Packages built for a single project must use the egg 18 format, as the wheel format (described below) is not 19 supported by the setuptools loading mechanism. Build the `egg` file from the plugin source: 17 Packages built for a single project must use the egg format, as the wheel format (described below) is not supported by the setuptools loading mechanism. Build the `egg` file from the plugin source: 20 18 21 19 * Checkout or download and unpack the source. 22 * Change to the directory containing `setup.py`. 23 * Run: 20 * Change to the directory containing `setup.py` and run: 24 21 {{{#!sh 25 22 $ python setup.py bdist_egg … … 28 25 * Copy the egg file to the `plugins` directory of the [TracEnvironment project environment]. 29 26 30 Make sure the web server has sufficient permissions to read the plugin egg and restart the web server. If you are running as a [TracStandalone "tracd" standalone server], restart tracd (i.e. kill the process and run again).27 Make sure the web server has sufficient permissions to read the plugin egg and restart the web server. If you are running as a [TracStandalone "tracd" standalone server], restart tracd, i.e. kill the process and run again. 31 28 32 29 Trac also searches for plugins installed in the [TracIni#GlobalConfiguration global shared] plugins directory. This is a convenient way to share the installation of plugins across several, but not all, environments. … … 46 43 The modern Python package manager, `pip`, is included in Python 2.7.9 and later. In earlier versions of Python it can be installed through the package manager of your OS (e.g. `apt-get install python-pip`) or using [https://pip.pypa.io/en/latest/installing.html#install-pip get_pip.py]. 47 44 48 Using `pip`, the plugin will be installed 49 in the [https://pythonwheels.com/ wheel format], which is the modern standard for Python and a 50 replacement for the egg format. 45 Using `pip`, the plugin will be installed in the [https://pythonwheels.com/ wheel format], which is the modern standard for Python and a replacement for the egg format. 51 46 52 47 ==== From PyPI 53 48 54 Some plugins, such as [ th:TagsPlugin TracTags], can be installed directly from [https://pypi.org PyPI] using `pip`:49 Some plugins, such as [https://trac-hacks.org/wiki/TagsPlugin TracTags], can be installed directly from [https://pypi.org PyPI] using `pip`: 55 50 {{{#!sh 56 51 $ pip install TracTags … … 59 54 The version can be specified, which can be useful if you don't want to install the latest: 60 55 {{{#!sh 61 $ pip install TracTags== 0.1056 $ pip install TracTags==1.2 62 57 }}} 63 58 … … 69 64 }}} 70 65 71 Replace the `svn+` prefix with `git+` if installing 72 from a Git repository. 66 Replace the `svn+` prefix with `git+` if installing from a Git repository. 73 67 74 68 Or from the path or URL of a tar.gz or zip archive: … … 101 95 ==== Upgrading the environment 102 96 103 Some plugins require an environment upgrade. This will typically be necessary for plugins that implement `IEnvironmentSetupParticipant`. Common reasons for requiring an environment upgrade are to add tables to the database or add configuration parameters to trac.ini. A notification will be displayed when accessing Trac for the first time after installing a plugin and restarting the web server. To upgrade the environment, run the command:97 Some plugins require an environment upgrade. This will typically be necessary for plugins that implement `IEnvironmentSetupParticipant`. Common reasons for requiring an environment upgrade are to add tables to the database or add configuration parameters to `trac.ini`. A notification will be displayed when accessing Trac for the first time after installing a plugin and restarting the web server. To upgrade the environment, run the command: 104 98 105 99 {{{#!sh … … 111 105 ==== Redeploying static resources 112 106 113 If you [TracInstall#MappingStaticResources mapped static resources] so they are served by the web server, and the plugin contains static resources (CSS, !JavaScript and image files), the resources will need to be deployed to the location on the filesystem that is served by the web server.107 If you [TracInstall#MappingStaticResources mapped static resources] so they are served by the web server, and the plugin contains static resources, such as stylesheets, !JavaScript and image files, the resources will need to be deployed to the location on the filesystem that is served by the web server. 114 108 115 109 Execute the `deploy` command, as is done during install and [TracUpgrade#a5.Refreshstaticresources upgrade]: … … 193 187 '''Note''': !SetEnv requires the `mod_env` module, which needs to be activated for Apache. In this case the !SetEnv directive can also be used in the `mod_python` Location block. 194 188 195 For [TracFastCgi FastCGI], you 'll need to `-initial-env` option, or whatever is provided by your web server for setting environment variables.189 For [TracFastCgi FastCGI], you will need to `-initial-env` option, or whatever is provided by your web server for setting environment variables. 196 190 197 191 '''Note''': if you already use -initial-env to set the project directory for either a single project or parent, you will need to add an additional -initial-env directive to the !FastCgiConfig directive: … … 216 210 === Did you get the correct version of the Python egg? 217 211 218 Python eggs have the Python version encoded in their filename. For example, `MyPlugin-1.0-py2.5.egg` is an egg for Python 2.5, and will '''not''' be loaded if you're running a different Python version (such as 2.4 or 2.6).212 Python eggs have the Python version encoded in their filename. For example, `MyPlugin-1.0-py2.5.egg` is an egg for Python 2.5, and will '''not''' be loaded if you're running a different Python version, such as 2.4 or 2.6. 219 213 220 214 Also, verify that the egg file you downloaded is indeed a .zip archive. If you downloaded it from a Trac site, you may have downloaded the HTML preview page instead. … … 247 241 * Only one version of the plugin can be loaded for each running Trac server, i.e. each Python process. The Python namespaces and module list will be shared, and it cannot handle duplicates. Whether a plugin is `enabled` or `disabled` makes no difference. 248 242 * A globally installed plugin will override any version in the global or project plugins directories. A plugin from the global plugins directory will be discovered ''before'' any project plugins directory. 249 * If your Trac server hosts more than one project (as with `TRAC_ENV_PARENT_DIR` setups), having two versions of a plugin in two different projects will give unpredic atable results. Only one of them will load, and the one loaded will be shared by both projects. Trac will load the first plugin found, usually from the project that receives the first request.243 * If your Trac server hosts more than one project (as with `TRAC_ENV_PARENT_DIR` setups), having two versions of a plugin in two different projects will give unpredictable results. Only one of them will load, and the one loaded will be shared by both projects. Trac will load the first plugin found, usually from the project that receives the first request. 250 244 * Having more than one version listed inside Python site-packages is fine, because setuptools will make sure you get the version installed most recently. However, don't store more than one version inside a global or project plugins directory: neither the version number nor the installed date will matter at all. There is no way to determine which one will be located first when Trac searches the directory for plugins. 251 245