Skip to content

Commit

Permalink
Complete Nagcat's new setup.py script.
Browse files Browse the repository at this point in the history
This is now capable of installing nagcat and unit tests even pass.
  • Loading branch information
marineam committed Aug 25, 2010
1 parent 354008b commit ac702db
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
@@ -1,4 +1,4 @@
PREFIX = /ita/installs/polthon
PREFIX = /usr
PYTHON = $(PREFIX)/bin/python
CY_SRC = python/nagcat/_object_parser_c.pyx
CY_TMP = $(CY_SRC:.pyx=.c)
Expand Down
52 changes: 47 additions & 5 deletions setup.py 100644 → 100755
@@ -1,18 +1,60 @@
#!/usr/bin/env python

import os
import stat
from glob import glob
from distutils import log
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from distutils.command.build_py import build_py as du_build_py
from twisted.python.dist import getPackages

setup(
# distutils doesn't provide a way to make some package data executable
# but nagcat requires a test script for unit testing, so hack time.
package_scripts = ["python/nagcat/unittests/queries/simple_subprocess"]

class build_py(du_build_py):

def copy_file(self, infile, outfile, **kwargs):
du_build_py.copy_file(self, infile, outfile, **kwargs)

# Ripped out of install_scripts, might as well be consistent.
if os.name == 'posix' and infile in package_scripts:
if self.dry_run:
log.info("changing mode of %s", outfile)
else:
mode = ((os.stat(outfile)[stat.ST_MODE]) | 0555) & 07777
log.info("changing mode of %s to %o", outfile, mode)
os.chmod(outfile, mode)

setup_args = dict(
name = "nagcat",
author = "Michael Marineau",
author_email = "mmarineau@itasoftware.com",
url = "http://code.google.com/p/nagcat/",
license = "Apache 2.0",
packages = getPackages("python/nagcat") +
getPackages("python/snapy") +
getPackages("python/twirrdy"),
package_data = {'nagcat': ["plugins/dropin.cache",
"unittests/trend_data*",
"unittests/queries/oracle_package.sql",
"unittests/queries/simple_subprocess"],
'snapy': ["netsnmp/unittests/snmpd.conf"]},
package_dir = {'': "python"},
ext_modules = [Extension("nagcat._object_parser_c",
["python/nagcat/_object_parser_c.pyx"])],
cmdclass = {'build_ext': build_ext},
scripts = glob("bin/*"),
data_files = [('share/doc/nagcat', ["README", "LICENSE"]),
('share/doc/nagcat/docs', glob("docs/*.*"))],
cmdclass = {'build_py': build_py},
)

# Nagcat works without Cython so make it optional
try:
from Cython.Distutils import build_ext
setup_args['ext_modules'] = [Extension("nagcat._object_parser_c",
["python/nagcat/_object_parser_c.pyx"])]
setup_args['cmdclass']['build_ext'] = build_ext
except ImportError:
pass

setup(**setup_args)

0 comments on commit ac702db

Please sign in to comment.