Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Sharing code between different projects?

Thread Tools

Re: Sharing code between different projects?

Cameron Simpson
Posts: n/a
On 13Aug2012 17:53, andrea crotti <(E-Mail Removed)> wrote:
| I am in the situation where I am working on different projects that
| might potentially share a lot of code.
| I started to work on project A, then switched completely to project B
| and in the transiction I copied over a lot of code with the
| corresponding tests, and I started to modify it.
| Now it's time to work again on project A, but I don't want to copy
| things over again.
| The problem is that there are functions/classes from many domains, so it
| would not make much sense to create a real project, and the only name I
| could give might be "utils or utilities"..
| In plus the moment the code is shared I must take care of versioning and
| how to link different pieces together (we use perforce by the way).

Having just skimmed this thread, one thing I haven't quite seen suggested is

Really do make a third "utilities" project, and treat "the project" and
"deploy" as separate notions. So to actually run/deploy project A's code
you'd have a short script that copied project A and the utilities project
code into a tree and ran off that. Or even a simple process/script to
update the copy of "utilities" in "project A"'s area.

So you don't "share" code on an even handed basis but import the
"utilities" library into each project as needed.

I do this (one my own very small scale) in one of two ways:

- as needed, copy the desired revision of utilities into the project's
library space and do perforce's equivalent of Mercurial's addremove
on that library tree (comment "update utilities to revision X").

- keep a perforce work area for the utilities in your project A area,
where your working project A can hook into it with a symlink or some
deploy/copy procedure as suggested above.
With this latter one you can push back into the utilities library
from your "live" project, because you have a real checkout. So:


Personally I become more and more resistent to cut/paste even for small
things as soon as multiple people use it; you will never get to backport
updates to even trivial code to all the copies.

Cameron Simpson <(E-Mail Removed)>

The mere existence of a problem is no proof of the existence of a solution.
- Yiddish Proverb
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Sharing code between different projects? andrea crotti Python 2 08-15-2012 06:07 PM
Re: Sharing code between different projects? andrea crotti Python 0 08-15-2012 09:05 AM
Sharing code between different projects? andrea crotti Python 1 08-14-2012 03:35 PM
Re: Sharing code between different projects? Jean-Michel Pichavant Python 0 08-14-2012 02:34 PM
Re: Sharing code between different projects? Chris Angelico Python 0 08-13-2012 10:16 PM