Repository: xonsh/xonsh

Issue:
slow startup while installing as develop dependency
<!--- Provide a general summary of the issue in the Title above -->
<!--- If you have a question along the lines of "How do I do this Bash command in xonsh"
please first look over the Bash to Xonsh translation guide: https://xon.sh/bash_to_xsh.html
If you don't find an answer there, please do open an issue! -->

## xonfig

<details>

```
+------------------+----------------------+
| xonsh            | 0.9.24.dev211        |
| Git SHA          | 4f060b0a             |
| Commit Date      | Dec 25 20:44:34 2020 |
| Python           | 3.8.6                |
| PLY              | 3.11                 |
| have readline    | True                 |
| prompt toolkit   | 3.0.8                |
| shell type       | prompt_toolkit       |
| pygments         | 2.7.3                |
| on posix         | True                 |
| on linux         | True                 |
| distro           | manjaro              |
| on darwin        | False                |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
| on jupyter       | False                |
| jupyter kernel   | None                 |
| xontrib 1        | abbrevs              |
| xontrib 2        | avox_poetry          |
| xontrib 3        | back2dir             |
| xontrib 4        | broot                |
| xontrib 5        | cmd_done             |
| xontrib 6        | commands             |
| xontrib 7        | fzf-widgets          |
| xontrib 8        | hist_navigator       |
| xontrib 9        | jedi                 |
| xontrib 10       | kitty                |
| xontrib 11       | notifypy             |
| xontrib 12       | powerline3           |
| xontrib 13       | prompt_ret_code      |
| xontrib 14       | vox                  |
| xontrib 15       | voxapi               |
+------------------+----------------------+

```

</details>

## Expected Behavior
<!--- Tell us what should happen -->

## Current Behavior
<!--- Tell us what happens instead of the expected behavior -->
<!--- If part of your bug report is a traceback, please first enter debug mode before triggering the error
To enter debug mode, set the environment variable `XONSH_DEBUG=1` _before_ starting `xonsh`.
On Linux and OSX, an easy way to to do this is to run `env XONSH_DEBUG=1 xonsh` -->
when installing the xonsh from source using `python setup.py develop` the startup time becomes very high. I am just curious to know what causes this and perhaps anyone using some workarounds.

## Steps to Reproduce
<!--- Please try to write out a minimal reproducible snippet to trigger the bug, it will help us fix it! -->
```sh
python -m venv .venv
vox activate .venv
cd xonsh # source folder
pip install -e .
```

develop mode timings

<details>

```

Debug level: Off
|-------------------------|-----------|-----------|
|Event name               | Time (s)  | Delta (s) |
|-------------------------|-----------|-----------|
|start                    |   0.000   |   0.000   |
|pre_execer_init          |   0.047   |   0.047   |
|post_execer_init         |   0.076   |   0.030   |
|on_pre_rc                |   0.077   |   0.000   |
|on_post_rc               |   4.073   |   3.996   |
|on_ptk_create            |   4.101   |   0.029   |
|on_post_init             |   4.102   |   0.001   |
|on_pre_cmdloop           |   4.120   |   0.018   |
|on_pre_prompt_format     |   4.121   |   0.000   |
|on_pre_prompt_tokenize   |   4.178   |   0.057   |
|on_post_prompt_tokenize  |   4.191   |   0.013   |
|on_pre_prompt_style      |   4.191   |   0.000   |
|on_post_prompt_style     |   4.386   |   0.195   |
|on_pre_prompt            |   4.386   |   0.000   |
|-------------------------|-----------|-----------|
```

</details>

in normal dist mode
```sh
pip install .
```

<details>

```

Debug level: Off
|-------------------------|-----------|-----------|
|Event name               | Time (s)  | Delta (s) |
|-------------------------|-----------|-----------|
|start                    |   0.000   |   0.000   |
|pre_execer_init          |   0.020   |   0.020   |
|post_execer_init         |   0.127   |   0.107   |
|on_pre_rc                |   0.127   |   0.000   |
|on_post_rc               |   0.820   |   0.693   |
|on_ptk_create            |   0.848   |   0.028   |
|on_post_init             |   0.849   |   0.001   |
|on_pre_cmdloop           |   0.875   |   0.026   |
|on_pre_prompt_format     |   0.875   |   0.000   |
|on_pre_prompt_tokenize   |   0.932   |   0.057   |
|on_post_prompt_tokenize  |   0.945   |   0.012   |
|on_pre_prompt_style      |   0.945   |   0.000   |
|on_post_prompt_style     |   1.126   |   0.181   |
|on_pre_prompt            |   1.126   |   0.000   |
|-------------------------|-----------|-----------|

```
</details>

## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,6 @@
 # fixed. See https://github.com/xonsh/xonsh/issues/487.
 import os
 import sys
-import json
 import subprocess
 
 from setuptools import setup, find_packages
@@ -62,14 +61,15 @@ def amalgamate_source():
 
 def build_tables():
     """Build the lexer/parser modules."""
-    print("Building lexer and parser tables.")
-    sys.path.insert(0, os.path.dirname(__file__))
+    print("Building lexer and parser tables.", file=sys.stderr)
+    root_dir = os.path.abspath(os.path.dirname(__file__))
+    sys.path.insert(0, root_dir)
     from xonsh.parser import Parser
 
     Parser(
         lexer_table="lexer_table",
         yacc_table="parser_table",
-        outputdir="xonsh",
+        outputdir=os.path.join(root_dir, "xonsh"),
         yacc_debug=True,
     )
     sys.path.pop(0)
@@ -348,7 +348,14 @@ def main():
         "linux": ["distro"],
         "proctitle": ["setproctitle"],
         "zipapp": ['importlib_resources; python_version < "3.7"'],
-        "full": ["ptk", "pygments", "distro"],
+        "full": [
+            "prompt-toolkit>=3",
+            "pyperclip",
+            "pygments>=2.2",
+            "distro; platform_system=='Linux'",  # PEP 508 platform specifiers
+            "setproctitle; platform_system=='Windows'",
+            "gnureadline; platform_system=='Darwin'",
+        ],
     }
     skw["python_requires"] = ">=3.6"
     setup(**skw)


Test patch: