Skip to content

Commit

Permalink
Merge pull request pycassa#127 from caruccio/bb29fe65d1421cfff613dbbf…
Browse files Browse the repository at this point in the history
…a8ffa0fbe2e01f89

RPM Install script to build under CentOS
  • Loading branch information
thobbs committed Mar 24, 2012
2 parents 605c0b5 + 2612990 commit 5a7a27b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
17 changes: 17 additions & 0 deletions rpm-install-script.sh
@@ -0,0 +1,17 @@
python setup.py install --single-version-externally-managed --root="$RPM_BUILD_ROOT" --record=INSTALLED_FILES

# Add .pyo files generated on CentOS 5.x
# This is a workaround until someone comes with a better fix, like avoiding
# /usr/lib/rpm/brp-python-bytecompile to run or convincing people that CentOS is pure evil.
rm -f INSTALLED_PYO_FILES
(cd "$RPM_BUILD_ROOT"
find -type f -name '*.pyc' | cut -b2-|sed -e 's/pyc$/pyo/' | while read pyo
do
if [ -e "$pyo" ]; then
echo "$pyo" >> INSTALLED_PYO_FILES
fi
done)

if [ -e INSTALLED_PYO_FILES ]; then
sort -u INSTALLED_PYO_FILES >> INSTALLED_FILES
fi
30 changes: 29 additions & 1 deletion setup.py
Expand Up @@ -35,6 +35,34 @@
5. A method to map an existing class to a Cassandra column family
"""

class rpm(Command):

description = "builds a RPM package"

user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
if has_subprocess:
status = subprocess.call(["python", "setup.py", "bdist_rpm", "--install-script", "rpm-install-script.sh"])

if status:
raise RuntimeError("RPM build failed")

print ""
print "RPM built"
else:
print """
`setup.py rpm` is not supported for this version of Python.
Please ask in the user forums for help.
"""

class doc(Command):

description = "generate or test documentation"
Expand Down Expand Up @@ -101,7 +129,7 @@ def run(self):
install_requires = ['thrift'],
py_modules=['ez_setup'],
scripts=['pycassaShell'],
cmdclass={"doc": doc},
cmdclass={"doc": doc, "rpm": rpm},
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand Down

0 comments on commit 5a7a27b

Please sign in to comment.