Last active
August 29, 2015 14:19
-
-
Save skamithi/0866c3622a2fa37f2a54 to your computer and use it in GitHub Desktop.
setup.py that builds data files in correct location using stdeb , if installed in venv it puts it in sys.prefix + <path>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pylint: disable=c0111 | |
from netshowlib import get_version | |
import os | |
import sys | |
try: | |
from setuptools import setup, find_packages | |
except ImportError: | |
import ez_setup | |
ez_setup.use_setuptools() | |
from setuptools import setup, find_packages | |
from distutils.command.install_data import install_data | |
import re | |
class PostInstall(install_data): | |
def run(self): | |
# Call parent | |
install_data.run(self) | |
# Execute commands | |
print sys.__dict__ | |
print os.environ | |
def var_dir(): | |
_var_dir = '/var' | |
# this first if ensure stdeb installs system file in the right place | |
if not re.search('deb_dist', os.environ.get('PWD')): | |
# these 2 checks are to see if build is happen on virtualenv or pyvenv | |
if os.environ.get('VIRTUAL_ENV') or hasattr(sys, 'real_prefix'): | |
_var_dir = os.path.join(sys.prefix, 'var') | |
return os.path.join(_var_dir, 'lib', 'netshow', 'discovery') | |
setup( | |
name='linux-netshow-lib', | |
version=get_version(), | |
url="http://github.com/CumulusNetworks/netshow-lib", | |
description="Python Library to Abstract Linux Networking Data", | |
author='Cumulus Networks', | |
author_email='[email protected]', | |
packages=find_packages(), | |
zip_safe=False, | |
license='GPLv2', | |
# namespace_packages=['netshowlib'], | |
package_data={'data': ['*']}, | |
classifiers=[ | |
'Topic :: System :: Networking', | |
'Intended Audience :: Developers', | |
'Intended Audience :: System Administrators', | |
'Operating System :: POSIX :: Linux' | |
], | |
data_files=[(var_dir(), ['data/discovery/linux'])], | |
cmdclass={'install_data': PostInstall} | |
) | |
(mypython2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment