Project

General

Profile

Setup And Install » History » Version 8

Luke Murphey, 02/05/2013 07:51 AM

1 1 Luke Murphey
h1. Setup And Install
2 1 Luke Murphey
3 2 Luke Murphey
Below are instructions for how to run your own instance of TextCritical.
4 2 Luke Murphey
5 1 Luke Murphey
h2. Install Prerequisites
6 1 Luke Murphey
7 2 Luke Murphey
To run TextCritical, you will need:
8 2 Luke Murphey
9 2 Luke Murphey
* "Django 1.4.*":https://www.djangoproject.com/download/
10 2 Luke Murphey
* "Python 2.7":http://www.python.org/getit/
11 4 Luke Murphey
* A database (you can use SQLite to avoid extensive database setup)
12 2 Luke Murphey
13 1 Luke Murphey
h2. Install TextCritical Application
14 1 Luke Murphey
15 2 Luke Murphey
Check out the source code from http://svn.lukemurphey.net/textcritical.com using a "Subversion client":http://en.wikipedia.org/wiki/Comparison_of_Subversion_clients.
16 2 Luke Murphey
17 2 Luke Murphey
Copy start_here_settings.py to settings.py (under the src directory). Update the settings.py file per your host.
18 2 Luke Murphey
19 1 Luke Murphey
h2. Configure Initialize Database
20 1 Luke Murphey
21 2 Luke Murphey
Specify a database in settings.py unless you intend to use SQLite.
22 2 Luke Murphey
23 2 Luke Murphey
After configuring the database, run syncdb (from the src directory):
24 2 Luke Murphey
25 1 Luke Murphey
<pre>
26 1 Luke Murphey
python manage.py syncdb
27 1 Luke Murphey
</pre>
28 1 Luke Murphey
29 1 Luke Murphey
h2. Import Works
30 1 Luke Murphey
31 1 Luke Murphey
You will need to import the works into the library in order to have something for the site to provide access to. The easy way to do this is to use a prebuilt library. The more difficult way is to import the works yourself.
32 1 Luke Murphey
33 1 Luke Murphey
h3. Using Existing Library
34 1 Luke Murphey
35 1 Luke Murphey
To use an existing library, copy the library.sqlite file to the server. By default, it should be placed in the src directory.
36 1 Luke Murphey
37 1 Luke Murphey
h3. Importing Works
38 1 Luke Murphey
39 1 Luke Murphey
If you want to import works manually, then following the steps below.
40 1 Luke Murphey
41 1 Luke Murphey
First, initialize the library database.
42 1 Luke Murphey
43 1 Luke Murphey
<pre>
44 1 Luke Murphey
python manage.py syncdb --database=library
45 1 Luke Murphey
</pre>
46 1 Luke Murphey
47 2 Luke Murphey
Next, download the relevant works. The Perseus works can be obtained from "Perseus.tufts.edu":http://www.perseus.tufts.edu/hopper/opensource/download. Make sure to get the classics library. Decompress the archive.
48 1 Luke Murphey
49 2 Luke Murphey
Start the import process by running the following command, substituting "/Users/Luke/Perseus_Directory" with the location where you placed the files:
50 1 Luke Murphey
51 1 Luke Murphey
<pre>
52 1 Luke Murphey
python manage.py batch_import_perseus -d "/Users/Luke/Perseus_Directory"
53 1 Luke Murphey
</pre>
54 1 Luke Murphey
55 6 Luke Murphey
The import process may take a while (it takes about 70 minutes on a Core i7 with 8 GB of RAM). *Make sure to set DEBUG to False* before running the import. Otherwise, memory consumption will grow until the import completes.
56 2 Luke Murphey
57 8 Luke Murphey
h3. Indexing Works
58 8 Luke Murphey
59 8 Luke Murphey
You'll need to index the works for the search engine to work properly.
60 8 Luke Murphey
61 8 Luke Murphey
After importing the works, run the following:
62 8 Luke Murphey
63 8 Luke Murphey
<pre>
64 8 Luke Murphey
python manage.py make_search_indexes -c
65 8 Luke Murphey
</pre>
66 8 Luke Murphey
67 1 Luke Murphey
h2. Start Web Server
68 2 Luke Murphey
69 4 Luke Murphey
For production installs, you ought to use a production web-server like Apache. For development, you can use the built in Django web-server:
70 1 Luke Murphey
71 1 Luke Murphey
<pre>
72 1 Luke Murphey
python manage.py runserver 0.0.0.0:8080
73 4 Luke Murphey
</pre>
74 4 Luke Murphey
75 4 Luke Murphey
Alternatively, you can use the included CherryPy server which should be good enough for production use. To use it, start "run_server.py" after setting WEB_SERVER_ADDRESS and WEB_SERVER_PORT in settings.py; example below:
76 4 Luke Murphey
77 4 Luke Murphey
<pre>
78 4 Luke Murphey
<code class="python">
79 4 Luke Murphey
# The address and port to use when using the built-in web-server
80 4 Luke Murphey
WEB_SERVER_ADDRESS = '0.0.0.0' # Use '127.0.0.1' to serve content to localhost only
81 4 Luke Murphey
WEB_SERVER_PORT    = 8080
82 4 Luke Murphey
</code>
83 2 Luke Murphey
</pre>
84 3 Luke Murphey
85 7 Luke Murphey
h2. Common Setup Issues
86 3 Luke Murphey
87 3 Luke Murphey
h3. Syncdb Fails Saying it couldn't create "django_content_type"
88 3 Luke Murphey
89 3 Luke Murphey
This has something to do with database routing. It can be solved by adding the following to the settings.py file and re-running syncdb:
90 3 Luke Murphey
91 3 Luke Murphey
<pre>
92 3 Luke Murphey
DATABASE_ROUTING = []
93 3 Luke Murphey
</pre>
94 3 Luke Murphey
95 5 Luke Murphey
Once syncdb succeeds, delete this line.
96 5 Luke Murphey
97 5 Luke Murphey
Reference: https://code.djangoproject.com/ticket/16039
98 5 Luke Murphey
99 3 Luke Murphey
h3. Syncdb Fails When Creating Superuser
100 3 Luke Murphey
101 3 Luke Murphey
<pre>
102 3 Luke Murphey
You just installed Django's auth system, which means you don't have any superusers defined.                                                 
103 3 Luke Murphey
Would you like to create one now? (yes/no): yes                                                                                             
104 3 Luke Murphey
Traceback (most recent call last):                                                                                                          
105 3 Luke Murphey
  File "manage.py", line 10, in <module>                                                                                                    
106 3 Luke Murphey
    execute_from_command_line(sys.argv)                                                                                                     
107 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line                  
108 3 Luke Murphey
    utility.execute()                                                                                                                       
109 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute                                    
110 3 Luke Murphey
    self.fetch_command(subcommand).run_from_argv(self.argv)                                                                                 
111 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 196, in run_from_argv                                  
112 3 Luke Murphey
    self.execute(*args, **options.__dict__)                                                                                                 
113 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute                                        
114 3 Luke Murphey
    output = self.handle(*args, **options)                                                                                                  
115 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 371, in handle                                         
116 3 Luke Murphey
    return self.handle_noargs(**options)                                                                                                    
117 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 110, in handle_noargs                       
118 3 Luke Murphey
    emit_post_sync_signal(created_models, verbosity, interactive, db)                                                                       
119 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 189, in emit_post_sync_signal                           
120 3 Luke Murphey
    interactive=interactive, db=db)                                                                                                         
121 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send                                            
122 3 Luke Murphey
    response = receiver(signal=self, sender=sender, **named)                                                                                
123 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 73, in create_superuser                    
124 3 Luke Murphey
    call_command("createsuperuser", interactive=True, database=db)                                                                          
125 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 150, in call_command                               
126 3 Luke Murphey
    return klass.execute(*args, **defaults)                                                                                                 
127 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 232, in execute                                        
128 3 Luke Murphey
    output = self.handle(*args, **options)                                                                                                  
129 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 70, in handle              
130 3 Luke Murphey
    default_username = get_default_username()                                                                                               
131 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 105, in get_default_username               
132 3 Luke Murphey
    default_username = get_system_username()                                                                                                
133 3 Luke Murphey
  File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 85, in get_system_username                 
134 3 Luke Murphey
    return getpass.getuser().decode(locale.getdefaultlocale()[1])                                                                           
135 3 Luke Murphey
TypeError: decode() argument 1 must be string, not None   
136 3 Luke Murphey
</pre>
137 3 Luke Murphey
138 3 Luke Murphey
You may need to set your locale by running the following before running syncdb:
139 3 Luke Murphey
140 3 Luke Murphey
<pre>
141 3 Luke Murphey
export LC_ALL="en_US.UTF-8"
142 3 Luke Murphey
</pre>
143 3 Luke Murphey
144 3 Luke Murphey
Delete the auth_users table and do another syncdb to try again.
145 1 Luke Murphey
146 1 Luke Murphey
Reference: https://code.djangoproject.com/ticket/16017
147 7 Luke Murphey
148 7 Luke Murphey
h3. "__init__() keywords must be strings" when running Perseus Importer
149 7 Luke Murphey
150 7 Luke Murphey
This is caused by a "known bug in Python 2.6":http://bugs.python.org/issue2646 in which unicode arguments are not handled correctly. Upgrading to Python 2.7 resolves the issue.