Developers Heads Up: Python Package renamed to "mediadrop"


Today I pushed several commits to rename the internals of MediaDrop and unfortunately this has some impact on developers extending MediaDrop. This post explains the process how to adapt your code to the latest git.

What changed?

With the commits I pushed today I pruned all references to the old "mediacore" name. Most notably this includes the Python package name "mediacore" (now "mediadrop") in a huge commit (see 6d7f9d9). but it affects also some CSS classes. And last but not least the Python "egg name" changed from "MediaCore" to "MediaDrop".

This of course breaks all plugins and customizations big time. Basically it's the worst code change you can think of as I touched every single code file.

But actually I added some compatibility mechanisms to lighten the pain as much as I could:

  • The entry point is now called mediadrop.plugin but the old mediacore.plugin will continue to work for 1-2 stable releases.
  • There is a fake "mediacore" Python package so you don't have to update all your imports at once (see 35ecb173).
  • The actual renames were done completely automated by a number of hand-crafted find/ack/grep/sed calls and I'm providing you with that script so you ran run the renames yourself.

How to adapt: Translators

If you only changed some translations (in a mediacore.po file) then updating is pretty simple:

  • create a copy of your mediacore.po file somewhere
  • update to the latest git
  • move the mediacore.po file back in its place but rename it to mediadrop.po file
  • run python setup.py update_catalog -l <your language>

How to adapt: Plugin developers

Ideally you should be good to go right of the start as long as you don't have "MediaCore" in your setup.py/install_requires (see 906c7c7e for such a change in the SEO plugin). You'll see some compatibility warnings but your plugin should be up and running anyway.

In the medium term you should:

  • Import only from the "mediadrop" package
  • Use the mediadrop.plugin entry point.

How to adapt: MediaDrop developers

If you modified the MediaDrop source code in a local git repository you need to merge in the rename yourself. Generally I think the best strategy here is to merge with MediaDrop just before the huge rename, run the rename script yourself and then merge again so you're really on top of the latest MediaDrop revision.

If you know git well you'll hardly loose any data even if something goes wrong (git reflog!). However if you want to be cautious just create a backup of your source code and create a new git branch before changing anything. Also you need my rename script – download it and put it somewhere (e.g. in the parent directory of your MediaDrop source code).

Assuming that you can handle the shell and you're using a Un*x system with the usual tools (find, ack, sed, grep, mv) here is a step-by-step guide:

# before: move all unversioned away and do not have any uncommitted changes.
# ensure that you configured the MediaDrop repository in git, e.g.:
git remote add upstream git@github.com:mediadrop/mediadrop.git
git fetch upstream

# merge your branch with MediaDrop just before the huge rename
git merge 4eaead27155404dddab6fab881601c801839b739
# now you likely see some merge conflicts. you need to resolve these.
# once you "git add"ed/"git remove"ed the changes, the final pre-rename commit
git commit -m "update to MediaDrop 0.11 before the mediadrop package rename"

# now magic happens
# (you need to adapt the path shown below, depending where you downloaded
# the shell script)
sh ../rename-mediacore-package.sh

# package all changes up in a huge commit
git add mediadrop
git add deployment-scripts/mod_fastcgi/mediadrop.fcgi
git add deployment-scripts/mod_wsgi/mediadrop.wsgi
git add deployment-scripts/uwsgi/mediadrop.wsgi
git commit -a -m 'rename package name from "mediacore" to "mediadrop" (similar to 6d7f9d9dd27d6910c016bc943d7ee3e1d7a36988)'

# merge upstream rename commit to clean up the remaining changes
git merge 6d7f9d9dd27d6910c016bc943d7ee3e1d7a36988
# if there are any conflicts you need to merge these and then do
# git commit -a -m 'merge big "mediacore" package rename'

# and now merge in a state after the big rename
git merge upstream/master
# alternatively just merge the "mediacore" compatibility package:
# git merge 35ecb17308229f6d7b41d9b7c37c6bda2670e9f4 -m "update to the latest MediaDrop code (post-rename)"

Pheew, done. I guess it was some work but I know you can manage it. I know resolving the merge conflicts might be a pain. If you need some help on resolving merge conflicts I hope the git documentation on "basic merge conflicts" will help you.

Help?!?

I tried to ensure that the commands above really work so I converted repositories from three selected community members. However it's always possible that I missed something.

If you have any questions please send an email to the mailing list.