Changes between Version 5 and Version 6 of TracPlugins


Ignore:
Timestamp:
Nov 7, 2023, 4:50:51 PM (6 months ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TracPlugins

    v5 v6  
    77== Plugin discovery
    88
    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.
     9A 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.
    1010
    1111== Installing a Trac plugin
    1212
    13 The instructions below are applicable to a 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.
     13The 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.
    1414
    1515=== For a single project
    1616
    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:
     17Packages 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:
    2018
    2119* 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:
    2421 {{{#!sh
    2522$ python setup.py bdist_egg
     
    2825* Copy the egg file to the `plugins` directory of the [TracEnvironment project environment].
    2926
    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).
     27Make 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.
    3128
    3229Trac 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.
     
    4643The 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].
    4744
    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.
     45Using `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.
    5146
    5247==== From PyPI
    5348
    54 Some plugins, such as [th:TagsPlugin TracTags], can be installed directly from [https://pypi.org PyPI] using `pip`:
     49Some plugins, such as [https://trac-hacks.org/wiki/TagsPlugin TracTags], can be installed directly from [https://pypi.org PyPI] using `pip`:
    5550{{{#!sh
    5651$ pip install TracTags
     
    5954The version can be specified, which can be useful if you don't want to install the latest:
    6055{{{#!sh
    61 $ pip install TracTags==0.10
     56$ pip install TracTags==1.2
    6257}}}
    6358
     
    6964}}}
    7065
    71 Replace the `svn+` prefix with `git+` if installing
    72 from a Git repository.
     66Replace the `svn+` prefix with `git+` if installing from a Git repository.
    7367
    7468Or from the path or URL of a tar.gz or zip archive:
     
    10195==== Upgrading the environment
    10296
    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:
     97Some 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:
    10498
    10599{{{#!sh
     
    111105==== Redeploying static resources
    112106
    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.
     107If 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.
    114108
    115109Execute the `deploy` command, as is done during install and [TracUpgrade#a5.Refreshstaticresources upgrade]:
     
    193187'''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.
    194188
    195 For [TracFastCgi FastCGI], you'll need to `-initial-env` option, or whatever is provided by your web server for setting environment variables.
     189For [TracFastCgi FastCGI], you will need to `-initial-env` option, or whatever is provided by your web server for setting environment variables.
    196190
    197191'''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:
     
    216210=== Did you get the correct version of the Python egg?
    217211
    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).
     212Python 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.
    219213
    220214Also, 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.
     
    247241* 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.
    248242* 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 unpredicatable 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.
    250244* 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.
    251245