Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
exclude docs/*
exclude tests/*
exclude tests/*
exclude install/*
129 changes: 129 additions & 0 deletions docs/install/InstallWizard.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
1 change: 1 addition & 0 deletions docs/install/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main-Class: InstallWizard
12 changes: 12 additions & 0 deletions docs/install/install.bat
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions docs/install/install.ps1
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions docs/install/install.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/source/guides/Install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/sharktide/restructuredpython/releases/v1.0.0/>`_, (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:
Expand Down