Repository: spyder-ide/spyder

Issue:
Language server does not start in macOS application (master)
### What steps will reproduce the problem?

<!--- You can use Markdown here --->

The language server does not appear to start in the macOS standalone application and command completion does not work.

Also, when running debug mode there does not appear to be any lsp logs produced. Are these in a new location?

### System
* Spyder version: 5.0.0.dev0 1dd460bf55912e851ec36686c8726e250c9853de (latest master)
* Python version: 3.9.1 64-bit
* Qt version: 5.12.10
* PyQt5 version: 5.12.3
* Operating System: Darwin 19.6.0
```
# Mandatory:
applaunchservices >=0.1.7   :  0.2.1 (OK)
atomicwrites >=1.2.0        :  1.4.0 (OK)
chardet >=2.0.0             :  4.0.0 (OK)
cloudpickle >=0.5.0         :  1.6.0 (OK)
cookiecutter >=1.6.0        :  1.7.2 (OK)
diff_match_patch >=20181111 :  20200713 (OK)
intervaltree >=3.0.2        :  3.1.0 (OK)
IPython >=7.6.0             :  7.21.0 (OK)
jedi =0.17.2                :  0.17.2 (OK)
jsonschema >=3.2.0          :  3.2.0 (OK)
keyring >=17.0.0            :  23.0.0 (OK)
nbconvert >=4.0             :  6.0.7 (OK)
numpydoc >=0.6.0            :  1.1.0 (OK)
parso =0.7.0                :  0.7.0 (OK)
pexpect >=4.4.0             :  4.8.0 (OK)
pickleshare >=0.4           :  0.7.5 (OK)
psutil >=5.3                :  5.8.0 (OK)
pygments >=2.0              :  2.8.1 (OK)
pylint >=1.0                :  2.7.2 (OK)
pyls >=0.36.2;<1.0.0        :  v5.0.0a5+145.g1dd460bf5 (OK)
pyls_black >=0.4.6          :  0.4.6 (OK)
pyls_spyder >=0.3.2         :  0.3.2 (OK)
qdarkstyle >=2.8            :  2.8.1 (OK)
qtawesome >=0.5.7           :  1.0.2 (OK)
qtconsole >=5.0.1           :  5.0.2 (OK)
qtpy >=1.5.0                :  1.9.0 (OK)
setuptools >=39.0.0         :  54.1.1 (OK)
sphinx >=0.6.6              :  3.5.2 (OK)
spyder_kernels >=2.0.0dev0  :  2.0.0.dev0 (OK)
textdistance >=4.2.0        :  4.2.1 (OK)
three_merge >=0.1.1         :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0    :  1.0.2 (OK)
zmq >=17                    :  22.0.3 (OK)

# Optional:
cython >=0.21               :  0.29.22 (OK)
matplotlib >=2.0.0          :  3.3.4 (OK)
numpy >=1.7                 :  1.20.1 (OK)
pandas >=1.1.1              :  1.2.3 (OK)
scipy >=0.17.0              :  1.6.1 (OK)
sympy >=0.7.3               :  1.7.1 (OK)
```


Discussion:
> The language server does not appear to start in the macOS standalone application and command completion does not work.

Now our code completion architecture uses setuptools entry points for its providers (LSP, Kite, Fallback and Snippets). So that could be causing issues in our Mac app.

> Also, when running debug mode there does not appear to be any lsp logs produced. Are these in a new location?

I guess the server is not even started in the app because the logs are generated as expected.
Okay, I'm not sure what to do with that...

Resolving patch:
diff --git a/bootstrap.py b/bootstrap.py
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -32,7 +32,6 @@
 
 time_start = time.time()
 
-
 # --- Parse command line
 
 parser = argparse.ArgumentParser(
@@ -43,20 +42,20 @@
 Type `python bootstrap.py -- --help` to read about Spyder
 options.""")
 parser.add_argument('--gui', default=None,
-                  help="GUI toolkit: pyqt5 (for PyQt5), pyqt (for PyQt4) or "
-                       "pyside (for PySide, deprecated)")
+                    help="GUI toolkit: pyqt5 (for PyQt5), pyqt (for PyQt4) or "
+                    "pyside (for PySide, deprecated)")
 parser.add_argument('--show-console', action='store_true', default=False,
-                  help="(Deprecated) Does nothing, now the default behavior "
-                  "is to show the console")
-parser.add_argument('--hide-console', action='store_true',
-                  default=False, help="Hide parent console window (Windows only)")
+                    help="(Deprecated) Does nothing, now the default behavior "
+                    "is to show the console")
+parser.add_argument('--hide-console', action='store_true', default=False,
+                    help="Hide parent console window (Windows only)")
 parser.add_argument('--safe-mode', dest="safe_mode",
                     action='store_true', default=False,
                     help="Start Spyder with a clean configuration directory")
-parser.add_argument('--no-apport', action='store_true',
-                    default=False, help="Disable Apport exception hook (Ubuntu)")
+parser.add_argument('--no-apport', action='store_true', default=False,
+                    help="Disable Apport exception hook (Ubuntu)")
 parser.add_argument('--debug', action='store_true',
-                  default=False, help="Run Spyder in debug mode")
+                    default=False, help="Run Spyder in debug mode")
 parser.add_argument('--filter-log', default='',
                     help="Comma-separated module name hierarchies whose log "
                          "messages should be shown. e.g., "
@@ -103,16 +102,16 @@
 # Warn if we're running under 3rd party exception hook, such as
 # apport_python_hook.py from Ubuntu
 if sys.excepthook != sys.__excepthook__:
-   if sys.excepthook.__name__ != 'apport_excepthook':
-     print("WARNING: 3rd party Python exception hook is active: '%s'"
-            % sys.excepthook.__name__)
-   else:
-     if not args.no_apport:
-       print("WARNING: Ubuntu Apport exception hook is detected")
-       print("         Use --no-apport option to disable it")
-     else:
-       sys.excepthook = sys.__excepthook__
-       print("NOTICE: Ubuntu Apport exception hook is disabed")
+    if sys.excepthook.__name__ != 'apport_excepthook':
+        print("WARNING: 3rd party Python exception hook is active: '%s'"
+              % sys.excepthook.__name__)
+    else:
+        if not args.no_apport:
+            print("WARNING: Ubuntu Apport exception hook is detected")
+            print("         Use --no-apport option to disable it")
+        else:
+            sys.excepthook = sys.__excepthook__
+            print("NOTICE: Ubuntu Apport exception hook is disabed")
 
 
 # --- Continue
@@ -180,6 +179,7 @@ def remove_pyls_installation():
 atexit.register(remove_pyls_installation)
 
 print("*. Declaring completion providers")
+
 # Register completion providers
 fallback = pkg_resources.EntryPoint.parse(
     'fallback = spyder.plugins.completion.providers.fallback.provider:'
@@ -226,7 +226,7 @@ def remove_pyls_installation():
     except ImportError:
         sys.exit("ERROR: No PyQt5 detected!")
 else:
-    print ("*. Skipping GUI toolkit detection")
+    print("*. Skipping GUI toolkit detection")
     os.environ['QT_API'] = args.gui
 
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -301,6 +301,8 @@ def run(self):
      'SnippetsProvider'),
     ('kite = spyder.plugins.completion.providers.kite.provider:'
      'KiteProvider'),
+    ('lsp = spyder.plugins.completion.providers.languageserver.provider:'
+     'LanguageServerProvider'),
 ]
 
 


Test patch: