Opened 8 years ago

# Possible bug related to "packages.pth"

Reported by: Owned by: anonymous normal TracSvnPoliciesPlugin major 0.11

## What version are you using?

Checkout revision 5144 for Trac 0.11.

## What were you doing when the problem occured?

1. edit svnpolicy.conf
2. python setup.py bdist_egg
3. cp dist/TracSVNPoliciesPlugin-0.2-py2.5.egg /path/to/tracroot/plugins
4. edit /path/to/tracroot/conf/trac.ini
5. enable "Require log messages for commits" on the Administration UI
6. try to commit something without a log message

## What happened? What did you expect to happen instead?

Traceback (most recent call last):
File "./hooks/pre-commit", line 3, in <module>
File "./.egg-cache/TracSVNPoliciesPlugin-0.2-py2.5.egg-tmp/svnpolicies/hooks/loader.py", line 39, in <module>
from svnpolicies import api
ImportError: No module named svnpolicies


the log message isn't conform to the project policy!


Patch the following file like this:

• ## svnpolicies/api.py

 'get_site_packages'] def get_site_packages(): return path.sep.join(__file__.split(path.sep)[:-3]) return path.sep.join(__file__.split(path.sep)[:-2]) def validate_email(email): """

or change

/path/to/tracroot/plugins


manually to something like this

/path/to/tracroot/plugins/TracSVNPoliciesPlugin-0.2-py2.5.egg


### comment:1 Changed 8 years ago by Robert Corsaro

Owner: changed from Culapov Andrei to Robert Corsaro

### comment:2 Changed 8 years ago by Gunnar Thielebein

Just tried to adapt the above patch but it failed. Message on commits remains the same. Config is the same, as above. What else to try?

### comment:3 Changed 2 years ago by Ryan J Ollos

Owner: Robert Corsaro deleted

### comment:4 Changed 6 months ago by Ryan J Ollos

Description: modified (diff)

### comment:5 Changed 6 months ago by Ryan J Ollos

I see a few problems with the plugin design:

• svnpolicy.conf is compiled in the egg, so the egg must be recreated when the config is changed.
• The location of site-packages is retrieved through the location of the egg. This causes problems with developing in "edit mode", and I assume would also cause problems if the egg is placed in the Environment plugins directory rather than the site-packages directory.
• The plugin writes to packages.pth in the egg in response to a POST request. I don't think we can assume that the web server will have write access to the egg.

We do need a way to pass environment variables to the hook scripts, which has always been a problem with Subversion since the hooks run in an empty environment. Subversion 1.8 has a configuration for hook script environment variables. I think we could eliminate svnpolicy.conf and hooks/packages.pth, and instruct the user how to configure the hooks environment in Subversion 1.8 and later. Subversion 1.8 seems like a reasonable requirement since it was released in June 2013.

Last edited 6 months ago by Ryan J Ollos (previous) (diff)

### Modify Ticket

Change Properties