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

Get this working on Windows #71

Open
simonw opened this issue Sep 8, 2021 · 8 comments
Open

Get this working on Windows #71

simonw opened this issue Sep 8, 2021 · 8 comments

Comments

@simonw
Copy link
Owner

simonw commented Sep 8, 2021

Lots to consider here:

  • I need a Windows/Electron development environment
  • Which bits need to work differently?
  • How does bundling a Python environment for Windows work? On macOS I could stick the whole thing in /Application/Datasette.app/Content/Resources - what do I do on Windows?
  • How does Windows code signing work?
  • How do I get GitHub Actions to do that for me?
@simonw
Copy link
Owner Author

simonw commented Sep 15, 2021

diff --git a/main.js b/main.js
index 02ac6aa..9912b26 100644
--- a/main.js
+++ b/main.js
@@ -190,7 +190,7 @@ class DatasetteServer {
   async startOrRestart() {
     const venv_dir = await this.ensureVenv();
     await this.ensurePackagesInstalled();
-    const datasette_bin = path.join(venv_dir, "bin", "datasette");
+    const datasette_bin = path.join(venv_dir, "Scripts", "datasette.exe");
     let backupPath = null;
     if (this.process) {
       // Dump temporary to restore later
@@ -319,8 +319,8 @@ class DatasetteServer {
       process.env.HOME,
       ".datasette-app",
       "venv",
-      "bin",
-      "pip"
+      "Scripts",
+      "pip.exe"
     );
     await this.execCommand(pip_binary, [
       "install",
@@ -334,8 +334,8 @@ class DatasetteServer {
       process.env.HOME,
       ".datasette-app",
       "venv",
-      "bin",
-      "pip"
+      "Scripts",
+      "pip.exe"
     );
     await this.execCommand(pip_binary, [
       "uninstall",
@@ -371,7 +371,7 @@ class DatasetteServer {
       // Check Python interpreter still works, using
       // ~/.datasette-app/venv/bin/python3.9 --version
       // See https://github.com/simonw/datasette-app/issues/89
-      const venv_python = path.join(venv_dir, "bin", "python3.9");
+      const venv_python = path.join(venv_dir, "Scripts", "python.exe");
       try {
         await this.execCommand(venv_python, ["--version"]);
         shouldCreateVenv = false;
@@ -392,7 +392,7 @@ class DatasetteServer {
     for (const [name, requiredVersion] of Object.entries(minPackageVersions)) {
       needsInstall.push(`${name}>=${requiredVersion}`);
     }
-    const pip_path = path.join(venv_dir, "bin", "pip");
+    const pip_path = path.join(venv_dir, "Scripts", "pip.exe");
     try {
       await this.execCommand(
         pip_path,
@@ -456,6 +456,8 @@ function findPython() {
     path.join(process.resourcesPath, "python", "bin", "python3.9"),
     // In development
     path.join(__dirname, "python", "bin", "python3.9"),
+    // On Windows
+    path.join(__dirname, "python", "python.exe"),
   ];
   for (const path of possibilities) {
     if (fs.existsSync(path)) {

@simonw
Copy link
Owner Author

simonw commented Sep 15, 2021

And I downloaded and extracted cpython-3.9.6-x86_64-pc-windows-msvc-shared-install_only-20210724T1424.tar.gz from https://github.com/indygreg/python-build-standalone/releases/tag/20210724

@simonw
Copy link
Owner Author

simonw commented Sep 15, 2021

509E60FE-CEDF-400C-9677-14F88504770C
F69F324A-35AE-4C40-ABD7-EF225252089F
02DCDE7F-FAF0-4629-AAFC-1193D6B5DE5E
6C54A217-3523-41AB-993B-DC19D6A3C3A0
69C86A99-C895-4E1A-94C4-421F9D8DF697

@simonw
Copy link
Owner Author

simonw commented Sep 15, 2021

Here's the Electron build documentation for Windows, which is pretty thin: https://www.electron.build/configuration/win#WindowsConfiguration-target

@rdmolony
Copy link

rdmolony commented Sep 22, 2021

hey @simonw, I saw Jupyter Lab have a cross-platform app running on Electron and thought of this PR (love datasette btw)

code signing on Windows [WIP]: jupyterlab/jupyterlab-desktop#202
Github Action to publish (and build?) installers: https://github.com/jupyterlab/jupyterlab_app/blob/50ce277c2abf844c5eb70cc4aa633653c14c416f/.github/workflows/publish.yml

@simonw
Copy link
Owner Author

simonw commented Sep 22, 2021

That's a fantastic example, thank you! Looks like the Windows build is generated using this script: https://github.com/jupyterlab/jupyterlab_app/blob/50ce277c2abf844c5eb70cc4aa633653c14c416f/package.json#L25

@simonw
Copy link
Owner Author

simonw commented Aug 6, 2022

@simonw
Copy link
Owner Author

simonw commented Jan 3, 2023

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

No branches or pull requests

2 participants