Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow multiline input #260

Merged
merged 54 commits into from
Oct 12, 2020
Merged

Allow multiline input #260

merged 54 commits into from
Oct 12, 2020

Conversation

yajo
Copy link
Member

@yajo yajo commented Aug 17, 2020

Fix #210.

TODO:

Upstream PRs done by the way:

@Tecnativa TT23705

@yajo yajo added this to the v6.0.0 milestone Aug 17, 2020
@yajo
Copy link
Member Author

yajo commented Aug 19, 2020

This PoC uses prompt-toolkit, and it looks quite nice until now, because it lets us to have live validation, multiline input and syntax highlighting.

Implementing choices, however, will be quite hard at least until prompt-toolkit/python-prompt-toolkit#1071 is fixed. Bool quiestions shouldn't be a problem, as bools are one simple kind of choices after all...

There are other simpler prompt toolkits which are all missing the multiline input feature. I opened a bunch of feature requests, and I will wait some time. If one of them implements it, it should be our toolkit of choice:

If none does, then we'll have to choose one of those for all things except multiline inputs, and use prompt-toolkit just for those. But I'd rather prefer to stick with a single prompt toolkit if possible.

@pawamoy
Copy link
Contributor

pawamoy commented Oct 8, 2020

Well... I don't understand why the pip install fails either... Maybe try to restart the job 😕

Or could it be a cache issue?

I've tried that command on Windows:

 'C:\Program Files\Git\bin\bash.EXE' --noprofile --norc -e -o pipefail -c 'python -m pip install poetry poetry-dynamic-versioning poethepoet'

...and it went fine, even when the requirements were already satisfied.

@yajo
Copy link
Member Author

yajo commented Oct 9, 2020

Oh well, it seems you skipped some steps:

python -m pip install poetry poetry-dynamic-versioning poethepoet
poetry run python -m pip install pip -U
poetry install --verbose

The failure actually happens on the poetry install step, and it is probably related to python-poetry/poetry#3090 or python-poetry/poetry#3045.

@pawamoy
Copy link
Contributor

pawamoy commented Oct 9, 2020

Damn you're right! I'll try again.

@pawamoy
Copy link
Contributor

pawamoy commented Oct 9, 2020

I had some KeyError:

  1  c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:1215 in _updated_path
     return os.pathsep.join([str(self._bin_dir), os.environ["PATH"]])

  KeyError

  'PATH'

...fixed with export PATH.

Then I got:

  Stack trace:

  7  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:199 in _execute_operation
     result = self._do_execute_operation(operation)

  6  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:273 in _do_execute_operation
     result = getattr(self, "_execute_{}".format(method))(operation)

  5  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:408 in _execute_install
     return self._install(operation)

  4  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:446 in _install
     return self.run_pip(*args)

  3  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:297 in run_pip
     self._env.run_pip(*args, **kwargs)

  2  c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:916 in run_pip
     return self._run(cmd, **kwargs)

  1  c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:1189 in _run
     return super(VirtualEnv, self)._run(cmd, **kwargs)

  EnvCommandError

  Command C:\Users\user\copier\venv\Scripts\pip.exe install --no-deps C:\Users\user\AppData\Local\pypoetry\Cache\artifacts\58\cc\c2\a3eb325d94ba57a74146fd5692fb3876a9ff8d11985fdf1e35f389b0ee\jsbeautifier-1.13.0.tar.gz errored with the following return code 1, and output:
  Looking in indexes: redacted
  Processing c:\users\user\appdata\local\pypoetry\cache\artifacts\58\cc\c2\a3eb325d94ba57a74146fd5692fb3876a9ff8d11985fdf1e35f389b0ee\jsbeautifier-1.13.0.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
      Preparing wheel metadata: started
      Preparing wheel metadata: finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: 'c:\users\user\copier\venv\scripts\python.exe' 'c:\users\user\copier\venv\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\user\AppData\Local\Temp\1\tmpe2ua9ub0'
           cwd: C:\Users\user\AppData\Local\Temp\1\pip-req-build-806c5fbj
      Complete output (14 lines):
      running dist_info
      creating C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info
      writing C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\PKG-INFO
      writing dependency_links to C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\dependency_links.txt
      writing entry points to C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\entry_points.txt
      writing requirements to C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\requires.txt
      writing top-level names to C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\top_level.txt
      writing manifest file 'C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\SOURCES.txt'
      reading manifest file 'C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching 'js-beautify'
      writing manifest file 'C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.egg-info\SOURCES.txt'
      creating 'C:\Users\user\AppData\Local\Temp\1\pip-modern-metadata-ol72kxsp\jsbeautifier.dist-info'
      error: invalid command 'bdist_wheel'
      ----------------------------------------
  ERROR: Command errored out with exit status 1: 'c:\users\user\copier\venv\scripts\python.exe' 'c:\users\user\copier\venv\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\user\AppData\Local\Temp\1\tmpe2ua9ub0' Check the logs for full command output.


  at c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:948 in _run
       944│                 output = subprocess.check_output(
       945│                     cmd, stderr=subprocess.STDOUT, **kwargs
       946│                 )
       947│         except CalledProcessError as e:
    →  948│             raise EnvCommandError(e, input=input_)
       949│
       950│         return decode(output)
       951│
       952│     def execute(self, bin, *args, **kwargs):

...fixed with pip install wheel in the venv I'm using.

Then I got:

  Stack trace:

  7  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:199 in _execute_operation
     result = self._do_execute_operation(operation)

  6  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:273 in _do_execute_operation
     result = getattr(self, "_execute_{}".format(method))(operation)

  5  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:408 in _execute_install
     return self._install(operation)

  4  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:446 in _install
     return self.run_pip(*args)

  3  c:\users\user\copier\venv\lib\site-packages\poetry\installation\executor.py:297 in run_pip
     self._env.run_pip(*args, **kwargs)

  2  c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:916 in run_pip
     return self._run(cmd, **kwargs)

  1  c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:1189 in _run
     return super(VirtualEnv, self)._run(cmd, **kwargs)

  EnvCommandError

  Command C:\Users\user\copier\venv\Scripts\pip.exe install --no-deps C:\Users\user\AppData\Local\pypoetry\Cache\artifacts\9c\e3\a5\2336d6a7025672cb5036461b1bc4d7c9338cf89269e02b499c608ffe60\flake8-debugger-3.2.1.tar.gz errored with the following return code 1, and output:
  Looking in indexes: redacted
  Processing c:\users\user\appdata\local\pypoetry\cache\artifacts\9c\e3\a5\2336d6a7025672cb5036461b1bc4d7c9338cf89269e02b499c608ffe60\flake8-debugger-3.2.1.tar.gz
      ERROR: Command errored out with exit status 1:
       command: 'c:\users\user\copier\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\1\\pip-req-build-f4kaly7v\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\1\\pip-req-build-f4kaly7v\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\1\pip-pip-egg-info-7qvw3cyg'
           cwd: C:\Users\user\AppData\Local\Temp\1\pip-req-build-f4kaly7v\
      Complete output (25 lines):
      Download error on https://pypi.org/simple/pytest-runner/: Tunnel connection failed: 407 Proxy Authentication Required -- Some packages may not be found!
      Couldn't find index page for 'pytest-runner' (maybe misspelled?)
      Download error on https://pypi.org/simple/: Tunnel connection failed: 407 Proxy Authentication Required -- Some packages may not be found!
      No local packages or working download links found for pytest-runner
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "C:\Users\user\AppData\Local\Temp\1\pip-req-build-f4kaly7v\setup.py", line 60, in <module>
          'Programming Language :: Python :: 3.5',
        File "c:\users\user\copier\venv\lib\site-packages\setuptools\__init__.py", line 142, in setup
          _install_setup_requires(attrs)
        File "c:\users\user\copier\venv\lib\site-packages\setuptools\__init__.py", line 137, in _install_setup_requires
          dist.fetch_build_eggs(dist.setup_requires)
        File "c:\users\user\copier\venv\lib\site-packages\setuptools\dist.py", line 586, in fetch_build_eggs
          replace_conflicting=True,
        File "c:\users\user\copier\venv\lib\site-packages\pkg_resources\__init__.py", line 780, in resolve
          replace_conflicting=replace_conflicting
        File "c:\users\user\copier\venv\lib\site-packages\pkg_resources\__init__.py", line 1063, in best_match
          return self.obtain(req, installer)
        File "c:\users\user\copier\venv\lib\site-packages\pkg_resources\__init__.py", line 1075, in obtain
          return installer(requirement)
        File "c:\users\user\copier\venv\lib\site-packages\setuptools\dist.py", line 653, in fetch_build_egg
          return cmd.easy_install(req)
        File "c:\users\user\copier\venv\lib\site-packages\setuptools\command\easy_install.py", line 673, in easy_install
          raise DistutilsError(msg)
      distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pytest-runner')
      ----------------------------------------
  ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


  at c:\users\user\copier\venv\lib\site-packages\poetry\utils\env.py:948 in _run
       944│                 output = subprocess.check_output(
       945│                     cmd, stderr=subprocess.STDOUT, **kwargs
       946│                 )
       947│         except CalledProcessError as e:
    →  948│             raise EnvCommandError(e, input=input_)
       949│
       950│         return decode(output)
       951│
       952│     def execute(self, bin, *args, **kwargs):

...that I can't fix unfortunately. It seems flake8-debugger tries to download pytest-runner from PyPI, which is blocked by my corporate proxy.

@yajo yajo linked an issue Oct 12, 2020 that may be closed by this pull request
@yajo yajo merged commit cda9327 into master Oct 12, 2020
@yajo yajo deleted the improve-prompt branch October 12, 2020 07:56
@pawamoy
Copy link
Contributor

pawamoy commented Oct 12, 2020

Congrats on this @yajo, it looked like hell to get it to work on Windows 😅 Sorry I couldn't help more!

@yajo
Copy link
Member Author

yajo commented Oct 12, 2020

Haha it really was! At the end I had to skip a lot of tests, but it seems to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement hacktoberfest-accepted This PR is a candidate to win a T-shirt if done while the Hacktoberfest is live
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiline interactive input Conditional questions
2 participants