Commits

Ronald Oussoren committed e532fd6

py2app doesn't work on Windows or Linux, bail out in setup.py when trying to install on a platform that isn't OSX

Comments (0)

Files changed (2)

doc/changelog.rst

 py2app 0.7.4
 ------------
 
+- "python setup.py install" now fails unless the machine is running Mac OS X.
+
+  I've seen a number of reports of users that try to use py2app on Windows
+  or Linux to build OSX applications. That doesn't work, py2app now fails
+  during installation do make this clear.
+
 - Disabled the 'email' recipe for python 3.x as it isn't needed there.
 
 - Issue #91: Added a recipe for `lxml <http://lxml.de/>`, needed because
             # Collect sphinx output
             if not os.path.exists('dist'):
                 os.mkdir('dist')
-            zf = zipfile.ZipFile('dist/%s-docs.zip'%(name,), 'w', 
+            zf = zipfile.ZipFile('dist/%s-docs.zip'%(name,), 'w',
                     compression=zipfile.ZIP_DEFLATED)
 
             for toplevel, dirs, files in os.walk('doc/_build/html'):
             # Upload the results, this code is based on the distutils
             # 'upload' command.
             content = open('dist/%s-docs.zip'%(name,), 'rb').read()
-            
+
             data = {
                 ':action': 'doc_upload',
                 'name': name,
                 self.announce('Upload failed (%s): %s' % (r.status, r.reason),
                     log.ERROR)
 
-                print ('-'*75) 
+                print ('-'*75)
                 print (r.read())
                 print ('-'*75)
 
             if fnmatch(fn, pathPattern):
                 result.append(os.path.join(rootpath, fn))
     return result
-        
 
-def importExternalTestCases(unittest, 
+
+def importExternalTestCases(unittest,
         pathPattern="test_*.py", root=".", package=None):
     """
     Import all unittests in the PyObjC tree starting at 'root'
         testModules = [(package + '.' + m) for m in testModules]
 
     suites = []
-   
+
     for modName in testModules:
         try:
             module = __import__(modName)
         if nspkgs is not None:
             for nm in nspkgs:
                 del sys.modules[nm]
-        
+
         # Reset pkg_resources state:
         add_activation_listener(lambda dist: dist.activate())
         working_set.__init__()
             meta = self.distribution.metadata
             name = meta.get_name()
             test_pkg = name + "_tests"
-            suite = importExternalTestCases(unittest, 
+            suite = importExternalTestCases(unittest,
                     "test_*.py", test_pkg, test_pkg)
 
             runner = unittest.TextTestRunner(verbosity=self.verbosity)
 
         finally:
             self.remove_from_sys_path()
+
+from setuptools.command import build_py
+
+class my_build_py (build_py.build_py):
+    def run(self):
+        if sys.platform != 'darwin':
+            raise DistutilsError("Py2app can only be used on Mac OS X")
+
+        build_py.build_py.run(self)
+
 setup(
     # metadata
     name='py2app',
     ],
     tests_require=tests_require,
     cmdclass=dict(
+        build_py=my_build_py,
         upload_docs=upload_docs,
         test=test,
     ),