Skip to content
Browse files

More build work

- separate build dir for setup_skytools, to avoid conflict with pkgloader
- pass configure switches to setup.py
  • Loading branch information...
1 parent 774d2c4 commit e2e88e0ab46e2944d62785fc2b94af7f9fdff6c6 @markokr markokr committed Sep 6, 2011
Showing with 64 additions and 16 deletions.
  1. +1 −4 Makefile
  2. +1 −0 config.mak.in
  3. +17 −2 configure.ac
  4. +45 −10 setup_skytools.py
View
5 Makefile
@@ -29,7 +29,7 @@ python-all: config.mak
clean: sub-clean
$(PYTHON) setup_skytools.py clean
- rm -rf build
+ rm -rf build build.sk3
find python -name '*.py[oc]' -print | xargs rm -f
rm -f python/skytools/installer_config.py source.list
rm -rf tests/londiste/sys
@@ -48,10 +48,7 @@ modules-install: config.mak
SITEDIR = site-packages
python-install: config.mak sub-all
- mkdir -p $(DESTDIR)/$(bindir)
- rm -rf build
$(PYTHON) setup_pkgloader.py install --prefix=$(prefix) --root=$(DESTDIR)/ $(BROKEN_PYTHON)
- find build -name 'pkgloader*' | xargs rm
$(PYTHON) setup_skytools.py install --prefix=$(prefix) --root=$(DESTDIR)/ $(BROKEN_PYTHON)
$(MAKE) -C doc DESTDIR=$(DESTDIR) install
View
1 config.mak.in
@@ -37,4 +37,5 @@ INSTALL = @INSTALL@
BININSTALL = @BININSTALL@
SKYLOG = @SKYLOG@
+SK3_SUBDIR = @SK3_SUBDIR@
View
19 configure.ac
@@ -85,10 +85,10 @@ changequote([, ])dnl
esac
fi
-dnl Find PostgreSQL pg_config
+dnl Decide default skylog setting
SKYLOG=0
AC_MSG_CHECKING(for skylog default setting)
-AC_ARG_WITH(skylog, [ --with-skylog=0|1 set default value for skylog (default: 0)],
+AC_ARG_WITH(skylog, [ --with-skylog set default value for skylog (default: off)],
[ if test "$withval" = "yes"; then
SKYLOG="1"
elif test "$withval" = "no"; then
@@ -100,6 +100,21 @@ AC_ARG_WITH(skylog, [ --with-skylog=0|1 set default value for skylog (default:
AC_MSG_RESULT([$SKYLOG])
AC_SUBST(SKYLOG)
+dnl Decide module subdir
+SK3_SUBDIR=0
+AC_MSG_CHECKING([whether to install modules in /skytools-3.0/ subdir])
+AC_ARG_WITH(sk3-subdir, AC_HELP_STRING([--with-sk3-subdir], [put modules into /skytools-3.0/ subdir]),
+[ if test "$withval" = "yes"; then
+ SK3_SUBDIR="1"
+ elif test "$withval" = "no"; then
+ SK3_SUBDIR="0"
+ else
+ SK3_SUBDIR="$withval"
+ fi
+ AC_MSG_RESULT([$SK3_SUBDIR])])
+AC_MSG_RESULT([$SK3_SUBDIR])
+AC_SUBST(SK3_SUBDIR)
+
dnl check for xmlto, but only if asciidoc is found
if test "$ASCIIDOC" != "no"; then
AC_CHECK_PROGS(XMLTO, [$XMLTO xmlto])
View
55 setup_skytools.py
@@ -1,11 +1,11 @@
-#! /usr/bin/env python
+#e! /usr/bin/env python
-# this script installs only Python modules,
-# scripts and sql files are installed from makefile
+# this script installs Python modules, scripts and sql files
import sys, os.path, re
from distutils.core import setup
from distutils.extension import Extension
+from distutils.command.build import build
from distutils.command.install import install
from subprocess import Popen
@@ -14,24 +14,45 @@
m = re.search("AC_INIT[(][^,]*,\s+([^)]*)[)]", buf)
ac_ver = m.group(1)
+# scripts that we add suffix
sfx_scripts = [
'python/londiste.py',
'python/walmgr.py',
'scripts/scriptmgr.py',
'scripts/queue_splitter.py',
'scripts/queue_mover.py',
]
+# those do not need suffix (no conflict with 2.1)
nosfx_scripts = [
'python/qadmin.py',
]
+# sql files we want to access from python
sql_files = [
'sql/pgq/pgq.sql',
'sql/londiste/londiste.sql',
'sql/pgq_ext/pgq_ext.sql',
'sql/pgq_node/pgq_node.sql',
#'sql/txid/txid.sql',
]
+
+def getvar(name, default):
+ try:
+ cf = open('config.mak').read()
+ m = re.search(r'^%s\s*=\s*(.*)' % name, cf, re.M)
+ if m:
+ return m.group(1).strip()
+ except IOError:
+ pass
+ return default
+
+# load defaults from config.mak
+DEF_SUFFIX = getvar('SUFFIX', '')
+DEF_SKYLOG = getvar('SKYLOG', '0') != '0'
+DEF_SK3_SUBDIR = getvar('SK3_SUBDIR', '0') != '0'
+
+
+# create sql files if they dont exist
for fn in sql_files:
if not os.path.isfile(fn):
f = open(fn, 'w')
@@ -42,6 +63,7 @@
if p.returncode != 0:
raise Exception('catsql failed')
+# remove .py, add suffix
def fixscript(fn, dstdir, sfx):
fn = os.path.basename(fn)
fn2 = fn.replace('.py', sfx)
@@ -50,31 +72,44 @@ def fixscript(fn, dstdir, sfx):
dfn2 = os.path.join(dstdir, fn2)
os.rename(dfn, dfn2)
+class sk3_build(build):
+ def initialize_options(self):
+ build.initialize_options(self)
+ self.build_base = 'build.sk3'
+
+# wrap generic install command
class sk3_install(install):
user_options = install.user_options + [
('script-suffix=', None, 'add suffix to scripts'),
- ('sk3-subdir', None, 'install modules into "skytools-3.0" subdir')
+ ('sk3-subdir', None, 'install modules into "skytools-3.0" subdir'),
+ ('skylog', None, 'use "skylog" logging by default'),
]
- boolean_options = ['sk3-subdir']
- sk3_subdir = ''
- script_suffix = ''
+ boolean_options = ['sk3-subdir', 'skylog']
+ sk3_subdir = DEF_SK3_SUBDIR
+ script_suffix = DEF_SUFFIX
+ skylog = DEF_SKYLOG
def run(self):
+
+ # create installer_config.py with final paths
fn = 'python/skytools/installer_config.py'
cf = open(fn + '.in', 'r').read()
- cf = cf.replace('@SQLDIR@', self.prefix + 'share/skytools3')
+ cf = cf.replace('@SQLDIR@', os.path.join(self.prefix, 'share/skytools3'))
cf = cf.replace('@PACKAGE_VERSION@', ac_ver)
- cf = cf.replace('@SKYLOG@', '1')
+ cf = cf.replace('@SKYLOG@', self.skylog and '1' or '0')
open(fn, 'w').write(cf)
+ # move python modules
if self.sk3_subdir:
subdir = 'skytools-3.0'
self.install_lib = os.path.join(self.install_lib, subdir)
self.install_purelib = os.path.join(self.install_purelib, subdir)
self.install_platlib = os.path.join(self.install_platlib, subdir)
+ # generic install
install.run(self)
+ # fix scripts
for sfn in sfx_scripts:
fixscript(sfn, self.install_scripts, self.script_suffix)
for sfn in nosfx_scripts:
@@ -98,6 +133,6 @@ def run(self):
('share/skytools3', sql_files)],
ext_modules=[Extension("skytools._cquoting", ['python/modules/cquoting.c'])],
scripts = sfx_scripts + nosfx_scripts,
- cmdclass = { 'install': sk3_install },
+ cmdclass = { 'build': sk3_build, 'install': sk3_install },
)

0 comments on commit e2e88e0

Please sign in to comment.
Something went wrong with that request. Please try again.