Commits

Anonymous committed 2243d5f

move code from setup.py into its own module to make setup.py more readable

  • Participants
  • Parent commits 6e71f83

Comments (0)

Files changed (4)

 
 # General information about the project.
 project = release_info['name']
-copyright = release_info['copyright']
+copyright = release_info['_copyright']
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the

pymta/lib/distribution_helpers.py

+# -*- coding: UTF-8 -*-
+# 
+# The MIT License
+# 
+# Copyright (c) 2010 Felix Schwarz <felix.schwarz@oss.schwarz.eu>
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+
+__all__ = ['commands_for_babel_support']
+
+def is_babel_available():
+    try:
+        import babel
+    except ImportError:
+        return False
+    return True
+
+def commands_for_babel_support():
+    if not is_babel_available():
+        return {}
+    from babel.messages import frontend as babel
+    
+    extra_commands = {
+        'extract_messages': babel.extract_messages,
+        'init_catalog':     babel.init_catalog,
+        'update_catalog':   babel.update_catalog,
+        'compile_catalog':  babel.compile_catalog,
+    }
+    return extra_commands
+
+def information_from_file(filename):
+    data = dict()
+    execfile(filename, data)
+    is_exportable_symbol = lambda key: not key.startswith('_')
+    externally_defined_parameters = dict([(key, value) for key, value in data.items() if is_exportable_symbol(key)])
+    return externally_defined_parameters
+
+
    server
 '''
 author = 'Felix Schwarz'
-email = 'felix.schwarz@oss.schwarz.eu'
+author_email = 'felix.schwarz@oss.schwarz.eu'
 url = 'http://www.schwarz.eu/opensource/projects/pymta'
 download_url = 'http://www.schwarz.eu/opensource/projects/%(name)s/download/%(version)s/%(name)s-%(version)s.tar.gz' % dict(name=name, version=version)
-copyright = u'2008-2010 Felix Schwarz'
+# prefix it with '_' so the symbol is not passed to setuptools.setup()
+_copyright = u'2008-2010 Felix Schwarz'
 license='MIT'
 
 
 import setuptools
 
+from pymta.lib.distribution_helpers import information_from_file
+
 if __name__ == '__main__':
-    execfile(os.path.join('pymta', 'release.py'))
-
+    release_filename = os.path.join('pymta', 'release.py')
+    externally_defined_parameters= information_from_file(release_filename)
+    
     setuptools.setup(
-          name=name,
-          version=version,
-            
-          description=description,
-          long_description=long_description,
-          author=author,
-          author_email=email,
-          url=url,
-          download_url=download_url,
-          license=license,
-          
           install_requires=['pycerberus >= 0.3.1'],
           
           # simple_super is not zip_safe
               'Topic :: Software Development :: Libraries :: Python Modules',
             ],
           test_suite = 'nose.collector',
+          **externally_defined_parameters
     )