Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

python: update images to use vscode extensions #297

Merged
merged 1 commit into from
Feb 19, 2020
Merged

Conversation

vince-fugnitto
Copy link
Member

What it does

Fixes #74

The goal of the pull-request is to update the existing theia-python:latest and theia-python:next images to make use of both builtin and external vscode extensions while also removing soon-to-be-deprecated extensions such as @theia/python.

The Dockerfile has also been modified to a modified version of the theia-full-docker image, complete with necessary Python 2 and 3 tools for development including the python-language-server which supports both versions.

Python functionality is completed by the vscode-python extension which also supports both Python 2 and 3.

In essence, the pull-request includes:

  • updates the theia-python:latest image to use builtin and vscode extensions.
  • updates the theia-python:next image to use builtin and vscode extensions.
  • updates the image to support both python 2 and 3.
  • includes the necessary tools for python development.

How to test

Verify that the CI successfully passes for both theia-python:latest and theia-python:next.

Review checklist

Reminder for reviewers

Signed-off-by: vince-fugnitto vincent.fugnitto@ericsson.com

@vince-fugnitto vince-fugnitto self-assigned this Feb 6, 2020
@vince-fugnitto vince-fugnitto force-pushed the vf/python branch 2 times, most recently from 0bbfa4f to 0a3e9d2 Compare February 6, 2020 22:26
Copy link
Contributor

@lmcbout lmcbout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating the docker image for testing now

theia-python-docker/Dockerfile Outdated Show resolved Hide resolved
theia-python-docker/latest.package.json Show resolved Hide resolved
@marcdumais-work
Copy link
Member

marcdumais-work commented Feb 12, 2020

(Note: I tested with a version of this PR where I switched to the node:10 image as base. I then built a latest version of the image. So take with a grain of salt - some issues may not reproduce on the original PR version)

the python extension logs a lot, specially at the INFO level. We should configure logging so these are not shown.

There are a couple of runtimes exceptions in BE log from the python extension. Here's one that I think happened during load:

root ERROR [hosted-plugin: 1556] (node:1556) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Following this tutorial I expected that the extension would notice when I create a virtual environment from the terminal but nothing happened. The new v env should also have been picked-up by the Select Python Environment command (shortcut on status bar), but were not listed among the choices .

@marcdumais-work
Copy link
Member

Seems Python3 is not happy with the system's locale . If confirmed we should set this in image (likely done already in Ubuntu):

theia@56b525a48f4d:/home/project$ python3 -m flask run
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/theia/.local/lib/python3.5/site-packages/flask/__main__.py", line 15, in <module>
    main(as_module=True)
  File "/home/theia/.local/lib/python3.5/site-packages/flask/cli.py", line 966, in main
    cli.main(prog_name="python -m flask" if as_module else None)
  File "/home/theia/.local/lib/python3.5/site-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/home/theia/.local/lib/python3.5/site-packages/click/core.py", line 696, in main
    _verify_python3_env()
  File "/home/theia/.local/lib/python3.5/site-packages/click/_unicodefun.py", line 124, in _verify_python3_env
    ' mitigation steps.' + extra
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/en/7.x/python3/ for mitigation steps.

This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8

Once I did Python's bidding, it rewarded me with a working app:

theia@56b525a48f4d:/home/project$ export LC_ALL=C.UTF-8
theia@56b525a48f4d:/home/project$     export LANG=C.UTF-8
theia@56b525a48f4d:/home/project$ 
theia@56b525a48f4d:/home/project$ python3 -m flask run
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [12/Feb/2020 00:40:28] "GET / HTTP/1.1" 200 

@vince-fugnitto vince-fugnitto force-pushed the vf/python branch 3 times, most recently from 733e20c to b143288 Compare February 12, 2020 20:23
@vince-fugnitto
Copy link
Member Author

@marcdumais-work I updated the baseImage for the Dockerfile, removed the gpg keys, and also removed sudo access. I will need to find a way to add a newer version of Python since the base version is 3.5 and the vscode-python extension requires at least 3.6.

@marcdumais-work
Copy link
Member

@marcdumais-work I updated the baseImage for the Dockerfile, removed the gpg keys, and also removed sudo access. I will need to find a way to add a newer version of Python since the base version is 3.5 and the vscode-python extension requires at least 3.6.

I hope there might be an better way, but last resort we could fetch the sources archive and build it as part of the image: https://medium.com/@rijaspk5195/install-python-3-6-4-on-debian-9-jessie-bb71cdc9ff35

@vince-fugnitto
Copy link
Member Author

@marcdumais-work I updated the baseImage for the Dockerfile, removed the gpg keys, and also removed sudo access. I will need to find a way to add a newer version of Python since the base version is 3.5 and the vscode-python extension requires at least 3.6.

I hope there might be an better way, but last resort we could fetch the sources archive and build it as part of the image: https://medium.com/@rijaspk5195/install-python-3-6-4-on-debian-9-jessie-bb71cdc9ff35

I updated the image to perform the steps you referenced (I could not find a simpler approach on debian). The image now has Python 3.6.4. (I tried updating to 3.7.0 but the build is too long).

@marcdumais-work
Copy link
Member

Following this tutorial I expected that the extension would notice when I create a virtual environment from the terminal but nothing happened. The new v env should also have been picked-up by the Select Python Environment command (shortcut on status bar), but were not listed among the choices .

This problem is gone - now the venv is detected and proposed from the select python environment command

👍

@vince-fugnitto
Copy link
Member Author

I believe the image is ready for another round of review 😄

@marcdumais-work
Copy link
Member

I am not a python developer, so I am not sure how important this is. While testing using a tutorial, I installed something through pip and got this warning:

You are using pip version 10.0.1, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

I think the version of pip available in the DEBIAN repo is what it is, but we can potentially upgrade it during image compilation, using the suggested command.

Fixes #74

- updates the `theia-python:latest` image to use builtin and vscode extensions.
- updates the `theia-python:next` image to use builtin and vscode extensions.
- updates the image to support both python 2 and 3.
- includes the necessary tools for python development.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
@vince-fugnitto
Copy link
Member Author

I think the version of pip available in the DEBIAN repo is what it is, but we can potentially upgrade it during image compilation, using the suggested command.

I now perform the update using:

pip install --upgrade pip --user

@marcdumais-work
Copy link
Member

Looking good - just rebuilding to quickly check the latest change and it should be enough.

Copy link
Member

@marcdumais-work marcdumais-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - nice work @vince-fugnitto

@vince-fugnitto
Copy link
Member Author

LGTM - nice work @vince-fugnitto

Thank you for the review!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support of Python3
4 participants