Commits

bob  committed c052828

refactor for bdist_mpkg 0.4.2

  • Participants
  • Parent commits 20a5b3b

Comments (0)

Files changed (2)

File bdist_mpkg_support.py

+# only enable bdist_mpkg if it's installed already
+import pkg_resources
 try:
-    import setuptools
-    import pkg_resources
-    try:
-        pkg_resources.require('bdist_mpkg')
-    except pkg_resources.DistributionNotFound:
-        raise ImportError
-except ImportError:
-    import bdist_mpkg
-    from distutils.command.bdist_mpkg import bdist_mpkg as _bdist_mpkg
-else:
-    _bdist_mpkg = setuptools.Distribution().get_command_class('bdist_mpkg')
+    pkg_resources.require('bdist_mpkg>=0.4.2')
+except pkg_resources.DistributionNotFound:
+    raise ImportError
 
 FRAMEWORKS = ['SDL', 'SDL_ttf', 'SDL_image', 'SDL_mixer', 'smpeg']
 
-class bdist_mpkg(_bdist_mpkg):
-    def initialize_options(self):
-        _bdist_mpkg.initialize_options(self)
-        self.scheme_descriptions['examples'] = u'(Optional) pygame example code'
-        self.scheme_map['examples'] = '/Developer/Python/pygame/Examples'
-        self.scheme_copy['examples'] = 'examples'
-        self.scheme_descriptions['docs'] = u'(Optional) pygame documentation'
-        self.scheme_map['docs'] = '/Developer/Python/pygame/Documentation'
-        self.scheme_copy['docs'] = 'docs'
-        for framework in FRAMEWORKS:
-            self.scheme_descriptions[framework] = u'(Required) %s.framework' % (framework,)
-            self.scheme_map[framework] = '/Library/Frameworks/%s.framework' % (framework,)
-            self.scheme_copy[framework] = '/Library/Frameworks/%s.framework' % (framework,)
+CUSTOM_SCHEMES = dict(
+    examples=dict(
+        description=u'(Optional) pygame example code',
+        prefix='/Developer/Python/pygame/Examples',
+        source='examples',
+    ),
+    docs=dict(
+        description=u'(Optional) pygame documentation',
+        prefix='/Developer/Python/pygame/Documentation',
+        source='docs',
+    ),
+)
 
-cmdclass = {'bdist_mpkg': bdist_mpkg}
+for framework in FRAMEWORKS:
+    CUSTOM_SCHEMES[framework] = dict(
+        description=u'(Required) %s.framework' % (framework,),
+        prefix='/Library/Frameworks/%s.framework' % (framework,),
+        source='/Library/Frameworks/%s.framework' % (framework,),
+    )
+
+options = dict(bdist_mpkg=dict(custom_schemes=CUSTOM_SCHEMES))
 that will allow you to use SDL's support for playing cdroms,
 audio and video output, and keyboard, mouse and joystick input."""
 
+EXTRAS = {}
+
 METADATA = {
     "name":             "pygame",
     "version":          "1.8.0pre",
     "long_description": DESCRIPTION,
 }
 
-cmdclass = {}
-
 import sys
 if not hasattr(sys, 'version_info') or sys.version_info < (2,2):
     raise SystemExit, "Pygame requires Python version 2.2 or above."
 
-try:
-    import bdist_mpkg_support
-except ImportError:
-    pass
-else:
-    cmdclass.update(bdist_mpkg_support.cmdclass)
-
 #get us to the correct directory
 import os, sys
 path = os.path.split(os.path.abspath(sys.argv[0]))[0]
 from distutils.ccompiler import new_compiler
 from distutils.command.install_data import install_data
 
+try:
+    import bdist_mpkg_support
+    from setuptools import setup, Extension
+except ImportError:
+    pass
+else:
+    EXTRAS.update({
+        'options': bdist_mpkg_support.options,
+        'setup_requires': ['bdist_mpkg>=0.4.2'],
+    })
+
+
 import config
 # a separate method for finding dlls with mingw.
 if config.is_msys_mingw():
         self.install_dir = getattr(install_cmd, 'install_lib')
         return install_data.run(self)
 
-cmdclass['install_data'] = smart_install_data
-
-
 #finally,
 #call distutils with all needed info
 PACKAGEDATA = {
-       "cmdclass":    cmdclass,
+       "cmdclass":    {'install_data': smart_install_data},
        "packages":    ['pygame', 'pygame.gp2x'],
        "package_dir": {'pygame': 'lib',
                        'pygame.gp2x': 'lib/gp2x'},
        "data_files":  [['pygame', data_files]],
 }
 PACKAGEDATA.update(METADATA)
+PACKAGEDATA.update(EXTRAS)
 setup(**PACKAGEDATA)