<commit_before>#!/usr/bin/python
# BridgeDB by <NAME>.
# Copyright (c) 2007-2009, The Tor Project, Inc.
# See LICENSE for licensing information

import distutils
import subprocess
from distutils.command.install_data import install_data as _install_data
from babel.messages import frontend as babel
import os
import sys

from setuptools import setup, Command, find_packages

class installData(_install_data):
    def run(self):
        self.data_files = []
        for lang in os.listdir('build/locale/'):
            if lang.endswith('templates'):
                continue
            lang_dir = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
            lang_file = os.path.join('build', 'locale', lang, 'LC_MESSAGES', 
                                     'bridgedb.mo')
            self.data_files.append( (lang_dir, [lang_file]) )
        _install_data.run(self)

class runTests(Command):
    # Based on setup.py from mixminion, which is based on setup.py
    # from Zooko's pyutil package, which is in turn based on
    # http://mail.python.org/pipermail/distutils-sig/2002-January/002714.html
    description = "Run unit tests"
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        build = self.get_finalized_command('build')
        self.build_purelib = build.build_purelib
        self.build_platlib = build.build_platlib

    def run(self):
        self.run_command('build')
        old_path = sys.path[:]
        sys.path[0:0] = [ self.build_purelib, self.build_platlib ]
        try:
            testmod = __import__("bridgedb.Tests", globals(), "", [])
            testmod.Tests.main()
        finally:
            sys.path = old_path

setup(name='BridgeDB',
      version='0.1',
      description='Bridge disbursal tool for use with Tor anonymity network',
      author='<NAME>',
      author_email='<EMAIL> tor<EMAIL>',
      url='https://www.torproject.org',
      package_dir= {'' : 'lib'},
      packages=find_packages('lib'),
      py_modules=['TorBridgeDB'],
      cmdclass={'test' : runTests,
                'compile_catalog': babel.compile_catalog,
                'extract_messages': babel.extract_messages,
                'init_catalog': babel.init_catalog,
                'update_catalog': babel.update_catalog,
                'install_data': installData},
      include_package_data=True,
      package_data={'bridgedb': ['i18n/*/LC_MESSAGES/*.mo',
                                 'templates/*.html',
                                 'templates/assets/*']},
      message_extractors = {'lib/bridgedb': [
              ('**.py', 'python', None),
              ('templates/**.html', 'mako', None),
              ('public/**', 'ignore', None)]},  
)<commit_msg>Fix circular import with setup.py dependencies<commit_after>#!/usr/bin/python
# BridgeDB by <NAME>.
# Copyright (c) 2007-2009, The Tor Project, Inc.
# See LICENSE for licensing information

import distutils
import subprocess
from distutils.command.install_data import install_data as _install_data
import os
import sys
from setuptools import setup, Command, find_packages

# Fix circular dependency with setup.py install
try:
    from babel.messages.frontend import compile_catalog, extract_messages
    from babel.messages.frontend import init_catalog, update_catalog
except ImportError:
    compile_catalog = extract_messages = init_catalog = update_catalog = None

class installData(_install_data):
    def run(self):
        self.data_files = []
        for lang in os.listdir('build/locale/'):
            if lang.endswith('templates'):
                continue
            lang_dir = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
            lang_file = os.path.join('build', 'locale', lang, 'LC_MESSAGES', 
                                     'bridgedb.mo')
            self.data_files.append( (lang_dir, [lang_file]) )
        _install_data.run(self)

class runTests(Command):
    # Based on setup.py from mixminion, which is based on setup.py
    # from Zooko's pyutil package, which is in turn based on
    # http://mail.python.org/pipermail/distutils-sig/2002-January/002714.html
    description = "Run unit tests"
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        build = self.get_finalized_command('build')
        self.build_purelib = build.build_purelib
        self.build_platlib = build.build_platlib

    def run(self):
        self.run_command('build')
        old_path = sys.path[:]
        sys.path[0:0] = [ self.build_purelib, self.build_platlib ]
        try:
            testmod = __import__("bridgedb.Tests", globals(), "", [])
            testmod.Tests.main()
        finally:
            sys.path = old_path

setup(name='BridgeDB',
      version='0.1',
      description='Bridge disbursal tool for use with Tor anonymity network',
      author='<NAME>',
      author_email='<EMAIL>',
      url='https://www.torproject.org',
      package_dir= {'' : 'lib'},
      packages=find_packages('lib'),
      py_modules=['TorBridgeDB'],
      cmdclass={'test' : runTests,
                'compile_catalog': compile_catalog,
                'extract_messages': extract_messages,
                'init_catalog': init_catalog,
                'update_catalog': update_catalog,
                'install_data': installData},
      include_package_data=True,
      package_data={'bridgedb': ['i18n/*/LC_MESSAGES/*.mo',
                                 'templates/*.html',
                                 'templates/assets/*']},
      message_extractors = {'lib/bridgedb': [
              ('**.py', 'python', None),
              ('templates/**.html', 'mako', None),
              ('public/**', 'ignore', None)]},  
)
{'fraction_non_alphanumeric': 0.12419551226300227, 'fraction_numerical': 0.008349278135327882, 'mean_word_length': 2.4534534534534536, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7668632', 'n_tokens_mistral': 1736, 'n_tokens_neox': 1662, 'n_words': 364}