From a01f091fb3574bd3dcb57b67befbb12557f4aa88 Mon Sep 17 00:00:00 2001 From: sharktide Date: Thu, 27 Mar 2025 12:22:36 -0400 Subject: [PATCH 1/3] Add install wizards --- docs/source/guides/Install.rst | 1 + install/InstallWizard.java | 129 +++++++++++++++++++++++++++++++++ install/MANIFEST.MF | 1 + install/install.bat | 12 +++ install/install.ps1 | 8 ++ install/install.sh | 10 +++ 6 files changed, 161 insertions(+) create mode 100644 install/InstallWizard.java create mode 100644 install/MANIFEST.MF create mode 100644 install/install.bat create mode 100644 install/install.ps1 create mode 100644 install/install.sh diff --git a/docs/source/guides/Install.rst b/docs/source/guides/Install.rst index 11331ab..c4ee819 100644 --- a/docs/source/guides/Install.rst +++ b/docs/source/guides/Install.rst @@ -3,6 +3,7 @@ Installation Guide To install and use reStructuredPython, follow the steps below: +There are two methods: Either use one of the `Installation Wizards `_, (Make sure to pick the right one for your system (.bat or .ps1 for windows, .sh for macOS/Linux, or .ps1 (again)/.jar if you have java or powershell installed) or follow the steps below. 1. **Install reStructuredPython:** Open your terminal or command prompt and run the following command to install reStructuredPython using pip: diff --git a/install/InstallWizard.java b/install/InstallWizard.java new file mode 100644 index 0000000..e91efce --- /dev/null +++ b/install/InstallWizard.java @@ -0,0 +1,129 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.InputStreamReader; + +public class InstallWizard { + public static void main(String[] args) { + // Create the main frame + JFrame frame = new JFrame("Install Wizard"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(600, 400); + frame.setLayout(new CardLayout()); // Use CardLayout for wizard-like behavior + + // Panels for wizard steps + JPanel welcomePanel = new JPanel(); + JLabel welcomeLabel = new JLabel("Welcome to the reStructuredPython Install Wizard!"); + welcomePanel.setLayout(new BorderLayout()); + welcomePanel.add(welcomeLabel, BorderLayout.NORTH); + + JPanel installationPanel = new JPanel(); + JCheckBox vscodeCheckbox = new JCheckBox("Install Visual Studio Code Extension?"); + JButton backButton = new JButton("Back"); + JButton nextButton = new JButton("Install"); + installationPanel.add(vscodeCheckbox); + installationPanel.add(backButton); + installationPanel.add(nextButton); + + JPanel installingPanel = new JPanel(); + installingPanel.setLayout(new BorderLayout()); + JTextArea logArea = new JTextArea(); + logArea.setEditable(false); + JScrollPane logScrollPane = new JScrollPane(logArea); + JLabel installingLabel = new JLabel("Installing..."); + installingPanel.add(installingLabel, BorderLayout.NORTH); + installingPanel.add(logScrollPane, BorderLayout.CENTER); + + JPanel finalPanel = new JPanel(); + JLabel finalLabel = new JLabel("Installation Complete!"); + finalPanel.add(finalLabel); + JButton finishButton = new JButton("Finish"); + finalPanel.add(finishButton); + + // Add panels to frame + frame.add(welcomePanel, "Welcome"); + frame.add(installationPanel, "Install Options"); + frame.add(installingPanel, "Installing"); + frame.add(finalPanel, "Final Step"); + + // Create a CardLayout controller + CardLayout cardLayout = (CardLayout) frame.getContentPane().getLayout(); + + // Next button action (from welcome to installation options) + JButton welcomeNextButton = new JButton("Next"); + welcomePanel.add(welcomeNextButton, BorderLayout.SOUTH); + welcomeNextButton.addActionListener(e -> cardLayout.show(frame.getContentPane(), "Install Options")); + + // Back button action (from installation options to welcome) + backButton.addActionListener(e -> cardLayout.show(frame.getContentPane(), "Welcome")); + + // Install button action (from installation options to installing) + nextButton.addActionListener(e -> { + cardLayout.show(frame.getContentPane(), "Installing"); + + new Thread(() -> { + try { + // Install the 'restructuredpython' package and show logs + ProcessBuilder pipBuilder = new ProcessBuilder("pip", "install", "--upgrade", "restructuredpython"); + Process pipProcess = pipBuilder.start(); + BufferedReader pipReader = new BufferedReader(new InputStreamReader(pipProcess.getInputStream())); + + String line; + while ((line = pipReader.readLine()) != null) { + logArea.append(line + "\n"); + } + pipProcess.waitFor(); + + logArea.append("Python package 'restructuredpython' installed successfully!\n"); + + // If checkbox is selected, install VS Code extension + if (vscodeCheckbox.isSelected()) { + String os = System.getProperty("os.name").toLowerCase(); + ProcessBuilder vscodeBuilderWin = new ProcessBuilder( + "cmd.exe", + "/c", + "code --install-extension RihaanMeher.restructuredpython --force" + ); + ProcessBuilder vscodeBuilderUnix = new ProcessBuilder( + "bash", + "-c", + "code --install-extension RihaanMeher.restructuredpython --force" + ); + + Process vscodeProcess = null; + if (os.contains("win")) { + logArea.append("Running on Windows\n"); + vscodeProcess = vscodeBuilderWin.start(); + } else if (os.contains("mac") || os.contains("nix") || os.contains("nux") || os.contains("aix")) { + logArea.append("Running on macOS/Linux\n"); + vscodeProcess = vscodeBuilderUnix.start(); + } else { + throw new Exception("Unknown OS"); + } + + BufferedReader vscodeReader = new BufferedReader(new InputStreamReader(vscodeProcess.getInputStream())); + while ((line = vscodeReader.readLine()) != null) { + logArea.append(line + "\n"); + } + vscodeProcess.waitFor(); + + logArea.append("VS Code extension 'RihaanMeher.restructuredpython' installed successfully!\n"); + } + + // Move to final step + SwingUtilities.invokeLater(() -> cardLayout.show(frame.getContentPane(), "Final Step")); + } catch (Exception ex) { + SwingUtilities.invokeLater(() -> logArea.append("Error during installation: " + ex.getMessage() + "\n")); + } + }).start(); + }); + + // Finish button action (exit the wizard) + finishButton.addActionListener(e -> System.exit(0)); + + // Show the frame + frame.setVisible(true); + } +} diff --git a/install/MANIFEST.MF b/install/MANIFEST.MF new file mode 100644 index 0000000..a20365b --- /dev/null +++ b/install/MANIFEST.MF @@ -0,0 +1 @@ +Main-Class: InstallWizard diff --git a/install/install.bat b/install/install.bat new file mode 100644 index 0000000..20edeba --- /dev/null +++ b/install/install.bat @@ -0,0 +1,12 @@ +@echo off +echo Installing... +pip install --upgrade restructuredpython +set /p input= Install Visual Studio Code extension? (y/n) +IF %input%==y ( + echo Sup + code --install-extension RihaanMeher.restructuredpython --force +) +IF %input%==Y ( + code --install-extension RihaanMeher.restructuredpython --force +) +PAUSE \ No newline at end of file diff --git a/install/install.ps1 b/install/install.ps1 new file mode 100644 index 0000000..c574f3f --- /dev/null +++ b/install/install.ps1 @@ -0,0 +1,8 @@ +Write-Host "Installing..." +pip install --upgrade restructuredpython + +$input = Read-Host -Prompt "Install Visual Studio Code extension? (y/n)" +if ($input -eq "y" -or $input -eq "Y") { + Write-Host "Installing extension..." + code --install-extension RihaanMeher.restructuredpython --force +} \ No newline at end of file diff --git a/install/install.sh b/install/install.sh new file mode 100644 index 0000000..65f5962 --- /dev/null +++ b/install/install.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Installing..." +pip install --upgrade restructuredpython + +read -p "Install Visual Studio Code extension? (y/n): " input +if [[ "$input" == "y" || "$input" == "Y" ]]; then + echo "Installing extension..." + code --install-extension RihaanMeher.restructuredpython --force +fi From f96ccc9f690747fbcf535a2b62d832b1c7a056b1 Mon Sep 17 00:00:00 2001 From: sharktide Date: Thu, 27 Mar 2025 12:25:40 -0400 Subject: [PATCH 2/3] exclude install dir --- MANIFEST.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index e3cd5ce..e2a350c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,3 @@ exclude docs/* -exclude tests/* \ No newline at end of file +exclude tests/* +exclude install/* \ No newline at end of file From 6f8843e10161035bc41d7159c5d13f709e4459c9 Mon Sep 17 00:00:00 2001 From: sharktide Date: Thu, 27 Mar 2025 12:31:14 -0400 Subject: [PATCH 3/3] move install to docs --- {install => docs/install}/InstallWizard.java | 0 {install => docs/install}/MANIFEST.MF | 0 {install => docs/install}/install.bat | 0 {install => docs/install}/install.ps1 | 0 {install => docs/install}/install.sh | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename {install => docs/install}/InstallWizard.java (100%) rename {install => docs/install}/MANIFEST.MF (100%) rename {install => docs/install}/install.bat (100%) rename {install => docs/install}/install.ps1 (100%) rename {install => docs/install}/install.sh (100%) diff --git a/install/InstallWizard.java b/docs/install/InstallWizard.java similarity index 100% rename from install/InstallWizard.java rename to docs/install/InstallWizard.java diff --git a/install/MANIFEST.MF b/docs/install/MANIFEST.MF similarity index 100% rename from install/MANIFEST.MF rename to docs/install/MANIFEST.MF diff --git a/install/install.bat b/docs/install/install.bat similarity index 100% rename from install/install.bat rename to docs/install/install.bat diff --git a/install/install.ps1 b/docs/install/install.ps1 similarity index 100% rename from install/install.ps1 rename to docs/install/install.ps1 diff --git a/install/install.sh b/docs/install/install.sh similarity index 100% rename from install/install.sh rename to docs/install/install.sh