Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c727f92
fix style
anssakthi Mar 14, 2024
157a87c
Update ci_cd.yml
anssakthi Mar 14, 2024
a2636c8
fix style
anssakthi Mar 15, 2024
e8a9691
Merge branch 'feature/remove-python-installations' of https://github.…
anssakthi Mar 15, 2024
0247c26
adding warning/note for pre-compiled python version on linux
tusharbana-ansys Mar 15, 2024
e872bc0
minor
tusharbana-ansys Mar 15, 2024
9c8d7ae
Merge remote-tracking branch 'origin/main' into feature/remove-python…
anssakthi Mar 15, 2024
9b04cb8
fix style
anssakthi Mar 15, 2024
6fdc0fe
centos & fedora specific changes
tusharbana-ansys Mar 19, 2024
3763adb
fix style
anssakthi Mar 20, 2024
c95f96a
Merge branch 'main' into feature/remove-python-installations
anssakthi Mar 20, 2024
ad6fdfe
fix style
anssakthi Mar 20, 2024
8fc406c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 20, 2024
f0663ae
Update ci_cd.yml
anssakthi Mar 20, 2024
1e0989b
fix style
anssakthi Mar 20, 2024
3550842
Merge branch 'feature/remove-python-installations' of https://github.…
anssakthi Mar 20, 2024
8b06509
fix style
anssakthi Mar 21, 2024
a355f70
centos/fedora uninstaller script fix
tusharbana-ansys Mar 21, 2024
3156b72
fix style
tusharbana-ansys Mar 21, 2024
85f4a84
fix style
tusharbana-ansys Mar 21, 2024
70f7426
Update src/ansys/tools/installer/installed_table.py
RobPasMue Mar 27, 2024
4b8eb06
Update src/ansys/tools/installer/main.py
RobPasMue Mar 27, 2024
5d148df
Merge branch 'main' into feature/remove-python-installations
RobPasMue Mar 27, 2024
5a6f3b7
fix style
anssakthi Mar 28, 2024
f57a2f4
Update ci_cd.yml
anssakthi Mar 28, 2024
3ec3089
fix style
anssakthi Apr 1, 2024
6298a11
fix style
anssakthi Apr 1, 2024
26c8f83
fix style
anssakthi Apr 1, 2024
c75f8b7
fix style
anssakthi Apr 1, 2024
d55dfe2
Merge remote-tracking branch 'origin/main' into vcode-enablement
anssakthi Apr 2, 2024
92a7c2f
fix style
anssakthi Apr 2, 2024
11c4131
fix style
anssakthi Apr 2, 2024
0c35e2a
fix style
anssakthi Apr 2, 2024
7a492e8
fix style
anssakthi Apr 8, 2024
6aa8c26
Update ci_cd.yml
anssakthi Apr 8, 2024
bcc25fa
Merge branch 'main' into vcode-enablement
anssakthi Apr 8, 2024
63f2916
Update ci_cd.yml
anssakthi Apr 10, 2024
4bba9c2
Update src/ansys/tools/installer/vscode.py
anssakthi Apr 10, 2024
b28d15b
Update doc/source/installer.rst
anssakthi Apr 10, 2024
85f0ebb
Apply suggestions from code review
anssakthi Apr 10, 2024
f7b5228
wip
anssakthi Apr 10, 2024
5911599
wip
anssakthi Apr 10, 2024
3cb8a1d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2024
630ddc8
Merge branch 'main' into vcode-enablement
RobPasMue Apr 15, 2024
de72230
wip
anssakthi Apr 15, 2024
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
2 changes: 2 additions & 0 deletions doc/source/installer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ On the ``Launching options`` section, the following options are available:

* ``Launch Console``: this option starts a console window with the command ``python`` pointing
towards your selected Python environment.
* ``Launch VSCode``: this option starts a ``Visual Studio Code``. If ``Visual Studio Code`` is
not installed, then the ``Ansys Python Manager`` provides instructions to install it.
* ``Launch JupyterLab``: this option starts a ``JupyterLab`` session. If ``JupyterLab`` is
not installed, then the ``Ansys Python Manager`` installs it for you.
* ``Launch Jupyter Notebook``: this option starts a ``Jupyter Notebook`` session. If
Expand Down
20 changes: 13 additions & 7 deletions setup.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ OutFile "dist\${OUTFILE_NAME}"
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_LICENSE "${LICENSE_FILE}"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
!include "uninstall.nsi"

Function CreateDesktopShortCut
CreateShortCut "$desktop\Ansys Python Manager.lnk" "$INSTDIR\Ansys Python Manager.exe"
FunctionEnd

!define MUI_FINISHPAGE_RUN "$INSTDIR\Ansys Python Manager.exe"
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION "CreateDesktopShortCut"
!insertmacro MUI_PAGE_FINISH

Function .onInit
!insertmacro MULTIUSER_INIT
FunctionEnd
Expand Down Expand Up @@ -58,12 +68,6 @@ Section "Ansys Python Manager" SEC01

WriteUninstaller "$INSTDIR\uninstall.exe"

; start after install
Exec "$INSTDIR\Ansys Python Manager.exe"

; After installation succeeded, wait and close
Sleep 5000
Quit
SectionEnd

; Define the uninstaller section
Expand All @@ -74,6 +78,7 @@ Section "Uninstall" SEC02
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
Delete "$SMPROGRAMS\Ansys Python Manager\Ansys Python Manager.lnk"
RMDir "$SMPROGRAMS\Ansys Python Manager"
Delete "$desktop\Ansys Python Manager.lnk"
SectionEnd

Icon "dist\ansys_python_manager\_internal\assets\pyansys_icon.ico"
Expand All @@ -90,3 +95,4 @@ FunctionEnd
; Call the MUI2 OneClick plugin
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
4 changes: 2 additions & 2 deletions src/ansys/tools/installer/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@


class Configure(QtWidgets.QWidget):
"""Manage Virtual Environment w.r.t Python versions tab."""
"""Configure tab."""

def __init__(self, parent):
"""Initialize this tab."""
"""Initialize this class."""
try:
super().__init__()
self._parent = parent
Expand Down
9 changes: 9 additions & 0 deletions src/ansys/tools/installer/installed_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
run_linux_command,
run_linux_command_conda,
)
from ansys.tools.installer.vscode import VSCode

ALLOWED_FOCUS_EVENTS = [QtCore.QEvent.Type.WindowActivate, QtCore.QEvent.Type.Show]
LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -251,6 +252,10 @@ def __init__(self, parent=None):
self.button_launch_cmd.clicked.connect(self.launch_cmd)
hbox.addWidget(self.button_launch_cmd)

self.button_launch_cmd = QtWidgets.QPushButton("Launch VSCode")
self.button_launch_cmd.clicked.connect(self.launch_vscode)
hbox.addWidget(self.button_launch_cmd)

self.button_launch_lab = QtWidgets.QPushButton("Launch Jupyterlab")
self.button_launch_lab.clicked.connect(self.launch_jupyterlab)
hbox.addWidget(self.button_launch_lab)
Expand Down Expand Up @@ -365,6 +370,10 @@ def launch_jupyterlab(self):
self._update_pck_mnger()
self.launch_cmd(f"python -m jupyter lab || {error_msg}")

def launch_vscode(self):
"""Launch VSCode."""
vscode = VSCode(self)

def launch_jupyter_notebook(self):
"""Launch Jupyter Notebook."""
# handle errors
Expand Down
188 changes: 188 additions & 0 deletions src/ansys/tools/installer/vscode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# Copyright (C) 2023 - 2024 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""VS code launch window."""
import os

from PySide6 import QtCore, QtGui, QtWidgets

from ansys.tools.installer.constants import ANSYS_FAVICON, USER_PATH


class VSCode(QtWidgets.QWidget):
"""VS code launch window."""

def __init__(self, parent):
"""Initialize this class."""
try:
super().__init__()
self._parent = parent
if self.is_vscode_installed():
self._parent.vscode_window = QtWidgets.QWidget()
self._parent.vscode_window.move(
self._parent.vscode_window.frameGeometry().center()
)
vscode_window_label = QtWidgets.QLabel()
vscode_window_label.setText("Configuration")
vscode_window_label.setTextFormat(QtCore.Qt.TextFormat.RichText)
vscode_window_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignJustify)
vscode_window_label.setWordWrap(True)

vscode_layout = QtWidgets.QVBoxLayout()

# Group 1: Configure default Virtual Environment creation path
vscode_window_path_config = QtWidgets.QGroupBox(
"VS Code open directory:"
)
vscode_window_path_config_layout = QtWidgets.QVBoxLayout()
vscode_window_path_config_layout.setContentsMargins(10, 20, 10, 20)
vscode_window_path_config.setLayout(vscode_window_path_config_layout)

# ---> Add box
self.vscode_window_path_config_edit = QtWidgets.QLineEdit()
self.vscode_window_path_config_edit.setText(USER_PATH)
vscode_window_path_config_layout.addWidget(
self.vscode_window_path_config_edit
)

self.vscode_warning_text = QtWidgets.QLabel()
self.vscode_warning_text.setAlignment(
QtCore.Qt.AlignmentFlag.AlignJustify
)
self.vscode_warning_text.setWordWrap(True)
vscode_window_path_config_layout.addWidget(self.vscode_warning_text)

# Finally, add all the previous widgets to the global layout
vscode_layout.addWidget(vscode_window_path_config)

vscode_window_button_open = QtWidgets.QPushButton("Open")
vscode_window_button_open.clicked.connect(
lambda x: self._pop_up("Do you want to open?", self._open_vscode)
)
vscode_window_button_close = QtWidgets.QPushButton("Close")
vscode_window_button_close.clicked.connect(
lambda x: self._pop_up("Do you want to close?", self._close_all)
)

vscode_window_layout_1 = QtWidgets.QHBoxLayout()
vscode_window_layout_1.addWidget(vscode_window_label)
vscode_window_layout_2 = QtWidgets.QHBoxLayout()
vscode_window_layout_2.addWidget(vscode_window_button_open)
vscode_window_layout_2.addWidget(vscode_window_button_close)

vscode_window_layout = QtWidgets.QVBoxLayout()
vscode_window_layout.addLayout(vscode_window_layout_1)
vscode_window_layout.addLayout(vscode_layout)
vscode_window_layout.addLayout(vscode_window_layout_2)
self._parent.vscode_window.setLayout(vscode_window_layout)

self._parent.vscode_window.setWindowTitle("Configuration")
self._parent.vscode_window.setWindowIcon(QtGui.QIcon(ANSYS_FAVICON))
self._parent.vscode_window.resize(500, 40)
self._parent.vscode_window.show()
else:
msg = QtWidgets.QMessageBox()
msg.setTextFormat(QtCore.Qt.TextFormat.RichText)
msg.warning(
self,
"VS Code Launch Error",
f"Failed to launch vscode. Try reinstalling code by following this <a href='https://code.visualstudio.com/download'>link</a>",
)

except Exception as e:
self._parent.show_error(str(e))

def _open_vscode(self):
"""Open VS code from path."""
# handle errors
path = self.vscode_window_path_config_edit.text().strip()
if os.path.exists(path):
error_msg = "echo Failed to launch vscode. Try reinstalling code by following this link https://code.visualstudio.com/download"
self._parent.launch_cmd(f"code {path} && exit 0 || {error_msg}")

self.user_confirmation_form.close()
self._parent.vscode_window.close()
else:
self.vscode_warning_text.setText(
f"""{path} does not exist. Provide a valid path."""
)
self.vscode_warning_text.setStyleSheet(
"""
color: rgb(255, 0, 0);
"""
)
self.user_confirmation_form.close()

def _close_all(self):
"""Close all the pop-up window."""
self.user_confirmation_form.close()
self._parent.vscode_window.close()

def _pop_up(self, message, call_back):
"""Launch the confirmation pop-up window."""
self.user_confirmation_form = QtWidgets.QWidget()
self.user_confirmation_form.move(
self.user_confirmation_form.frameGeometry().center()
)
user_confirmation_label = QtWidgets.QLabel()
user_confirmation_label.setText(message)
user_confirmation_label.setOpenExternalLinks(True)
user_confirmation_label.setTextFormat(QtCore.Qt.TextFormat.RichText)
user_confirmation_label.setAlignment(QtCore.Qt.AlignmentFlag.AlignJustify)
user_confirmation_label.setWordWrap(True)

user_confirmation_layout_horizontal = QtWidgets.QHBoxLayout()
user_confirmation_yes_button = QtWidgets.QPushButton("Yes")
user_confirmation_yes_button.clicked.connect(call_back)
user_confirmation_no_button = QtWidgets.QPushButton("No")
user_confirmation_no_button.clicked.connect(self.user_confirmation_form.close)
user_confirmation_layout = QtWidgets.QVBoxLayout()
user_confirmation_layout.addWidget(user_confirmation_label)
user_confirmation_layout_horizontal.addWidget(user_confirmation_yes_button)
user_confirmation_layout_horizontal.addWidget(user_confirmation_no_button)
user_confirmation_layout.addLayout(user_confirmation_layout_horizontal)
self.user_confirmation_form.setLayout(user_confirmation_layout)
self.user_confirmation_form.setWindowTitle("Confirmation")
icon = QtGui.QIcon(ANSYS_FAVICON)
self.user_confirmation_form.setWindowIcon(icon)
self.user_confirmation_form.resize(400, 40)
self.user_confirmation_form.setWindowFlag(
QtCore.Qt.WindowCloseButtonHint, False
)
self.user_confirmation_form.show()

def is_vscode_installed(self):
"""Check if VSCode is installed or not.

Returns
-------
bool
Whether VSCode is installed or not.
"""
try:
return_val = os.system("code --version")
if return_val == 0:
return True
else:
return False
except:
return False