Permalink
Browse files

Python packaging fixes.

  • Loading branch information...
John Tobey John Tobey
John Tobey authored and John Tobey committed Aug 30, 2011
1 parent 2a0a41a commit 761e14c9a2cfcebc3af3ef6f4b81b313c4935874
View
@@ -26,14 +26,14 @@
import time
import binascii
-from Abe import version
-from Abe import DataStore
-from Abe import readconf
+import version
+import DataStore
+import readconf
# bitcointools -- modified deserialize.py to return raw transaction
-from Abe import deserialize
-from Abe import util # Added functions.
-from Abe import base58
+import deserialize
+import util # Added functions.
+import base58
__version__ = version.__version__
@@ -130,8 +130,7 @@ class Abe:
def __init__(abe, store, args):
abe.store = store
abe.args = args
- abe.htdocs = os.path.join(os.path.split(__file__)[0],
- args.document_root or 'htdocs')
+ abe.htdocs = args.document_root or find_htdocs()
abe.static_path = '' if args.static_path is None else args.static_path
abe.template_vars = args.template_vars.copy()
abe.template_vars['STATIC_PATH'] = (
@@ -1565,6 +1564,9 @@ def serve_static(abe, path, start_response):
def is_address_version(abe, v):
return len(v) == 1
+def find_htdocs():
+ return os.path.join(os.path.split(__file__)[0], 'htdocs')
+
def get_int_param(page, name):
vals = page['params'].get(name)
return vals and int(vals[0])
@@ -1722,12 +1724,11 @@ def serve(store):
# FastCGI server.
from flup.server.fcgi import WSGIServer
- # In the case where the web server starts abe.py but can't
- # signal it on server shutdown (because Abe runs as a
- # different user) we arrange the following. FastCGI script
- # passes its pid as --watch-pid=PID and enters an infinite
- # loop. We check every minute whether it has terminated and
- # exit when it has.
+ # In the case where the web server starts Abe but can't signal
+ # it on server shutdown (because Abe runs as a different user)
+ # we arrange the following. FastCGI script passes its pid as
+ # --watch-pid=PID and enters an infinite loop. We check every
+ # minute whether it has terminated and exit when it has.
wpid = args.watch_pid
if wpid is not None:
wpid = int(wpid)
@@ -1788,13 +1789,14 @@ def main(argv):
if not argv:
pass
elif argv[0] in ('-h', '--help'):
- print ("""Usage: abe.py [-h] [--config=FILE] [--CONFIGVAR=VALUE]...
+ print ("""Usage: python -m Abe.abe [-h] [--config=FILE] [--CONFIGVAR=VALUE]...
A Bitcoin block chain browser.
- --help Show this help message and exit.
- --version Show the program version and exit.
- --config FILE Read options from FILE.
+ --help Show this help message and exit.
+ --version Show the program version and exit.
+ --print-htdocs-directory Show the static content directory name and exit.
+ --config FILE Read options from FILE.
All configuration variables may be given as command arguments.
See abe.conf for commented examples.""")
@@ -1803,10 +1805,13 @@ def main(argv):
print ABE_APPNAME, ABE_VERSION
print "Schema version", DataStore.SCHEMA_VERSION
return 0
+ elif argv[0] == '--print-htdocs-directory':
+ print find_htdocs()
+ return 0
else:
sys.stderr.write(
"Error: unknown option `%s'\n"
- "See `abe.py --help' for more information.\n"
+ "See `python -m Abe.abe --help' for more information.\n"
% (argv[0],))
return 1
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -869,5 +869,5 @@ def upgrade_schema(store):
print "Upgrade complete."
if __name__ == '__main__':
- print "Run ./abe.py with --upgrade added to the usual arguments."
+ print "Run Abe with --upgrade added to the usual arguments."
sys.exit(2)
View
@@ -1,3 +1,2 @@
include abe.conf
include README-*.txt
-recursive-include htdocs *
View
@@ -1,26 +1,47 @@
Apache 2 FastCGI setup on Debian/Ubuntu
=======================================
+This document describes how to install and run Abe as a FastCGI
+process under Apache 2 on a Debian GNU/Linux or Ubuntu system.
+Advantages of FastCGI over the built-in HTTP server include:
+
+ * lets browsers cache static content for better performance;
+ * can integrate with an existing website, no :2750 in URLs.
+
+These instructions assume root privileges. To begin a privileged
+session in a terminal window, issue "sudo -i" (Ubuntu) or "su -"
+(Debian).
+
Install required packages:
apt-get install apache2 libapache2-mod-fcgid python-flup
apt-get install python-crypto
+Change directory to the Abe distribution and install Abe:
+
+ cd bitcoin-abe
+ python setup.py install
+
Replace YOUR.ABE.DOMAIN below with a domain that resolves to this
host. The site will be http://YOUR.ABE.DOMAIN/. To embed Abe in an
existing site (e.g., http://YOUR.DOMAIN/abe/) simply prepend a path
(e.g., "/abe") in the Alias directives and place them in your existing
sites-available file instead of a new VirtualHost.
-Replace ABE/DIRECTORY/htdocs with the directory containing abe.css;
-the Apache process must have permission to read it.
-Replace "/usr/lib/cgi-bin" with another directory if you prefer;
+
+Replace HTDOCS/DIRECTORY below with the directory containing abe.css;
+the Apache process must have permission to read it. The following
+command displays the correct value:
+
+ python -m Abe.abe --print-htdocs-directory
+
+Optionally, replace "/usr/lib/cgi-bin" below with another directory;
Apache must have the directory configured with Options +ExecCGI.
Create file /etc/apache2/sites-available/abe with these contents:
<VirtualHost *>
ServerName YOUR.ABE.DOMAIN
- Alias /static/ ABE/DIRECTORY/htdocs/
+ Alias /static/ HTDOCS/DIRECTORY
Alias / /usr/lib/cgi-bin/abe.fcgi/
# Raise this if you get server errors mentioning "mod_fcgid:
@@ -60,15 +81,17 @@ Put configuration such as database connection parameters in
abe.conf in the Abe distribution for file format. IMPORTANT: Make
sure the configuration does NOT contain a "host" or "port" option.
-Replace ABE/DIRECTORY with the directory containing abe.py and create
-file /home/USER/cgi-bin/abe with these contents:
+Create file /home/USER/cgi-bin/abe with these contents:
#! /bin/sh
- PYTHONUNBUFFERED=1 exec ABE/DIRECTORY/abe.py \
+ PYTHONUNBUFFERED=1 exec python -m Abe.abe \
--config /home/USER/abe.conf --static-path static/ --watch-pid="$1"
Make the file executable:
chmod +x /home/USER/cgi-bin/abe
-Abe should be reachable at http://YOUR.ABE.DOMAIN/.
+Abe should be reachable at http://YOUR.ABE.DOMAIN/. Exit the
+privileged session:
+
+ exit
View
@@ -3,8 +3,8 @@ Abe setup for MySQL.
Run the Bitcoin client to ensure that your copy of the block chain is
up to date.
-Install Python 2.7 and its Crypto modules. The Debian/Ubuntu packages
-are python2.7 and python-crypto.
+Install Python 2.7 and pycrypto. The Debian/Ubuntu packages are
+python2.7 and python-crypto.
Install MySQL 5.x server and MySQL-Python. On Debian/Ubuntu:
mysql-server-5.1 and python-mysqldb.
@@ -32,7 +32,7 @@ Create file abe-my.conf with the following contents, replacing
Run Abe as:
- python abe.py --config abe-my.conf
+ python -m Abe.abe --config abe-my.conf
Look for output such as:
View
@@ -27,7 +27,7 @@ Create file abe-pg.conf with contents:
Run Abe as:
- python abe.py --config abe-pg.conf
+ python -m Abe.abe --config abe-pg.conf
Look for output such as:
View
@@ -41,14 +41,16 @@ available to users of the server. You may do this by forking the
Github project (if you received this code from Github.com), keeping
your modifications in the new project, and linking to it in the page
template. Or you may wish to satisfy the requirement by simply
-passing "--auto-agpl" to "abe.py". This option makes all files in the
-directory containing abe.py and its subdirectories available to
-clients. See the comments in abe.conf for more information.
+passing "--auto-agpl" to "python -m Abe.abe". This option makes all
+files in the directory containing abe.py and its subdirectories
+available to clients. See the comments in abe.conf for more
+information.
Database
--------
-For usage, run "abe.py --help" and see the comments in abe.conf.
+For usage, run "python -m Abe.abe --help" and see the comments in
+abe.conf.
You will have to specify a database driver and connection arguments
(dbtype and connect-args in abe.conf). The dbtype is the name of a
View
@@ -1,3 +1,5 @@
+* Defunct abe.fcgi processes not letting abe.py exit.
+
* Bitcoin 140176 failed to catch up: str(exception) == "1". Should
probably limit the kinds of exceptions that catch_up converts to
warnings.
@@ -82,7 +84,9 @@
* Present Namecoin name operations as an optional add-on.
-* ixcoin, i0coin, StableCoin, ???
+* Extract info from MultiCoin config files.
+
+* Support new currencies.
* Import transactions from the pool.
View
@@ -7,8 +7,8 @@
# read as underscore, so "connect_args" and "connect-args" are
# synonymous. Later values override earlier ones (unless using "+=").
-# All values may be passed as abe.py command-line arguments by
-# preceding NAME with "--". Example: "--upgrade --dbtype=sqlite3
+# All values may be passed as command-line arguments by preceding NAME
+# with "--". Example: "python -m Abe.abe --upgrade --dbtype=sqlite3
# --connect-args=abe.sqlite --port 2750".
# dbtype and connect-args are required.
@@ -78,10 +78,10 @@
# SELECT configvar_value FROM configvar
# WHERE configvar_name = 'schema_version'
#
-# "./abe.py -v" shows the schema version that the software requires.
-# Sometimes you can upgrade a live database by running "./abe.py
-# --config YOUR_ABE_CONFIG --no-serve --upgrade" but this often
-# results in server errors.
+# "python -m Abe.abe -v" shows the schema version that the software
+# requires. Sometimes you can upgrade a live database by running
+# "python -m Abe.abe --config YOUR_ABE_CONFIG --no-serve --upgrade"
+# but this often results in server errors.
# Include another configuration file, relative to this one's directory.
#config ../secret/abe.conf
View
@@ -5,8 +5,9 @@
setup(
name = "Abe",
version = __version__,
+ requires = ['Crypto.Hash'],
packages = ["Abe"],
- py_modules = ["abe"],
+ package_data = {'Abe': ['htdocs/*']},
author = "John Tobey",
author_email = "John.Tobey@gmail.com",
url = "https://github.com/jtobey/bitcoin-abe",

0 comments on commit 761e14c

Please sign in to comment.