From 6c7764114f4b36f7c40132dfb6ec3e3ba14eb593 Mon Sep 17 00:00:00 2001 From: andreamah Date: Mon, 20 Jan 2020 11:42:45 -0800 Subject: [PATCH 1/4] fixed python package downloads for py 3.8 and removed pywin32 install for unix --- README.md | 22 +++++++++------------- docs/developers-setup.md | 22 +++++++--------------- docs/install.md | 14 +++++++------- gulpfile.js | 3 ++- src/constants.ts | 2 ++ src/extension_utils/utils.ts | 32 ++++++++++++++++++-------------- src/requirements-windows.txt | 6 ++++++ src/requirements.txt | 1 - 8 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 src/requirements-windows.txt diff --git a/README.md b/README.md index 49143b6db..0afb45b7c 100644 --- a/README.md +++ b/README.md @@ -43,19 +43,15 @@ You will be prompted to install the Python dependencies during the first use. - _**[Python 3.7.4](https://www.python.org/downloads/)**_: Make sure you've added python and pip to your PATH in your environment variables. (1) - _**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express. -The following dependecies can be installed for you by the extension by clicking yes when you are prompted to (**except** `pywin32` which is needed only on Windows platform). (2) - -- _**Playsound**_ - install by typing the following commands in a console: `pip install playsound` - -- _**Pywin 32**_ - install by typing the following commands in a console (only for Windows computers, you must run it manually): `pip install pywin32` -- _**Python-Socketio**_ - install by typing the following commands in a console: `pip install python-socketio` -- _**Requests**_ - install by typing the following commands in a console: `pip install requests` -- _**Application Insights**_ - install by typing the following commands in a console: `pip install applicationinsights` +- Python Modules + - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following Python modules should be downloaded when you select "yes" on prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** + - Playsound : `pip install playsound` + - Pywin32 : `pip install pywin32` + - **Note:** This is only needed for Windows computers. + - Python-Socketio : `pip install python-socketio` + - Requests : `pip install requests` + - Application Insights: `pip install applicationinsights` + ## Useful Links diff --git a/docs/developers-setup.md b/docs/developers-setup.md index d9eb3a2b1..1e3ce5752 100644 --- a/docs/developers-setup.md +++ b/docs/developers-setup.md @@ -15,21 +15,13 @@ - Run in a console `python -m pip install --upgrade pip` * Python Modules - - - **Note:** On extension activation you will be prompted a popup asking if you want the modules to be automatically installed for you, **except** `pywin32` which is needed only on Windows platform. - - Playsound - - Run the command in a console : `pip install playsound` - - pytest - - Run the command in a console : `pip install pytest` - - Pywin32 - - **Note:** This is only needed for Windows computers. You must install it manually with the above command! - - Run the command in a console : `pip install pywin32` - - Python-Socketio - - Run the command in a console : `pip install python-socketio` - - Requests - - Run the command in a console : `pip install requests` - - Application Insights - - Run the command in a console : `pip install applicationinsights` + - **Note:** On extension activation, you will be prompted with a popup asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on prompt message. + - playsound + - pytest + - python-socketio + - requests + - applicationinsights + - pywin32 **(on Windows only)** * VS Code diff --git a/docs/install.md b/docs/install.md index b0d782d2d..e1abe4b60 100644 --- a/docs/install.md +++ b/docs/install.md @@ -23,13 +23,13 @@ _Note: You need to install all the dependencies in order to use the extension._ - [Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - **Note:** This extension is installed automatically from the marketplace when you install our extension - Python Modules - - **Note:** On extension activation you will be prompted a popup asking if you want the modules to be automatically installed for you, **except** `pywin32` which is needed only on Windows platform. - - Playsound : `pip install playsound` - - Pywin32 : `pip install pywin32` - - **Note:** This is only needed for Windows computers. You must install it manually with the above command! - - Python-Socketio : `pip install python-socketio` - - Requests : `pip install requests` - - Application Insights: `pip install applicationinsights` + - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** + - Playsound : `pip install playsound` + - Pywin32 : `pip install pywin32` + - **Note:** This is only needed for Windows computers. + - Python-Socketio : `pip install python-socketio` + - Requests : `pip install requests` + - Application Insights: `pip install applicationinsights` ## How to use the Extension diff --git a/gulpfile.js b/gulpfile.js index fdc6fcac2..d5cb8cd27 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -36,7 +36,8 @@ gulp.task("clean", () => { const pythonToMove = [ "./src/adafruit_circuitplayground/*.*", "./src/*.py", - "./src/requirements.txt" + "./src/requirements.txt", + "./src/requirements-windows.txt" ]; gulp.task("python-compile", () => { diff --git a/src/constants.ts b/src/constants.ts index 692d13f55..21d8c8060 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -45,6 +45,8 @@ export const CONSTANTS = { "error.debuggingSessionInProgress", "[ERROR] A debugging session is currently in progress, please stop it before running your code. \n" ), + DEPENDENCY_DOWNLOAD_ERROR: + "Package downloads failed. Some functionality may not work. ", FAILED_TO_OPEN_SERIAL_PORT: (port: string): string => { return localize( "error.failedToOpenSerialPort", diff --git a/src/extension_utils/utils.ts b/src/extension_utils/utils.ts index 546bb8538..a4eaa72a9 100644 --- a/src/extension_utils/utils.ts +++ b/src/extension_utils/utils.ts @@ -258,14 +258,12 @@ export const checkConfig = (configName: string): boolean => { export const checkPythonDependencies = async (context: vscode.ExtensionContext, pythonExecutable: string) => { let hasInstalledDependencies: boolean = false; + const pathToLibs: string = getPathToScript(context, "out", "python_libs"); if (checkPipDependency() && checkPythonDependency()) { if (checkConfig(CONFIG.SHOW_DEPENDENCY_INSTALL)) { - hasInstalledDependencies = await promptInstallPythonDependencies(context, pythonExecutable); - if (hasInstalledDependencies) { - await vscode.workspace - .getConfiguration() - .update(CONFIG.SHOW_DEPENDENCY_INSTALL, false); - } + // check if ./out/python_libs exists; if not, the dependencies + // for adafruit_circuitpython are not (successfully) installed yet + hasInstalledDependencies = fs.existsSync(pathToLibs) || await promptInstallPythonDependencies(context, pythonExecutable, pathToLibs); } } else { hasInstalledDependencies = false; @@ -273,14 +271,14 @@ export const checkPythonDependencies = async (context: vscode.ExtensionContext, return hasInstalledDependencies; }; -export const promptInstallPythonDependencies = (context: vscode.ExtensionContext, pythonExecutable: string) => { +export const promptInstallPythonDependencies = (context: vscode.ExtensionContext, pythonExecutable: string, pathToLibs: string) => { return vscode.window.showInformationMessage( CONSTANTS.INFO.INSTALL_PYTHON_DEPENDENCIES, DialogResponses.YES, DialogResponses.NO) .then((selection: vscode.MessageItem | undefined) => { if (selection === DialogResponses.YES) { - return installPythonDependencies(context, pythonExecutable); + return installPythonDependencies(context, pythonExecutable, pathToLibs); } else if (selection === DialogResponses.NO) { return vscode.window.showInformationMessage( CONSTANTS.INFO.ARE_YOU_SURE, @@ -288,7 +286,7 @@ export const promptInstallPythonDependencies = (context: vscode.ExtensionContext DialogResponses.DONT_INSTALL ).then((installChoice: vscode.MessageItem | undefined) => { if (installChoice === DialogResponses.INSTALL_NOW) { - return installPythonDependencies(context, pythonExecutable); + return installPythonDependencies(context, pythonExecutable, pathToLibs); } else { return false; } @@ -302,18 +300,24 @@ export const getTelemetryState = () => { .get("telemetry.enableTelemetry", true); }; -export const installPythonDependencies = async (context: vscode.ExtensionContext, pythonExecutable: string) => { +export const installPythonDependencies = async (context: vscode.ExtensionContext, pythonExecutable: string, pathToLibs: string) => { let installed: boolean = false; try { vscode.window.showInformationMessage(CONSTANTS.INFO.INSTALLING_PYTHON_DEPENDENCIES); - const requirementsPath: string = getPathToScript(context, "out", "requirements.txt"); - const pathToLibs: string = getPathToScript(context, "out", "python_libs"); + + // only use requirements file with pywin32 if on windows + const requirementsFileName = (process.platform === "win32") ? "requirements-windows.txt" : "requirements.txt"; + const requirementsPath: string = getPathToScript(context, "out", requirementsFileName); + + // run command to download dependencies to out/python_libs const { stdout } = await exec(`${pythonExecutable} -m pip install -r ${requirementsPath} -t ${pathToLibs}`); - console.info(stdout); installed = true; + + console.log(stdout) vscode.window.showInformationMessage(CONSTANTS.INFO.SUCCESSFUL_INSTALL); } catch (err) { - console.error(err); + vscode.window.showErrorMessage(CONSTANTS.ERROR.DEPENDENCY_DOWNLOAD_ERROR); + console.error(err) installed = false; } return installed diff --git a/src/requirements-windows.txt b/src/requirements-windows.txt new file mode 100644 index 000000000..9e30ba279 --- /dev/null +++ b/src/requirements-windows.txt @@ -0,0 +1,6 @@ +playsound==1.2.2 +pytest==5.0.1 +applicationinsights==0.11.9 +python-socketio==4.3.1 +requests==2.22.0 +pywin32>=224 diff --git a/src/requirements.txt b/src/requirements.txt index b39b0bc1e..29e459465 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -3,4 +3,3 @@ pytest==5.0.1 applicationinsights==0.11.9 python-socketio==4.3.1 requests==2.22.0 -pywin32==224 From dd00ae189dce2266f03eda2248fb0a957df1ff57 Mon Sep 17 00:00:00 2001 From: andreamah Date: Mon, 20 Jan 2020 15:52:49 -0800 Subject: [PATCH 2/4] documentation updates for deploy to device package correction --- README.md | 5 ++++- docs/developers-setup.md | 5 ++++- docs/install.md | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0afb45b7c..8a9d3296a 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,10 @@ You will be prompted to install the Python dependencies during the first use. - _**[Python 3.7.4](https://www.python.org/downloads/)**_: Make sure you've added python and pip to your PATH in your environment variables. (1) - _**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express. -- Python Modules +- Python Modules for Deploy to Device + - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` + +- Python Modules for Simulation - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following Python modules should be downloaded when you select "yes" on prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** - Playsound : `pip install playsound` - Pywin32 : `pip install pywin32` diff --git a/docs/developers-setup.md b/docs/developers-setup.md index 1e3ce5752..09b69a7e0 100644 --- a/docs/developers-setup.md +++ b/docs/developers-setup.md @@ -14,7 +14,10 @@ (for example it could be found at : `c:\users\<...>\appdata\local\programs\python\python37\lib\site-packages\pip`) - Run in a console `python -m pip install --upgrade pip` -* Python Modules +* Python Modules for Deploy to Device + - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` + +* Python Modules for Simulation - **Note:** On extension activation, you will be prompted with a popup asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on prompt message. - playsound - pytest diff --git a/docs/install.md b/docs/install.md index e1abe4b60..504ca4bfc 100644 --- a/docs/install.md +++ b/docs/install.md @@ -22,7 +22,11 @@ _Note: You need to install all the dependencies in order to use the extension._ _(Note: the easiest way to do it might be when you install Python, you can select the "Add to PATH" option directly. Otherwise you can search how to insert it manually, but make sure that when you type `python` (or `python3.7`) in a terminal, the command is recognized.)_ - [Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - **Note:** This extension is installed automatically from the marketplace when you install our extension -- Python Modules + +- Python Modules for Deploy to Device + - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` + +- Python Modules for Simulation - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** - Playsound : `pip install playsound` - Pywin32 : `pip install pywin32` From 76c04c56ab58bb2aee7ba06229ddd4296b72849e Mon Sep 17 00:00:00 2001 From: andreamah Date: Tue, 21 Jan 2020 13:56:22 -0800 Subject: [PATCH 3/4] incorporated PR feedback --- README.md | 4 ++-- docs/developers-setup.md | 4 ++-- docs/install.md | 4 ++-- gulpfile.js | 3 +-- locales/en/out/constants.i18n.json | 1 + src/constants.ts | 10 +++++++++- src/extension.ts | 6 +++--- src/extension_utils/utils.ts | 24 ++++++++++++++++-------- src/requirements-windows.txt | 6 ------ src/requirements.txt | 1 + 10 files changed, 37 insertions(+), 26 deletions(-) delete mode 100644 src/requirements-windows.txt diff --git a/README.md b/README.md index 8a9d3296a..33adc5c4f 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,11 @@ You will be prompted to install the Python dependencies during the first use. - _**[Python 3.7.4](https://www.python.org/downloads/)**_: Make sure you've added python and pip to your PATH in your environment variables. (1) - _**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express. -- Python Modules for Deploy to Device +- Python Modules for Deploying to Device - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` - Python Modules for Simulation - - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following Python modules should be downloaded when you select "yes" on prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** + - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following Python modules should be downloaded when you select "yes" on the prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** - Playsound : `pip install playsound` - Pywin32 : `pip install pywin32` - **Note:** This is only needed for Windows computers. diff --git a/docs/developers-setup.md b/docs/developers-setup.md index 09b69a7e0..c210fc948 100644 --- a/docs/developers-setup.md +++ b/docs/developers-setup.md @@ -14,11 +14,11 @@ (for example it could be found at : `c:\users\<...>\appdata\local\programs\python\python37\lib\site-packages\pip`) - Run in a console `python -m pip install --upgrade pip` -* Python Modules for Deploy to Device +* Python Modules for Deploying to Device - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` * Python Modules for Simulation - - **Note:** On extension activation, you will be prompted with a popup asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on prompt message. + - **Note:** On extension activation, you will be prompted with a popup asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on the prompt message. - playsound - pytest - python-socketio diff --git a/docs/install.md b/docs/install.md index 504ca4bfc..2e995ece3 100644 --- a/docs/install.md +++ b/docs/install.md @@ -23,11 +23,11 @@ _Note: You need to install all the dependencies in order to use the extension._ - [Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - **Note:** This extension is installed automatically from the marketplace when you install our extension -- Python Modules for Deploy to Device +- Python Modules for Deploying to Device - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` - Python Modules for Simulation - - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** + - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on the prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** - Playsound : `pip install playsound` - Pywin32 : `pip install pywin32` - **Note:** This is only needed for Windows computers. diff --git a/gulpfile.js b/gulpfile.js index d5cb8cd27..3c106798d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -25,7 +25,7 @@ const languages = [{ folderName: "en", id: "en" }]; gulp.task("clean", () => { return del( [ - "out/!(python_libs)", + "out/*", "package.nls.*.json", "../../dist/*0.0.0-UNTRACKEDVERSION.vsix" ], @@ -37,7 +37,6 @@ const pythonToMove = [ "./src/adafruit_circuitplayground/*.*", "./src/*.py", "./src/requirements.txt", - "./src/requirements-windows.txt" ]; gulp.task("python-compile", () => { diff --git a/locales/en/out/constants.i18n.json b/locales/en/out/constants.i18n.json index 40744b520..c711316ef 100644 --- a/locales/en/out/constants.i18n.json +++ b/locales/en/out/constants.i18n.json @@ -9,6 +9,7 @@ "dialogResponses.installNow": "Install Now", "dialogResponses.dontInstall": "Don't Install", "dialogResponses.tutorials": "Tutorials on Adafruit", + "dialogResponses.readInstall": "Read installation docs", "error.debuggerServerInitFailed": "Warning : The Debugger Server cannot be opened. Please try to free the port {0} if it's already in use or select another one in your Settings 'Device Simulator Express: Debugger Server Port' and start another debug session.\n You can still debug your code but you won't be able to use the Simulator.", "error.debuggingSessionInProgress": "[ERROR] A debugging session is currently in progress, please stop it before running your code. \n", "error.incorrectFileNameForDevice": "[ERROR] Can\\'t deploy to your Circuit Playground Express device, please rename your file to \"code.py\" or \"main.py\". \n", diff --git a/src/constants.ts b/src/constants.ts index 21d8c8060..4fe0e12c2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -46,7 +46,7 @@ export const CONSTANTS = { "[ERROR] A debugging session is currently in progress, please stop it before running your code. \n" ), DEPENDENCY_DOWNLOAD_ERROR: - "Package downloads failed. Some functionality may not work. ", + "Package downloads failed. Some functionality may not work. Try restarting the simulator or review the installation docs.", FAILED_TO_OPEN_SERIAL_PORT: (port: string): string => { return localize( "error.failedToOpenSerialPort", @@ -103,6 +103,10 @@ export const CONSTANTS = { "Webview sent an unexpected message" ) }, + FILESYSTEM: { + OUTPUT_DIRECTORY: "out", + PYTHON_LIBS_DIR: "python_libs" + }, INFO: { ARE_YOU_SURE: localize( "info.areYouSure", @@ -205,6 +209,7 @@ export const CONSTANTS = { "https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/tree/master/examples", HELP: "https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart", + INSTALL: "https://github.com/microsoft/vscode-python-devicesimulator/blob/dev/docs/install.md", PRIVACY: "https://www.adafruit.com/privacy", TUTORIALS: "https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/circuit-playground-express-library" @@ -361,6 +366,9 @@ export namespace DialogResponses { export const YES: MessageItem = { title: localize("dialogResponses.Yes", "Yes") }; + export const READ_INSTALL_MD: MessageItem = { + title: localize("dialogResponses.readInstall", "Read installation docs") + }; } export const CPX_CONFIG_FILE = path.join(".vscode", "cpx.json"); diff --git a/src/extension.ts b/src/extension.ts index 0a523c3f8..e80101854 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -108,7 +108,7 @@ export async function activate(context: vscode.ExtensionContext) { { // Only allow the webview to access resources in our extension's media directory localResourceRoots: [ - vscode.Uri.file(path.join(context.extensionPath, "out")) + vscode.Uri.file(path.join(context.extensionPath, CONSTANTS.FILESYSTEM.OUTPUT_DIRECTORY)) ], enableScripts: true } @@ -412,7 +412,7 @@ export async function activate(context: vscode.ExtensionContext) { currentPanel.webview.postMessage({ command: "activate-play" }); childProcess = cp.spawn(pythonExecutableName, [ - utils.getPathToScript(context, "out", "process_user_code.py"), + utils.getPathToScript(context, CONSTANTS.FILESYSTEM.OUTPUT_DIRECTORY, "process_user_code.py"), currentFileAbsPath, JSON.stringify({ enable_telemetry: utils.getTelemetryState() }) ]); @@ -549,7 +549,7 @@ export async function activate(context: vscode.ExtensionContext) { ); const deviceProcess = cp.spawn(pythonExecutableName, [ - utils.getPathToScript(context, "out", "device.py"), + utils.getPathToScript(context, CONSTANTS.FILESYSTEM.OUTPUT_DIRECTORY, "device.py"), currentFileAbsPath ]); diff --git a/src/extension_utils/utils.ts b/src/extension_utils/utils.ts index a4eaa72a9..07645857f 100644 --- a/src/extension_utils/utils.ts +++ b/src/extension_utils/utils.ts @@ -18,6 +18,7 @@ import { import { CPXWorkspace } from "../cpxWorkspace"; import * as cp from "child_process"; import * as util from "util"; +import * as open from "open"; const exec = util.promisify(cp.exec); // tslint:disable-next-line: export-name @@ -258,7 +259,7 @@ export const checkConfig = (configName: string): boolean => { export const checkPythonDependencies = async (context: vscode.ExtensionContext, pythonExecutable: string) => { let hasInstalledDependencies: boolean = false; - const pathToLibs: string = getPathToScript(context, "out", "python_libs"); + const pathToLibs: string = getPathToScript(context, CONSTANTS.FILESYSTEM.OUTPUT_DIRECTORY, CONSTANTS.FILESYSTEM.PYTHON_LIBS_DIR); if (checkPipDependency() && checkPythonDependency()) { if (checkConfig(CONFIG.SHOW_DEPENDENCY_INSTALL)) { // check if ./out/python_libs exists; if not, the dependencies @@ -304,20 +305,27 @@ export const installPythonDependencies = async (context: vscode.ExtensionContext let installed: boolean = false; try { vscode.window.showInformationMessage(CONSTANTS.INFO.INSTALLING_PYTHON_DEPENDENCIES); - - // only use requirements file with pywin32 if on windows - const requirementsFileName = (process.platform === "win32") ? "requirements-windows.txt" : "requirements.txt"; - const requirementsPath: string = getPathToScript(context, "out", requirementsFileName); + const requirementsPath: string = getPathToScript(context, CONSTANTS.FILESYSTEM.OUTPUT_DIRECTORY, "requirements.txt"); + // run command to download dependencies to out/python_libs const { stdout } = await exec(`${pythonExecutable} -m pip install -r ${requirementsPath} -t ${pathToLibs}`); + console.log(stdout); installed = true; - console.log(stdout) vscode.window.showInformationMessage(CONSTANTS.INFO.SUCCESSFUL_INSTALL); } catch (err) { - vscode.window.showErrorMessage(CONSTANTS.ERROR.DEPENDENCY_DOWNLOAD_ERROR); - console.error(err) + + vscode.window + .showErrorMessage(CONSTANTS.ERROR.DEPENDENCY_DOWNLOAD_ERROR, + DialogResponses.READ_INSTALL_MD) + .then((selection: vscode.MessageItem | undefined) => { + if (selection === DialogResponses.READ_INSTALL_MD) { + open(CONSTANTS.LINKS.INSTALL); + } + }); + + console.error(err); installed = false; } return installed diff --git a/src/requirements-windows.txt b/src/requirements-windows.txt deleted file mode 100644 index 9e30ba279..000000000 --- a/src/requirements-windows.txt +++ /dev/null @@ -1,6 +0,0 @@ -playsound==1.2.2 -pytest==5.0.1 -applicationinsights==0.11.9 -python-socketio==4.3.1 -requests==2.22.0 -pywin32>=224 diff --git a/src/requirements.txt b/src/requirements.txt index 29e459465..c2fd41ef2 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -3,3 +3,4 @@ pytest==5.0.1 applicationinsights==0.11.9 python-socketio==4.3.1 requests==2.22.0 +pywin32==227; platform_system == "Windows" \ No newline at end of file From 528c1230c1dd439fc4a6fd86ee3148a970db1148 Mon Sep 17 00:00:00 2001 From: andreamah Date: Tue, 21 Jan 2020 17:13:51 -0800 Subject: [PATCH 4/4] incorporating more PR comments for clarity --- README.md | 7 +++---- docs/developers-setup.md | 19 +++++++++---------- docs/install.md | 25 ++++++++++++------------- src/constants.ts | 2 +- src/extension_utils/utils.ts | 2 +- 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 33adc5c4f..152c68147 100644 --- a/README.md +++ b/README.md @@ -43,14 +43,11 @@ You will be prompted to install the Python dependencies during the first use. - _**[Python 3.7.4](https://www.python.org/downloads/)**_: Make sure you've added python and pip to your PATH in your environment variables. (1) - _**[Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python)**_: This will be installed automatically from the marketplace when you install Device Simulator Express. -- Python Modules for Deploying to Device - - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` - - Python Modules for Simulation - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following Python modules should be downloaded when you select "yes" on the prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** - Playsound : `pip install playsound` - Pywin32 : `pip install pywin32` - - **Note:** This is only needed for Windows computers. + - On Windows, you need to use the above command in the console to manually install pywin32. - Python-Socketio : `pip install python-socketio` - Requests : `pip install requests` - Application Insights: `pip install applicationinsights` @@ -101,6 +98,8 @@ Before deploying the python code to your CPX device, you need to format your dev 2. Download the lastest version of the cpx library (link: https://learn.adafruit.com/welcome-to-circuitpython/circuitpython-libraries). **_Note:_** Make sure you name your file main.py or code.py: the device automatically runs the first file that is likely named. +Then, if you are on Windows, you will also need to install the Python Pywin32 package. Use the following command in the console: `pip install pywin32` + !["Deploy to Device" example](https://www.microsoft.com/en-us/garage/wp-content/uploads/sites/5/2019/08/deployToBoard.png) ### 5. Use the Serial Monitor for your Adafruit CPX device(available Windows and Mac only) diff --git a/docs/developers-setup.md b/docs/developers-setup.md index c210fc948..12e3eef26 100644 --- a/docs/developers-setup.md +++ b/docs/developers-setup.md @@ -13,19 +13,18 @@ - **NOTE :** Make sure pip is added to your environment variables as well (for example it could be found at : `c:\users\<...>\appdata\local\programs\python\python37\lib\site-packages\pip`) - Run in a console `python -m pip install --upgrade pip` - -* Python Modules for Deploying to Device - - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` -* Python Modules for Simulation +* Python Modules - **Note:** On extension activation, you will be prompted with a popup asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on the prompt message. - - playsound - - pytest - - python-socketio - - requests - - applicationinsights - pywin32 **(on Windows only)** - + - On Windows, you need to use the following command in the console to manually install pywin32: `pip install pywin32` + - *playsound* + - *pytest* + - *python-socketio* + - *requests* + - *applicationinsights* + + *italics*: used in simulation mode only * VS Code * Python extension for VS Code (download from VS Code market place) diff --git a/docs/install.md b/docs/install.md index 2e995ece3..8a8421d6e 100644 --- a/docs/install.md +++ b/docs/install.md @@ -22,19 +22,18 @@ _Note: You need to install all the dependencies in order to use the extension._ _(Note: the easiest way to do it might be when you install Python, you can select the "Add to PATH" option directly. Otherwise you can search how to insert it manually, but make sure that when you type `python` (or `python3.7`) in a terminal, the command is recognized.)_ - [Python VS Code extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) - **Note:** This extension is installed automatically from the marketplace when you install our extension - -- Python Modules for Deploying to Device - - If you're on Windows, use the following command in the console to install pywin32: `pip install pywin32` - -- Python Modules for Simulation - - **Note:** On extension activation, you will be prompted with a popup message asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on the prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** - - Playsound : `pip install playsound` - - Pywin32 : `pip install pywin32` - - **Note:** This is only needed for Windows computers. - - Python-Socketio : `pip install python-socketio` - - Requests : `pip install requests` - - Application Insights: `pip install applicationinsights` - + +* Python Modules + - **Note:** On extension activation, you will be prompted with a popup asking if you want the modules to be automatically installed for you. The following python modules should be downloaded when you select "yes" on the prompt message. **If modules are not installed correctly, please use the "pip install" commands listed below.** + - pywin32 **(on Windows only)**: `pip install pywin32` + - On Windows, you need to use the above command in the console to manually install pywin32. + - *playsound*: `pip install playsound` + - *pytest*: `pip install pytest` + - *python-socketio*: `pip install python-socketio` + - *requests*: `pip install requests` + - *applicationinsights*: `pip install applicationinsights` + + *italics*: used in simulation mode only ## How to use the Extension - [How to use the Extension](/docs/how-to-use.md) diff --git a/src/constants.ts b/src/constants.ts index 4fe0e12c2..f9f458153 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -46,7 +46,7 @@ export const CONSTANTS = { "[ERROR] A debugging session is currently in progress, please stop it before running your code. \n" ), DEPENDENCY_DOWNLOAD_ERROR: - "Package downloads failed. Some functionality may not work. Try restarting the simulator or review the installation docs.", + "Package downloads failed. Some functionalities may not work. Try restarting the simulator or review the installation docs.", FAILED_TO_OPEN_SERIAL_PORT: (port: string): string => { return localize( "error.failedToOpenSerialPort", diff --git a/src/extension_utils/utils.ts b/src/extension_utils/utils.ts index 07645857f..9638d8e88 100644 --- a/src/extension_utils/utils.ts +++ b/src/extension_utils/utils.ts @@ -310,7 +310,7 @@ export const installPythonDependencies = async (context: vscode.ExtensionContext // run command to download dependencies to out/python_libs const { stdout } = await exec(`${pythonExecutable} -m pip install -r ${requirementsPath} -t ${pathToLibs}`); - console.log(stdout); + console.info(stdout); installed = true; vscode.window.showInformationMessage(CONSTANTS.INFO.SUCCESSFUL_INSTALL);