Reversing buildout and virtualenv instructions because I think
[mediagoblin.git] / docs / hackinghowto.rst
index 26267b7fa54526048d5febac4688e2fe1c876c8a..d829b1c013a2f05effa13d183c3f43a3e146ea69 100644 (file)
@@ -9,23 +9,35 @@ So you want to hack on GNU MediaGoblin?
 =======================================
 
 First thing to do is check out the `Web site
-<http://mediagoblin.org>`_ where we list all the project
+<http://mediagoblin.org/join/>`_ where we list all the project
 infrastructure including:
 
-* the mailing list
 * the IRC channel
-* the bug tracker
+* the mailing list
+* the issue tracker
 
 Additionally, we have information on how to get involved, who to talk
 to, what needs to be worked on, and other things besides!
 
+Second thing to do is take a look at :ref:`codebase-chapter` where
+we've started documenting how GNU MediaGoblin is built and how to add
+new things.
+
+Third you'll need to :ref:`get the requirements
+<get-requirements-section>`.
+
+Fourth, you'll need to build a development environment.  For this step, there are two options: 
 
-How to set up and maintain an environment for hacking
-=====================================================
+1. :ref:`buildout and bootstrap <hacking-with-buildout>` (easier) OR
+2. :ref:`virtualenv <hacking-with-virtualenv>` (more flexible, but harder)
 
+Pick one---don't do both!
+
+
+.. _get-requirements-section:
 
 Getting requirements
---------------------
+====================
 
 First, you need to have the following installed before you can build
 an environment for hacking on GNU MediaGoblin:
@@ -45,9 +57,29 @@ requirements::
     sudo apt-get install mongodb git-core python python-dev \
          python-lxml
 
+.. YouCanHelp::
+
+   If you have instructions for other GNU/Linux distributions to set
+   up requirements, let us know!
+
+
+.. _hacking-with-buildout:
+
+How to set up and maintain an environment for hacking with buildout
+===================================================================
+
+.. Note::
+
+   Either follow the instructions in this section OR follow the ones
+   in :ref:`hacking-with-virtualenv`.  But don't do both!
 
-Running bootstrap and buildout
-------------------------------
+
+**Requirements**
+
+No additional requirements.
+
+
+**Create a development environment**
 
 After installing the requirements, follow these steps:
 
@@ -67,99 +99,222 @@ session stuff, etc).  You can change this, but for development
 purposes this default should be fine.
 
 
-.. Note::
+**Updating for dependency changes**
+
+While hacking on GNU MediaGoblin over time, you'll eventually have to
+update your development environment because the dependencies have
+changed.  To do that, run::
 
-   We used `zc.buildout <http://www.buildout.org/>`_ because it
-   involves fewer steps to get things running and less knowledge of
-   Python packaging.  However, if you prefer to use `virtualenv
-   <http://pypi.python.org/pypi/virtualenv>`_, that should work just
-   fine.
+    ./bin/buildout
 
 
-Updating dependencies
----------------------
+**Updating for code changes**
 
-While hacking on GNU MediaGoblin over time, you'll eventually have to
-update your development environment.  To do that, run::
+You don't need to do anything---code changes are automatically
+available.
 
-    ./bin/buildout
 
+**Deleting your buildout**
+
+At some point, you may want to delete your buildout.  Perhaps it's to
+start over.  Perhaps it's to test building development environments
+with buildout.
+
+To do this, do::
 
-Wiping your environment for a clean-slate
------------------------------------------
+    rm -rf bin develop-eggs eggs mediagoblin.egg-info parts user_dev
+
+Usually buildout works pretty great and is super easy, but if you get
+problems with python-dateutil conflicts on your system, you may need
+to use virtualenv instead.
+
+
+.. _hacking-with-virtualenv:
+
+How to set up and maintain an environment for hacking with virtualenv
+=====================================================================
 
 .. Note::
 
-   Unless you're doing development and working on and testing creating
-   a new instance, you will probably never have to do this.  Will
-   plans to do this work and thus he documented it.
+   Either follow the instructions in this section OR follow the ones
+   in :ref:`hacking-with-buildout`.  But don't do both!
+
+
+**Requirements**
+
+* virtualenv: http://pypi.python.org/pypi/virtualenv
+* virtualenv wrapper:
+  http://www.doughellmann.com/projects/virtualenvwrapper/ (be sure to
+  read the `install instructions
+  <http://www.doughellmann.com/docs/virtualenvwrapper/install.html>`_)
+
+
+**Create a development environment**
+
+1. Clone the repository::
+
+       git clone http://git.gitorious.org/mediagoblin/mediagoblin.git
+
+2. Create a virtual environment::
+
+       mkvirtualenv --no-site-packages mediagoblin
+
+3. If that doesn't put you in the virutal environment you just
+   created, then do::
+
+       workon mediagoblin
+
+4. Run::
+
+       python setup.py develop
+
+That's it!
+
 
+**Activating a virtual environment**
 
-Delete the following directories:
+When you want to work on GNU MediaGoblin, you need to activate the
+virtual environment like this::
 
-* bin/
-* develop-eggs/
-* eggs/
-* mediagoblin.egg-info/
-* parts/
-* user_dev/
+    workon mediagoblin
 
-FIXME - how to drop data from mongodb?  we should probably write a
-script.
+
+**Deactivating a virtual environment**
+
+If you want to deactivate it, you can do this::
+
+    deactivate
+
+
+**Updating a virtual environment with dependency changes**
+
+1. Enter the virtual environment.
+
+2. Run::
+
+      python setup.py develop
+
+
+**Updating a virtual environment with code changes**
+
+You don't need to do anything---code changes are automatically
+available.
+
+
+**Deleting a virtual environment**
+
+At some point you may want to delete your virtual environment.
+Perhaps it's to start over.  Perhaps it's so you can test building
+development environments with virtualenv.
+
+To do this, do::
+
+    rmvirtualenv mediagoblin
 
 
 Running the server
 ==================
 
-Run::
+If you did virtualenv, run::
+
+    paster serve mediagoblin.ini --reload
+
+If you did buildout, run::
 
     ./bin/paster serve mediagoblin.ini --reload
 
 
+Running celeryd
+===============
+
+You need to do this if you want your media to process and actually
+show up.  It's probably a good idea in development to have the web
+server (above) running in one terminal and celeryd in another window.
+
+If you did virtualenv, run::
+
+    CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_celery celeryd
+
+If you did buildout, run::
+
+    CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_celery ./bin/celeryd
+
+
 Running the test suite
 ======================
 
-Run::
+If you did virtualenv, run::
+
+    nosetests
+
+If you did buildout, run::
 
     ./bin/nosetests
 
 
-What's where
-============
+Troubleshooting
+===============
+
+pymongo.errors.AutoReconnect: could not find master/primary
+-----------------------------------------------------------
+
+If you see this::
+
+    pymongo.errors.AutoReconnect: could not find master/primary
+
+then make sure mongodb is installed and running.
+
+If it's installed, check the mongodb log.  On my machine, that's ``/var/log/mongodb/mongodb.log``.  If you see something like::
+
+    old lock file: /var/lib/mongodb/mongod.lock.  probably means...
+
+Then delete the lock file and relaunch mongodb.
+
 
-After you've run buildout, you're faced with the following directory
-tree::
+Wiping your user data
+=====================
 
-    mediagoblin/
-    |- mediagoblin/              source code
-    |  |- tests/
-    |  |- templates/
-    |  |- auth/
-    |  \- submit/
-    |- docs/                     documentation
-    |
-    |        the rest of these directories are generated by
-    |        buildout.
-    |
-    |- bin/                      scripts
-    |- develop-eggs/
-    |- eggs/
-    |- mediagoblin.egg-info/
-    |- parts/
-    |- user_dev/                 sessions, etc
+.. Note::
+
+   Unless you're doing development and working on and testing creating
+   a new instance, you will probably never have to do this.  Will
+   plans to do this work and thus he documented it.
+
+.. YouCanHelp::
 
+   If you're familiar with MongoDB, we'd love to get a `script that
+   removes all the GNU MediaGoblin data from an existing instance
+   <http://bugs.foocorp.net/issues/296>`_.  Let us know!
 
 
 Quickstart for Django programmers
 =================================
 
-FIXME - write this
+We're not using Django, but the codebase is very Django-like in its
+structure.
+
+* ``routing.py`` is like ``urls.py`` in Django
+* ``models.py`` has mongokit ORM definitions
+* ``views.py`` is where the views go
+
+We're using MongoDB.  Basically, instead of a relational database with
+tables, you have a big JSON structure which acts a lot like a Python
+dict.
+
+
+.. YouCanHelp::
+
+   If there are other things that you think would help orient someone
+   new to GNU MediaGoblin but coming from Django, let us know!
 
 
 Bite-sized bugs to start with
 =============================
 
-FIXME - write this
+**May 3rd, 2011**:  We don't have a list of bite-sized bugs, yet, but
+this is important to us.  If you're interested in things to work on,
+let us know on `the mailing list <http://mediagoblin.org/join/>`_ or
+on the `IRC channel <http://mediagoblin.org/join/>`_.
 
 
 Tips for people new to coding
@@ -186,7 +341,10 @@ that are freely available on the Internet:
 
 These are all excellent texts.
 
-FIXME - are there good quality Python tutorial videos?
+.. YouCanHelp::
+
+   If you know of other good quality Python tutorials and Python
+   tutorial videos, let us know!
 
 
 Learning Libraries GNU MediaGoblin uses