Skip to content

Commit 2b9890b

Browse files
authored
Missing extra packages install (#6)
* Adding skeleton * Missing statements * WIP - installing extra packages * Removing "Packages" section from Windows installer * Resizing window * Adding installation in managing Python env tab * List packages button * Adding sections and margins * Improving docs
1 parent 9420034 commit 2b9890b

File tree

3 files changed

+60
-62
lines changed

3 files changed

+60
-62
lines changed

doc/source/installer.rst

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,26 +53,6 @@ Regarding the available Python versions, users can select among the following on
5353

5454
In the case of having selected ``Conda (miniforge)``, only Python 3.10 is available.
5555

56-
Finally, the following extra packages are available for installing:
57-
58-
* ``Defaults``: by selecting this option, your clean Python install also provides you with
59-
the latest compatible versions of your Python version for ``numpy``, ``scipy``,
60-
``pandas``, ``matplotlib`` and ``scikit-learn``.
61-
* ``PyAnsys``: by selecting this option, users have access to the latest PyAnsys metapackage installation.
62-
This metapackage provides you with access to the latest public PyAnsys libraries in their compatible
63-
version with the latest Ansys products.
64-
* ``Jupyterlab``: by selecting this option, users have access to JupyterLab capabilities (that is, deploying a
65-
JupyterLab server locally, running Jupyter notebooks etc.).
66-
* ``Spyder``: by selecting this option, users are granted with a Spyder IDE install.
67-
68-
.. warning::
69-
70-
Currently the development team is experiencing problems when installing them by default.
71-
For the time being, it may be necessary to install them by hand. If you are using
72-
the ``Standard`` install then you should call ``pip install ...`` from a console. If you
73-
are using ``Conda (miniforge)``, then it should be ``conda install ...`` from a console.
74-
See the ``Launch Console`` information in the next section to know how to execute a
75-
console window properly configured for your Python environment.
7656

7757
Managing Python environments
7858
============================
@@ -86,7 +66,8 @@ installations. Have a look at how to access it here:
8666

8767
#. Select your desired ``Python`` environment and start one of the listed options.
8868

89-
Several options are provided to users:
69+
70+
On the ``Launching options`` section, the following options are available:
9071

9172
* ``Launch Console``: this option starts a console window with the command ``python`` pointing
9273
towards your selected Python environment.
@@ -95,4 +76,16 @@ Several options are provided to users:
9576
* ``Launch Jupyter Notebook``: this option starts a ``Jupyter Notebook`` session. If
9677
``Jupyter Notebook`` is not installed, then the ``Ansys Python Manager`` installs it for you.
9778
* ``Launch Spyder``: this option starts a Spyder IDE session. If Spyder is not installed,
98-
then the ``Ansys Python Manager`` installs it for you.
79+
then the ``Ansys Python Manager`` installs it for you.
80+
81+
On the ``Package management`` section, the following options are available:
82+
83+
* ``Install Python default packages``: by selecting this option, your selected Python install
84+
receives the latest compatible versions for ``numpy``, ``scipy``, ``pandas``, ``matplotlib``
85+
and ``scikit-learn``.
86+
* ``Install PyAnsys``: by selecting this option, your selected Python install has access to
87+
the latest, compatible PyAnsys metapackage installation. This metapackage provides you with
88+
access to the latest public PyAnsys libraries in their compatible version with the latest
89+
Ansys products.
90+
* ``List installed packages``: by selecting this option, a list of the installed packages on
91+
your selected Python install is provided. This might be useful for identifying potential problems.

src/ansys/tools/installer/installed_table.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ def __init__(self, parent):
7171
layout = QtWidgets.QVBoxLayout()
7272
self.setLayout(layout)
7373

74-
directions_text = QtWidgets.QLabel("Available Python installs")
75-
layout.addWidget(directions_text)
74+
launching_options = QtWidgets.QLabel("Launching options")
75+
launching_options.setContentsMargins(0, 10, 0, 0)
76+
layout.addWidget(launching_options)
7677

7778
hbox = QtWidgets.QHBoxLayout()
7879
layout.addLayout(hbox)
@@ -92,7 +93,32 @@ def __init__(self, parent):
9293
self.button_launch_spyder.clicked.connect(self.launch_spyder)
9394
hbox.addWidget(self.button_launch_spyder)
9495

96+
package_management = QtWidgets.QLabel("Package management")
97+
package_management.setContentsMargins(0, 10, 0, 0)
98+
layout.addWidget(package_management)
99+
100+
hbox_install = QtWidgets.QHBoxLayout()
101+
layout.addLayout(hbox_install)
102+
103+
self.button_install_defaults = QtWidgets.QPushButton(
104+
"Install Python default packages"
105+
)
106+
self.button_install_defaults.clicked.connect(self.install_defaults)
107+
hbox_install.addWidget(self.button_install_defaults)
108+
109+
self.button_install_pyansys = QtWidgets.QPushButton("Install PyAnsys")
110+
self.button_install_pyansys.clicked.connect(self.install_pyansys)
111+
hbox_install.addWidget(self.button_install_pyansys)
112+
113+
self.button_list_packages = QtWidgets.QPushButton("List installed packages")
114+
self.button_list_packages.clicked.connect(self.list_packages)
115+
hbox_install.addWidget(self.button_list_packages)
116+
95117
# Form
118+
form_title = QtWidgets.QLabel("Available Python installations")
119+
form_title.setContentsMargins(0, 10, 0, 0)
120+
layout.addWidget(form_title)
121+
96122
form = QtWidgets.QWidget()
97123
form_layout = QtWidgets.QVBoxLayout()
98124
form_layout.setContentsMargins(0, 0, 0, 0)
@@ -145,6 +171,20 @@ def launch_jupyter_notebook(self):
145171
error_msg = "pip install jupyter && python -m jupyter notebook || echo Failed to launch. Try reinstalling jupyter with pip install jupyter --force-reinstall"
146172
self.launch_cmd(f"python -m jupyter notebook || {error_msg}")
147173

174+
def install_defaults(self):
175+
"""Install Python default packages."""
176+
cmd = "pip install numpy pandas scipy scikit-learn matplotlib & timeout 3 & exit || echo Failed to install default Python packages. Try reinstalling it with pip install numpy pandas scipy scikit-learn matplotlib --force-reinstall"
177+
self.launch_cmd(cmd)
178+
179+
def install_pyansys(self):
180+
"""Install PyAnsys metapackage."""
181+
cmd = "pip install pyansys>=2023 & timeout 3 & exit || echo Failed to install PyAnsys metapackage. Try reinstalling it with pip install pyansys>=2023 --force-reinstall"
182+
self.launch_cmd(cmd)
183+
184+
def list_packages(self):
185+
"""List installed Python packages."""
186+
self.launch_cmd("pip list")
187+
148188
def launch_cmd(self, extra=""):
149189
""""""
150190
py_path = self.table.active_path

src/ansys/tools/installer/main.py

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
2424
While choosing the latest version of Python is generally recommended, some third-party libraries and applications may not yet be fully compatible with the newest release. Therefore, it is recommended to try the second newest version, as it will still have most of the latest features and improvements while also having broader support among third-party packages."""
2525

26-
PACKAGES_INFO_TEXT = """Select the packages to install globally in the Python environment. By default, the "Default" and "PyAnsys" packages are selected, but the user can also choose to install "JupyterLab" or "Spyder (IDE)" by selecting the corresponding check boxes. This allows the user to customize their Python installation to suit their specific needs."""
27-
2826

2927
if getattr(sys, "frozen", False):
3028
# If the application is run as a bundle, the PyInstaller bootloader
@@ -52,7 +50,7 @@ class AnsysPythonInstaller(QtWidgets.QWidget):
5250
def __init__(self, show=True):
5351
super().__init__()
5452
self.setWindowTitle("Ansys Python Manager")
55-
self.setGeometry(50, 50, 500, 900) # width should auto-update
53+
self.setGeometry(50, 50, 500, 700) # width should auto-update
5654

5755
self._pbar = None
5856
self._err_message_box = None
@@ -157,39 +155,6 @@ def __init__(self, show=True):
157155
python_version_box_layout.addWidget(python_version)
158156
form_layout.addWidget(python_version_box)
159157

160-
# Group 3: Packages
161-
packages_box = QtWidgets.QGroupBox("Packages")
162-
packages_box_layout = QtWidgets.QVBoxLayout()
163-
packages_box_layout.setContentsMargins(10, 20, 10, 20)
164-
packages_box.setLayout(packages_box_layout)
165-
166-
# Packages
167-
packages = QtWidgets.QWidget()
168-
packages_layout = QtWidgets.QVBoxLayout()
169-
# packages_layout.setContentsMargins(0,0,0,0)
170-
packages.setLayout(packages_layout)
171-
172-
packages_info_text = QtWidgets.QLabel(PACKAGES_INFO_TEXT)
173-
packages_info_text.setWordWrap(True)
174-
packages_layout.addWidget(packages_info_text)
175-
176-
packages_default = QtWidgets.QCheckBox("Default")
177-
packages_default.setChecked(True)
178-
packages_layout.addWidget(packages_default)
179-
180-
packages_pyansys = QtWidgets.QCheckBox("PyAnsys")
181-
packages_pyansys.setChecked(True)
182-
packages_layout.addWidget(packages_pyansys)
183-
184-
packages_jupyterlab = QtWidgets.QCheckBox("Jupyterlab")
185-
packages_layout.addWidget(packages_jupyterlab)
186-
187-
packages_spyder = QtWidgets.QCheckBox("Spyder (IDE)")
188-
packages_layout.addWidget(packages_spyder)
189-
190-
packages_box_layout.addWidget(packages)
191-
form_layout.addWidget(packages_box)
192-
193158
# ensure content does not get squished
194159
form_layout.addStretch()
195160

@@ -278,8 +243,8 @@ def _pbar_set_value(self, value):
278243

279244
def error_dialog(self, txt, textinfo=None):
280245
"""Create an error dialogue."""
281-
self._err_message_box = QMessageBox(self)
282-
self._err_message_box.setIcon(QMessageBox.Critical)
246+
self._err_message_box = QtWidgets.QMessageBox(self)
247+
self._err_message_box.setIcon(QtWidgets.QMessageBox.Critical)
283248
self._err_message_box.setText(txt)
284249

285250
def _show_error(self, text):

0 commit comments

Comments
 (0)