Repository: spyder-ide/spyder

Issue:
ImportError with create_app.py
## Description of problem

Hello, 

I installed spyder 3.0.0 on macOS Sierra 10.12 with pip. Spyder start's from terminal fine. 

I want to add Spyder to launchpad. So I tried to create app file for adding them to Applications.

I run create_app.py and got an error

```
Air-Oleg:spyder-3.0.0 xxblx$ python3 create_app.py py2app
Traceback (most recent call last):
  File "create_app.py", line 30, in <module>
    from spyder.config.main import EDIT_EXT
ImportError: cannot import name 'EDIT_EXT'
```
## Steps to reproduce
1. Download spyder-3.0.0 sources
2. python3 setup.py build
3. python3 create_app.py py2app
## Versions and main components
- spyder 3.0.0
- macOS Sierra 10.12
- Python 3.5.2 from Anaconda bundle
- py2app 0.10
## Dependencies

```
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.3 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.1 (OK)
pandas >=0.13.1  :  0.18.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  4.3.0 (OK)
pyflakes >=0.6.0 :  1.2.3 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.6.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.4.1 (OK)
sympy >=0.7.3    :  1.0 (OK)
```



Discussion:
I have the same issue on mac os 10.11, other configurations are the same.

I haven't had time to update `create_app.py`, that's why it's broken.

However, the process to create our apps is a lot more than just running `python create_app.py py2app`. If you really want to do this yourselves, please follow the instructions present in:

https://github.com/spyder-ide/mac-application


Resolving patch:
diff --git a/create_app.py b/create_app.py
--- a/create_app.py
+++ b/create_app.py
@@ -27,7 +27,7 @@
 from IPython.core.completerlib import module_list
 
 from spyder import __version__ as spy_version
-from spyder.config.main import EDIT_EXT
+from spyder.config.utils import EDIT_FILETYPES, _get_extensions
 from spyder.config.base import MAC_APP_NAME
 from spyder.utils.programs import find_program
 
@@ -64,6 +64,26 @@ def get_stdlib_modules():
     return modules
 
 
+#==============================================================================
+# Main message
+#==============================================================================
+main_message = """
+IMPORTANT NOTE
+==============
+
+Before running this script, please be sure of following the instructions
+present in
+
+https://github.com/spyder-ide/mac-application/blob/master/How to build the app.md
+
+This script only runs succesfully with those instructions!
+
+------
+"""
+
+print(main_message)
+
+
 #==============================================================================
 # App creation
 #==============================================================================
@@ -73,17 +93,18 @@ def get_stdlib_modules():
 APP = [APP_MAIN_SCRIPT]
 DEPS = ['pylint', 'logilab', 'astroid', 'pep8', 'setuptools']
 EXCLUDES = DEPS + ['mercurial']
-PACKAGES = ['spyder', 'spyderplugins', 'sphinx', 'jinja2', 'docutils',
+PACKAGES = ['spyder', 'spyder_breakpoints', 'spyder_io_dcm', 'spyder_io_hdf5',
+            'spyder_profiler', 'spyder_pylint', 'sphinx', 'jinja2', 'docutils',
             'alabaster', 'babel', 'snowballstemmer', 'sphinx_rtd_theme',
             'IPython', 'ipykernel', 'ipython_genutils', 'jupyter_client',
-            'jupyter_core', 'traitlets', 'qtconsole', 'pexpect',
-            'jsonschema', 'nbconvert', 'nbformat',
-            'zmq', 'pygments', 'rope', 'distutils', 'PIL', 'PyQt4',
+            'jupyter_core', 'traitlets', 'qtconsole', 'pexpect', 'jedi',
+            'jsonschema', 'nbconvert', 'nbformat', 'qtpy', 'qtawesome',
+            'zmq', 'pygments', 'rope', 'distutils', 'PIL', 'PyQt5',
             'sklearn', 'skimage', 'pandas', 'sympy', 'pyflakes', 'psutil',
             'nose', 'patsy','statsmodels', 'seaborn', 'networkx']
 
 INCLUDES = get_stdlib_modules()
-EDIT_EXT = [ext[1:] for ext in EDIT_EXT]
+EDIT_EXT = [ext[1:] for ext in _get_extensions(EDIT_FILETYPES)]
 
 OPTIONS = {
     'argv_emulation': True,
@@ -130,7 +151,8 @@ def get_stdlib_modules():
 # inside the app.
 minimal_lib = osp.join(app_python_lib, 'minimal-lib')
 os.mkdir(minimal_lib)
-minlib_pkgs = ['spyder', 'spyderplugins']
+minlib_pkgs = ['spyder', 'spyder_breakpoints', 'spyder_io_dcm',
+               'spyder_io_hdf5', 'spyder_profiler', 'spyder_pylint']
 for p in minlib_pkgs:
     shutil.copytree(osp.join(app_python_lib, p), osp.join(minimal_lib, p))
 
@@ -156,10 +178,10 @@ def get_stdlib_modules():
         shutil.copy2(osp.join(system_python_lib, i),
                      osp.join(app_python_lib, i))
 
-# Copy dependencies for IPython/Jupyter
-IPYDEPS = ['path.py', 'simplegeneric.py', 'decorator.py', 'mistune.py',
-           'mistune.so', 'pickleshare.py']
-for dep in IPYDEPS:
+# Single file dependencies
+SINGLE_DEPS = ['path.py', 'simplegeneric.py', 'decorator.py', 'mistune.py',
+               'mistune.so', 'pickleshare.py', 'sip.so']
+for dep in SINGLE_DEPS:
     if osp.isfile(osp.join(system_python_lib, dep)):
         shutil.copyfile(osp.join(system_python_lib, dep),
                         osp.join(app_python_lib, dep))
@@ -176,9 +198,9 @@ def _change_interpreter(program):
     try:
         for line in fileinput.input(program, inplace=True):
             if line.startswith('#!'):
-                print('#!' + sys.executable)
+                print('#!' + sys.executable, end='')
             else:
-                print(line)
+                print(line, end='')
     except:
         pass
 
@@ -250,9 +272,6 @@ def _get_env():
     else:
         print(line, end='')
 
-# To use the app's own Qt framework
-subprocess.call(['macdeployqt', 'dist/%s' % MAC_APP_NAME])
-
 # Workaround for what appears to be a bug with py2app and Homebrew
 # See https://bitbucket.org/ronaldoussoren/py2app/issue/26#comment-2092445
 PF_dir = get_config_var('PYTHONFRAMEWORKINSTALLDIR')
diff --git a/spyder/utils/site/sitecustomize.py b/spyder/utils/site/sitecustomize.py
--- a/spyder/utils/site/sitecustomize.py
+++ b/spyder/utils/site/sitecustomize.py
@@ -178,7 +178,7 @@ def write(self, text):
 if sys.platform == 'darwin':
     from spyder.config.base import MAC_APP_NAME
     if MAC_APP_NAME in __file__:
-        if IS_EXT_INTERPRETER.lower() == "true":
+        if IS_EXT_INTERPRETER:
             # Add a minimal library (with spyder) at the end of sys.path to
             # be able to connect our monitor to the external console
             py_ver = '%s.%s' % (sys.version_info[0], sys.version_info[1])


Test patch: