<commit_before>import os
import os.path
import pprint

from setuptools import setup
from setuptools import find_packages


# here = os.path.abspath(os.path.dirname(__file__))
# README = open(os.path.join(here, 'README.txt')).read()

requires = [
    'amqplib==1.0.2',
    'anyjson==0.3.1',
    'argparse==1.2.1',
    'Paste==1.7.5.1',
    'eventlet==0.9.17',
    'greenlet==0.4.0',
    'kombu==2.1.8',
    'nose==1.1.2',
    'nose2==0.4.1',
    'netaddr==0.7.10',
    'pycrypto==2.6',
    'PyYAML==3.10',
    'SQLAlchemy==0.7.8',
    'simplejson==2.6.2',
    'web.py==0.37',
    'wsgilog==0.3',
    'wsgiref==0.1.2',
    # 'cobbler',
]

major_version = '0.1'
minor_version = '0'
name = 'Nailgun'

version = "%s.%s" % (major_version, minor_version)


def recursive_data_files(spec_data_files):
    result = []
    for dstdir, srcdir in spec_data_files:
        for topdir, dirs, files in os.walk(srcdir):
            for f in files:
                result.append((os.path.join(dstdir, topdir),
                               [os.path.join(topdir, f)]))
    return result


if __name__ == "__main__":
    setup(name=name,
          version=version,
          description='Nailgun package',
          long_description="""Nailgun package""",
          classifiers=[
              "Development Status :: 4 - Beta",
              "Programming Language :: Python",
              "Topic :: Internet :: WWW/HTTP",
              "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
          ],
          author='Mirantis Inc.',
          author_email='<EMAIL>',
          url='http://mirantis.com',
          keywords='web wsgi nailgun mirantis',
          packages=find_packages(),
          zip_safe=False,
          install_requires=requires,
          include_package_data=True,
          scripts=['manage.py'],
          entry_points={
              'console_scripts': [
                  'nailgun_syncdb = nailgun.db:syncdb',
                  'nailgun_fixtures = \
                      nailgun.fixtures.fixman:upload_fixtures',
                  'nailgund = nailgun.wsgi:appstart',
              ],
          },
          data_files=recursive_data_files([('usr/share/nailgun', 'static')])<commit_msg>Added update_commit_sha method into nailgun/setup.py<commit_after>import os
import os.path
import pprint

from setuptools import setup
from setuptools import find_packages


# here = os.path.abspath(os.path.dirname(__file__))
# README = open(os.path.join(here, 'README.txt')).read()

requires = [
    'amqplib==1.0.2',
    'anyjson==0.3.1',
    'argparse==1.2.1',
    'Paste==1.7.5.1',
    'eventlet==0.9.17',
    'greenlet==0.4.0',
    'kombu==2.1.8',
    'nose==1.1.2',
    'nose2==0.4.1',
    'netaddr==0.7.10',
    'pycrypto==2.6',
    'PyYAML==3.10',
    'SQLAlchemy==0.7.8',
    'simplejson==2.6.2',
    'web.py==0.37',
    'wsgilog==0.3',
    'wsgiref==0.1.2',
    # 'cobbler',
]

major_version = '0.1'
minor_version = '0'
name = 'Nailgun'

version = "%s.%s" % (major_version, minor_version)


def update_commit_sha():
  """
  Sets COMMIT_SHA in nailgun/settings.yaml into
  sha sum of last commit
  """
  gitproc = subprocess.Popen(shlex.split("git rev-parse --verify HEAD"),
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  sha, err = gitproc.communicate()
  shaline = "COMMIT_SHA: \"%s\"\n" % sha.strip()

  with open("nailgun/settings.yaml", "r+") as f:
    pos = 0
    while True:
      line = f.readline()
      if len(line) == 0:
        break
      # we don't use yaml loading and dumping
      # in order to avoid file structure changing
      if re.search(ur'^COMMIT_SHA:.*', line):
        tail = f.read()
        f.seek(pos)
        f.write(shaline)
        f.seek(pos + len(shaline))
        f.write(tail)
        f.seek(pos + len(shaline))
      pos = f.tell()


def recursive_data_files(spec_data_files):
    result = []
    for dstdir, srcdir in spec_data_files:
        for topdir, dirs, files in os.walk(srcdir):
            for f in files:
                result.append((os.path.join(dstdir, topdir),
                               [os.path.join(topdir, f)]))
    return result


if __name__ == "__main__":
    update_commit_sha()

    setup(name=name,
          version=version,
          description='Nailgun package',
          long_description="""Nailgun package""",
          classifiers=[
              "Development Status :: 4 - Beta",
              "Programming Language :: Python",
              "Topic :: Internet :: WWW/HTTP",
              "Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
          ],
          author='Mirantis Inc.',
          author_email='<EMAIL>',
          url='http://mirantis.com',
          keywords='web wsgi nailgun mirantis',
          packages=find_packages(),
          zip_safe=False,
          install_requires=requires,
          include_package_data=True,
          scripts=['manage.py'],
          entry_points={
              'console_scripts': [
                  'nailgun_syncdb = nailgun.db:syncdb',
                  'nailgun_fixtures = \
                      nailgun.fixtures.fixman:upload_fixtures',
                  'nailgund = nailgun.wsgi:appstart',
              ],
          },
          data_files=recursive_data_files([('usr/share/nailgun', 'static')])
{'fraction_non_alphanumeric': 0.1542998477929985, 'fraction_numerical': 0.02207001522070015, 'mean_word_length': 2.1516786570743407, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7510082', 'n_tokens_mistral': 1853, 'n_tokens_neox': 1783, 'n_words': 313}