Setting up the development environment¶
Python¶
First you must install Python 2.5 or later.
We don't use Python 3.0 because Django doesn't support it.
Do not forget to add the python to the path, if not already.
Python SetupTools¶
SetupTools is a python library that adds a easy_install command to your system. easy_install is a cool utility that allows you to install (almost) any python library/app with a simple command line.
To install setuptools: http://pypi.python.org/pypi/setuptools
Note: On debian, aptitude install python-setuptools will install it easily.
Check if easy_install is in your system path. If not, you will find it in the Scripts dir in your python installation folder.
Mercurial + Source code fetch¶
Download it here http://mercurial.selenic.com/ and install it.
Then open a terminal window and type:
$ hg clone http://hg.eve-corp-management.org/ecm/ <folder_where you want the code> ...
Mercurial will download all the code but will leave the working directory empty. Update it to the tip of the branch with the following command:
$ hg update ...
Note: there is a fine GUI application: TortoiseHg that can be used with mercurial. It works on Windows, Linux/FreeBSD and even MacOS.
Important: To ensure that any sensitive information will not be attached to your commits, be sure to set a username in mercurial configuration.
1#
2# Mercurial user configuration file
3# "~/.hgrc" or "%USERPROFILE%\mercurial.ini"
4#
5[ui]
6username = diabeteman
More details here
Register ECM clone into your Python installation¶
Change your directory to where you created the mercurial clone in and execute:
$ python setup.py develop
This will first install all ECM dependencies (django, south, etc.), add your clone directory to your Python path and install the ecm-admin tool.
Note: You might need root to execute this command.
Initialize a development instance¶
You should now be able to execute ecm-admin (located in /usr/local/bin/ecm-admin). Run the following command:
$ ecm-admin create <path to your dev instance> -q
Note: Be sure not to put the instance in the source tree to avoid putting it under source control by mistake.
The next command will initialize your instance (esp. the database)
$ ecm-admin init <instance-folder>
To load the latest datadump from CCP, do this (adapt the dump according to your database engine):
$ ecm-admin load <instance-folder> http://releases.eve-corp-management.org/eve_sde/inferno10/inferno10-sqlite-2.db.bz2
You can now start The development server with:
$ ecm-admin manage <instance-folder> runserver
or (from the instance directory)
$ python manage.py runserver
Enjoy!
What IDE?¶
I personally use Eclipse who has the good taste to be free and to run on Windows, Linux and Mac.
You will need the Pydev plugin that rocks as much as the pony. And you'll be fine.
Here's how to import the project (once Eclipse and the pyDev plugin installed and setup'd):
- Change to the Pydev perspective
- Select Import... in the File menu.
- Choose Import Existing Projects into Workspace...
- Enter the folder where you cloned Mercurial's repository
- Eclipse will display the ECM project
- Click finish
- Do not hesitate to read the documentation on Eclipse and the plugins it's not rocket science :D
After all, there's no obligation to work that way. There's plenty of other IDEs such as PyCharm (commercial), Vim or even notepad :D
Run the development server in debug mode into eclipse-pydev¶
You need to create a new PyDev project with a custom location to your instance. Two things are important:
- project root must be added to sources path
- the project must be named exactly after its containing folder.
Here are some screenshots :
Then you'll need to create a debug configuration. Go to the Run menu and choose Debug Configurations...
Mind the --noreload option after runserver. The debugger won't work if you do.
Finally, to run the server with the PyDev debugger, hit the Debug button :)
You can then add break points where it suits you.
Optional: Gevent¶
Gevent is used for the embedded production HTTP server of ECM instances. For development it is recommended to use Django simple development server with ./manage.py runserver.
To install it, you will need libevent-1.4 or later (with dev headers) and python dev headers. Then, run this command:
$ easy_install gevent
Optional: Logging with Multitail¶
MultiTail lets you view one or multiple files like the original tail program. The difference is that it creates multiple windows on your console (with ncurses).
Add this simple ECM color highlighting to /etc/multitail.conf:
1# ECM
2colorscheme:ecm
3cs_re:red,,bold:\[ERROR\].*$
4cs_re:red:^.*Error:
5cs_re:yellow:\[INFO.*\].*$
6cs_re:blue:line
7cs_re:yellow:[0-9]
8cs_re:green: [a-zA-Z_]*$
Usage:
$ multitail -cS ecm log.file