Commit | Line | Data |
---|---|---|
5a40e1ec WKG |
1 | .. _hacking-howto: |
2 | ||
00fdc7bd WKG |
3 | =============== |
4 | Hacking HOWTO | |
5 | =============== | |
6 | ||
5a40e1ec WKG |
7 | So you want to hack on GNU MediaGoblin? |
8 | ======================================= | |
56d507b6 | 9 | |
9d952fdc | 10 | First thing to do is check out the `Web site |
9610848c | 11 | <http://mediagoblin.org/join/>`_ where we list all the project |
9d952fdc | 12 | infrastructure including: |
56d507b6 | 13 | |
56d507b6 | 14 | * the IRC channel |
9610848c WKG |
15 | * the mailing list |
16 | * the issue tracker | |
56d507b6 WKG |
17 | |
18 | Additionally, we have information on how to get involved, who to talk | |
19 | to, what needs to be worked on, and other things besides! | |
20 | ||
9610848c WKG |
21 | Second thing to do is take a look at :ref:`codebase-chapter` where |
22 | we've started documenting how GNU MediaGoblin is built and how to add | |
23 | new things. | |
24 | ||
4564da22 WKG |
25 | Third you'll need to :ref:`get the requirements |
26 | <get-requirements-section>`. | |
56d507b6 | 27 | |
2aa3bb11 WKG |
28 | Fourth, you'll need to build a development environment. We use buildout, |
29 | but if you want to use virtualenv, there's a set of mediocre not-very-supported | |
30 | steps in the `wiki <https://gitorious.org/mediagoblin/pages/Home>`_. | |
4564da22 WKG |
31 | |
32 | ||
33 | .. _get-requirements-section: | |
56d507b6 | 34 | |
c66d0f5c | 35 | Getting requirements |
4564da22 | 36 | ==================== |
56d507b6 | 37 | |
c66d0f5c WKG |
38 | First, you need to have the following installed before you can build |
39 | an environment for hacking on GNU MediaGoblin: | |
56d507b6 | 40 | |
c66d0f5c | 41 | * Python 2.6 or 2.7 - http://www.python.org/ |
56d507b6 | 42 | |
c66d0f5c | 43 | You'll need Python as well as the dev files for building modules. |
56d507b6 | 44 | |
c66d0f5c WKG |
45 | * python-lxml - http://lxml.de/ |
46 | * git - http://git-scm.com/ | |
47 | * MongoDB - http://www.mongodb.org/ | |
48 | ||
49 | If you're running Debian GNU/Linux or a Debian-derived distribution | |
50 | such as Mint or Ubuntu, running the following should install these | |
51 | requirements:: | |
52 | ||
5740a0d6 WKG |
53 | sudo apt-get install mongodb git-core python python-dev \ |
54 | python-lxml | |
c66d0f5c | 55 | |
4564da22 | 56 | .. YouCanHelp:: |
52be418a | 57 | |
4564da22 WKG |
58 | If you have instructions for other GNU/Linux distributions to set |
59 | up requirements, let us know! | |
52be418a | 60 | |
52be418a | 61 | |
7a5ddb45 CAW |
62 | .. _hacking-with-buildout: |
63 | ||
2aa3bb11 | 64 | |
7a5ddb45 CAW |
65 | How to set up and maintain an environment for hacking with buildout |
66 | =================================================================== | |
67 | ||
7a5ddb45 CAW |
68 | **Requirements** |
69 | ||
70 | No additional requirements. | |
71 | ||
72 | ||
73 | **Create a development environment** | |
74 | ||
75 | After installing the requirements, follow these steps: | |
76 | ||
77 | 1. Clone the repository:: | |
78 | ||
79 | git clone http://git.gitorious.org/mediagoblin/mediagoblin.git | |
80 | ||
81 | 2. Bootstrap and run buildout:: | |
82 | ||
83 | cd mediagoblin | |
84 | python bootstrap.py && ./bin/buildout | |
85 | ||
86 | ||
87 | That's it! Using this method, buildout should create a ``user_dev`` | |
88 | directory, in which certain things will be stored (media, beaker | |
89 | session stuff, etc). You can change this, but for development | |
90 | purposes this default should be fine. | |
91 | ||
92 | ||
93 | **Updating for dependency changes** | |
94 | ||
95 | While hacking on GNU MediaGoblin over time, you'll eventually have to | |
96 | update your development environment because the dependencies have | |
97 | changed. To do that, run:: | |
98 | ||
f4cfb4e9 | 99 | ./bin/buildout && ./bin/gmg migrate |
7a5ddb45 CAW |
100 | |
101 | ||
102 | **Updating for code changes** | |
103 | ||
104 | You don't need to do anything---code changes are automatically | |
105 | available. | |
106 | ||
107 | ||
108 | **Deleting your buildout** | |
109 | ||
110 | At some point, you may want to delete your buildout. Perhaps it's to | |
111 | start over. Perhaps it's to test building development environments | |
112 | with buildout. | |
113 | ||
114 | To do this, do:: | |
115 | ||
116 | rm -rf bin develop-eggs eggs mediagoblin.egg-info parts user_dev | |
117 | ||
4564da22 | 118 | |
11e5b197 CAW |
119 | Running the server |
120 | ================== | |
121 | ||
2aa3bb11 | 122 | Run:: |
11e5b197 CAW |
123 | |
124 | ./bin/paster serve mediagoblin.ini --reload | |
125 | ||
126 | ||
1c424df5 CAW |
127 | Running celeryd |
128 | =============== | |
129 | ||
130 | You need to do this if you want your media to process and actually | |
131 | show up. It's probably a good idea in development to have the web | |
132 | server (above) running in one terminal and celeryd in another window. | |
133 | ||
2aa3bb11 | 134 | Run:: |
1c424df5 CAW |
135 | |
136 | CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_celery ./bin/celeryd | |
137 | ||
138 | ||
693b674c CAW |
139 | Too much work? Don't want to run an http server and celeryd at the |
140 | same time? For development purposes there's a shortcut:: | |
141 | ||
142 | CELERY_ALWAYS_EAGER=true ./bin/paster serve mediagoblin.ini --reload | |
143 | ||
144 | This way the web server will block on processing items until they are | |
145 | done, but you don't need to run celery separately (which is probably | |
c0bf3c80 CAW |
146 | good enough for development purposes, but something you almost |
147 | certainly shouldn't do in production). | |
693b674c CAW |
148 | |
149 | ||
11e5b197 CAW |
150 | Running the test suite |
151 | ====================== | |
152 | ||
2aa3bb11 | 153 | Run:: |
11e5b197 | 154 | |
7eac4285 | 155 | CELERY_CONFIG_MODULE=mediagoblin.celery_setup.from_tests ./bin/nosetests |
11e5b197 CAW |
156 | |
157 | ||
3e4a2f2b CAW |
158 | Running a shell |
159 | =============== | |
160 | ||
161 | If you want a shell with your database pre-setup and an instantiated | |
2aa3bb11 | 162 | application ready and at your fingertips.... |
3e4a2f2b | 163 | |
2aa3bb11 | 164 | Run:: |
3e4a2f2b CAW |
165 | |
166 | ./bin/gmg shell | |
167 | ||
3e4a2f2b | 168 | |
4564da22 WKG |
169 | Troubleshooting |
170 | =============== | |
5740a0d6 | 171 | |
4564da22 WKG |
172 | pymongo.errors.AutoReconnect: could not find master/primary |
173 | ----------------------------------------------------------- | |
9d952fdc | 174 | |
4564da22 | 175 | If you see this:: |
9d952fdc | 176 | |
4564da22 | 177 | pymongo.errors.AutoReconnect: could not find master/primary |
9d952fdc | 178 | |
4564da22 | 179 | then make sure mongodb is installed and running. |
5740a0d6 | 180 | |
2aa3bb11 WKG |
181 | If it's installed, check the mongodb log. On my machine, that's |
182 | ``/var/log/mongodb/mongodb.log``. If you see something like:: | |
2704f7a6 WKG |
183 | |
184 | old lock file: /var/lib/mongodb/mongod.lock. probably means... | |
185 | ||
186 | Then delete the lock file and relaunch mongodb. | |
187 | ||
5740a0d6 | 188 | |
4564da22 WKG |
189 | Wiping your user data |
190 | ===================== | |
191 | ||
192 | .. Note:: | |
193 | ||
194 | Unless you're doing development and working on and testing creating | |
195 | a new instance, you will probably never have to do this. Will | |
196 | plans to do this work and thus he documented it. | |
9610848c WKG |
197 | |
198 | .. YouCanHelp:: | |
199 | ||
1b734c4d CAW |
200 | If you're familiar with MongoDB, we'd love to get a `script that |
201 | removes all the GNU MediaGoblin data from an existing instance | |
202 | <http://bugs.foocorp.net/issues/296>`_. Let us know! | |
5740a0d6 WKG |
203 | |
204 | ||
9610848c WKG |
205 | Quickstart for Django programmers |
206 | ================================= | |
5740a0d6 | 207 | |
9610848c WKG |
208 | We're not using Django, but the codebase is very Django-like in its |
209 | structure. | |
5740a0d6 | 210 | |
9610848c WKG |
211 | * ``routing.py`` is like ``urls.py`` in Django |
212 | * ``models.py`` has mongokit ORM definitions | |
213 | * ``views.py`` is where the views go | |
5740a0d6 | 214 | |
9610848c WKG |
215 | We're using MongoDB. Basically, instead of a relational database with |
216 | tables, you have a big JSON structure which acts a lot like a Python | |
217 | dict. | |
5740a0d6 WKG |
218 | |
219 | ||
9610848c | 220 | .. YouCanHelp:: |
5a40e1ec | 221 | |
9610848c WKG |
222 | If there are other things that you think would help orient someone |
223 | new to GNU MediaGoblin but coming from Django, let us know! | |
5a40e1ec WKG |
224 | |
225 | ||
226 | Bite-sized bugs to start with | |
227 | ============================= | |
228 | ||
9610848c WKG |
229 | **May 3rd, 2011**: We don't have a list of bite-sized bugs, yet, but |
230 | this is important to us. If you're interested in things to work on, | |
231 | let us know on `the mailing list <http://mediagoblin.org/join/>`_ or | |
232 | on the `IRC channel <http://mediagoblin.org/join/>`_. | |
9d952fdc WKG |
233 | |
234 | ||
235 | Tips for people new to coding | |
236 | ============================= | |
237 | ||
845c3ae2 WKG |
238 | Learning Python |
239 | --------------- | |
9d952fdc WKG |
240 | |
241 | GNU MediaGoblin is written using a programming language called `Python | |
242 | <http://python.org/>`_. | |
243 | ||
244 | There are two different incompatible iterations of Python which I'll | |
245 | refer to as Python 2 and Python 3. GNU MediaGoblin is written in | |
246 | Python 2 and requires Python 2.6 or 2.7. At some point, we might | |
247 | switch to Python 3, but that's a future thing. | |
248 | ||
249 | You can learn how to code in Python 2 from several excellent books | |
250 | that are freely available on the Internet: | |
251 | ||
252 | * `Learn Python the Hard Way <http://learnpythonthehardway.org/>`_ | |
253 | * `Dive Into Pyton <http://diveintopython.org/>`_ | |
254 | * `Python for Software Design <http://www.greenteapress.com/thinkpython/>`_ | |
255 | * `A Byte of Python <http://www.swaroopch.com/notes/Python>`_ | |
256 | ||
257 | These are all excellent texts. | |
258 | ||
9610848c WKG |
259 | .. YouCanHelp:: |
260 | ||
261 | If you know of other good quality Python tutorials and Python | |
262 | tutorial videos, let us know! | |
9d952fdc WKG |
263 | |
264 | ||
845c3ae2 WKG |
265 | Learning Libraries GNU MediaGoblin uses |
266 | --------------------------------------- | |
9d952fdc WKG |
267 | |
268 | GNU MediaGoblin uses a variety of libraries in order to do what it | |
3dca2776 | 269 | does. These libraries are listed in the :ref:`codebase-chapter` |
9d952fdc WKG |
270 | along with links to the project Web sites and documentation for the |
271 | libraries. | |
272 | ||
273 | There are a variety of Python-related conferences every year that have | |
274 | sessions covering many aspects of these libraries. You can find them | |
275 | at `Python Miro Community <http://python.mirocommunity.org>`_ [0]_. | |
276 | ||
277 | .. [0] This is a shameless plug. Will Kahn-Greene runs Python Miro | |
278 | Community. | |
279 | ||
280 | If you have questions or need help, find us on the mailing list and on | |
281 | IRC. | |
845c3ae2 WKG |
282 | |
283 | ||
284 | .. _hacking-howto-git: | |
285 | ||
286 | Learning git | |
287 | ------------ | |
288 | ||
289 | git is an interesting and very powerful tool. Like all powerful | |
290 | tools, it has a learning curve. | |
291 | ||
292 | If you're new to git, we highly recommend the following resources for | |
293 | getting the hang of it: | |
294 | ||
295 | * `Learn Git <http://learn.github.com/p/intro.html>`_ --- the GitHub | |
296 | intro to git | |
297 | * `Pro Git <http://progit.org/book/>`_ --- fantastic book | |
298 | * `Git casts <http://gitcasts.com/>`_ --- screencast covering git | |
299 | usage | |
300 | * `Git Reference <http://gitref.org/>`_ --- Git reference that makes | |
301 | it easier to get the hang of git if you're coming from other version | |
302 | control systems | |
303 | ||
2aa3bb11 WKG |
304 | There's also a git mission at `OpenHatch <http://openhatch.org/>`_. |
305 | ||
845c3ae2 WKG |
306 | |
307 | Learning other utilities | |
308 | ------------------------ | |
309 | ||
310 | The `OpenHatch <http://openhatch.org/>`_ site has a series of | |
311 | `training missions <http://openhatch.org/missions/>`_ which are | |
312 | designed to help you learn how to use these tools. | |
313 | ||
2aa3bb11 WKG |
314 | If you're new to tar, diff, patch and git, we highly recommend you sign |
315 | up with OpenHatch and do the missions. |