Skip to content

Instantly share code, notes, and snippets.

@david-batranu
Created May 22, 2015 10:22
Show Gist options
  • Save david-batranu/0ce2b637da1bd0e6ca74 to your computer and use it in GitHub Desktop.
Save david-batranu/0ce2b637da1bd0e6ca74 to your computer and use it in GitHub Desktop.
python package post-actions
from subprocess import call
from setuptools import setup, find_packages
from setuptools.command.install import install
from setuptools.command.develop import develop
from setuptools.command.sdist import sdist
import os
version = '1.0'
def common_do(command_subclass):
orig_run = command_subclass.run
def modified_run(self):
# call(['npm', 'install', 'bootstrap'])
call(['touch', 'version.txt'])
with open('version.txt', 'w') as f:
f.write('merge')
orig_run(self)
command_subclass.run = modified_run
return command_subclass
@common_do
class DoDevelop(develop):
""" Develop
"""
@common_do
class DoInstall(install):
""" Install
"""
@common_do
class DoSDist(sdist):
""" sdist
"""
setup(name='my.package',
version=version,
description="",
long_description=open("README.txt").read() + "\n" +
open(os.path.join("docs", "HISTORY.txt")).read(),
# Get more strings from
# http://pypi.python.org/pypi?:action=list_classifiers
classifiers=[
"Programming Language :: Python",
],
keywords='my package',
author='Me',
author_email='me@me',
url='http://my.package.repo',
license='GPL',
packages=find_packages(exclude=['ez_setup']),
namespace_packages=['my'],
include_package_data=True,
zip_safe=False,
install_requires=[
'setuptools',
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
setup_requires=["PasteScript"],
paster_plugins=["ZopeSkel"],
cmdclass={
'install': DoInstall,
'develop': DoDevelop,
'sdist': DoSDist
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment