Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Virtual Environment Support for Dependencies #218

Merged
merged 23 commits into from
Feb 26, 2020
Merged

Conversation

andreamah
Copy link
Contributor

Description:

Uses a virtual environment in extension files for holding adafruit_circuitplayground dependencies. Also allows for users to use their own virtual environments + install dependencies to those ones.

I also added a new option in settings to automatically configure environments when you switch the python interpreter. It is set to false by default, as it would probably be pretty disruptive if you're not using the extension.

There still the command palette option to configure the environment, which is now adapted for the new workflow.

If the python interpreter option ever gets deprecated and the "python.pythonPath" setting is no longer available, it will just use the global python version to create a virtual environment in the extension files every time.

Former dependencyChecker.ts system is deleted, since we are now more reliant on the python interpreter's ability to find the python path rather than what the python path environment variable is pointing to.

If virtual environment creation on the extension side ever fails, the extension asks the user if it can just install dependencies to whichever python interpreter they have selected & it stays on that interpreter.

If the user already has all dependencies installed on the python version that the interpreter is pointing to, it doesn't care whether they're in a venv and just goes with the current interpreter with no setup.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Limitations:

Testing:

Checklist:

  • My code follows the style guidelines of this project
  • My code has been formatted with npm run format and passes the checks in npm run check
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Copy link

@nasadigital nasadigital left a comment

Choose a reason for hiding this comment

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

The experience was much smoother than I expected! Awesome job :)

Copy link

@nasadigital nasadigital left a comment

Choose a reason for hiding this comment

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

LGTM. I noticed that the linter outputs a errors before "activating" the extension in the session (before we point to the venv), do you think we can do something about that?

package.nls.json Outdated
@@ -12,7 +12,7 @@
"deviceSimulatorExpressExtension.commands.microbit.openSimulator": "[micro:bit] Open Simulator",
"deviceSimulatorExpressExtension.commands.microbit.newFile": "[micro:bit] New File",
"deviceSimulatorExpressExtension.configuration.title": "Device Simulator Express configuration",
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python Interpreter, the dependencies for the Device Simulator Express will automatically be configured for the extension dependencies (and the interpreter will auto-change if necessary).",
"deviceSimulatorExpressExtension.configuration.properties.configEnvOnChange": "When you change the Python interpreter, the Device Simulator Express will atuomatically configure itself for the required dependencies.",

Choose a reason for hiding this comment

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

'automatically' is misspelled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LGTM. I noticed that the linter outputs a errors before "activating" the extension in the session (before we point to the venv), do you think we can do something about that?

For this, the pylint configuration is added upon activation, so it's hard to have it recognize it before activating :(. Based on our current structure, pylint doesn't know to look in our outfolder until we specify.

Copy link
Contributor

@isadorasophia isadorasophia left a comment

Choose a reason for hiding this comment

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

I am not entirely familiar with the best practices managing packages for VS extensions, but LGTM otherwise. I mostly made some nit suggestions as I had some trouble understanding some of the details at first :)

@nasadigital
Copy link

By the way, does the CI pipeline test the whole flow (from installing the extension to running an example)?

@andreamah andreamah merged commit 877cd30 into dev Feb 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants