Skip to content
Open
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
41 changes: 34 additions & 7 deletions doc/source/installer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,27 @@
#. **OS** supported for **Ubuntu(20.04 and 22.04)**.

#. Update ``apt-get`` repository and install the following packages with **sudo** privileges:
**wget, gnome, libffi-dev, libssl-dev, libsqlite3-dev, libxcb-xinerama0 and build-essential** packages with **sudo** privileges
**wget, gnome-terminal, libffi-dev, libssl-dev, libsqlite3-dev, libxcb-xinerama0 and build-essential** packages with **sudo** privileges

.. code:: shell

sudo apt-get update -y
sudo apt-get install wget gnome libffi-dev libssl-dev libsqlite3-dev libxcb-xinerama0 build-essential -y
sudo apt-get install wget gnome-terminal libffi-dev libssl-dev libsqlite3-dev libxcb-xinerama0 build-essential -y

.. note::

A terminal emulator is required for the ``Ansys Python Manager`` to run
commands (install packages, launch consoles, and so on). ``gnome-terminal``
is recommended, but ``konsole``, ``xfce4-terminal``, ``mate-terminal``,
``tilix``, and ``xterm`` are also supported. This is particularly relevant
when running under **WSL (Windows Subsystem for Linux)**, which does not
ship with a terminal emulator by default. In that case, install a
lightweight option instead of the full ``gnome-terminal`` package:

.. code:: shell

sudo apt-get update -y
sudo apt-get install xterm -y

#. Install **zlib** package

Expand Down Expand Up @@ -92,13 +107,19 @@
#. **OS** supported for **CentOS9** and **RHEL9**.

#. Update ``yum`` repository and install the following packages with **sudo** privileges:
**wget, gnome-terminal, Development Tools, libffi-devel, openssl-devel, rpm-build, sqlite-devel, sqlite-libs, libXinerama-devel, coreutils**
**wget, gnome-terminal, Development Tools, libffi-devel, openssl-devel, rpm-build, sqlite-devel, sqlite-libs, libXinerama-devel, coreutils, mesa-libGL, mesa-libEGL, xcb-util-cursor**

.. code:: shell

sudo yum update -y;
sudo yum groupinstall 'Development Tools' -y;
sudo yum install wget gnome-terminal libffi-devel openssl-devel rpm-build sqlite-devel sqlite-libs libXinerama-devel coreutils -y;
sudo yum install wget gnome-terminal libffi-devel openssl-devel rpm-build sqlite-devel sqlite-libs libXinerama-devel coreutils mesa-libGL mesa-libEGL xcb-util-cursor -y;

.. note::

Under **WSL (Windows Subsystem for Linux)**, you can install the lighter
``xterm`` instead of ``gnome-terminal``. ``mesa-libGL``, ``mesa-libEGL``,
and ``xcb-util-cursor`` are still required to display the application.

#. Install **zlib** package using **wget**

Expand Down Expand Up @@ -157,13 +178,19 @@
#. **OS** supported for **Fedora39**.

#. Update ``yum`` repository and install the following packages with **sudo** privileges:
**wget, gnome-terminal, Development Tools, libffi-devel, openssl-devel, rpm-build, sqlite-devel, sqlite-libs, libXinerama-devel, coreutils**
**wget, gnome-terminal, Development Tools, libffi-devel, openssl-devel, rpm-build, sqlite-devel, sqlite-libs, libXinerama-devel, coreutils, mesa-libGL, mesa-libEGL, xcb-util-cursor**

.. code:: shell

sudo yum update -y;
sudo yum groupinstall 'Development Tools' -y;
sudo yum install wget gnome-terminal libffi-devel openssl-devel rpm-build sqlite-devel sqlite-libs libXinerama-devel coreutils -y;
sudo yum group install development-tools -y;
sudo yum install wget gnome-terminal libffi-devel openssl-devel rpm-build sqlite-devel sqlite-libs libXinerama-devel coreutils mesa-libGL mesa-libEGL xcb-util-cursor -y;

.. note::

Under **WSL (Windows Subsystem for Linux)**, you can install the lighter
``xterm`` instead of ``gnome-terminal``. ``mesa-libGL``, ``mesa-libEGL``,
and ``xcb-util-cursor`` are still required to display the application.

#. Install **zlib** package using **wget**

Expand Down Expand Up @@ -221,7 +248,7 @@

Now, instructions on how to install Python from the ``Ansys Python Manager`` are provided.

In order to do so, just follow the upcoming steps:

Check warning on line 251 in doc/source/installer.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/installer.rst#L251 <Google.WordListCase>(https://developers.google.com/style/word-list)

Use 'to' instead of 'In order to'.
Raw output
{"message":"Use 'to' instead of 'In order to'.","location":{"path":"doc/source/installer.rst","range":{"start":{"line":251,"column":1},"end":{"line":251,"column":12}}},"severity":"WARNING","code":{"value":"Google.WordListCase","url":"https://developers.google.com/style/word-list"}}

#. Search for the ``Ansys Python Manager`` and run it.

Expand Down
6 changes: 3 additions & 3 deletions linux/debian/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ else
dependencies_available=false
fi
# check other dependencies
arr=("wget" "gnome" "libffi-dev" "libssl-dev" "build-essential" "libsqlite3-dev" "libxcb-xinerama0")
arr=("wget" "gnome-terminal" "libffi-dev" "libssl-dev" "build-essential" "libsqlite3-dev" "libxcb-xinerama0")
for x in "${arr[@]}"; do
c="dpkg -s $x >/dev/null 2>&1"
eval $c
Expand Down Expand Up @@ -75,7 +75,7 @@ else
dependencies_available=false
fi
# check other dependencies
arr=("wget" "gnome" "libffi-dev" "libssl-dev" "build-essential" "libsqlite3-dev" "libxcb-xinerama0")
arr=("wget" "gnome-terminal" "libffi-dev" "libssl-dev" "build-essential" "libsqlite3-dev" "libxcb-xinerama0")
for x in "${arr[@]}"; do
c="dpkg -s $x >/dev/null 2>&1"
eval $c
Expand Down Expand Up @@ -111,4 +111,4 @@ else
printf "Dependencies installation required sudo access.\n"
echo -e '\e]8;;https://installer.docs.pyansys.com/version/stable/installer.html\aFollow prerequisites in this link\e]8;;\a'
fi
fi
fi
49 changes: 39 additions & 10 deletions linux/non-debian/installer_CentOS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
clear
missing_deps=()
dependencies_available=true
if command -v dnf >/dev/null 2>&1; then
pkg_manager=dnf
elif command -v yum >/dev/null 2>&1; then
pkg_manager=yum
else
echo "Neither dnf nor yum was found. Install the dependencies manually, following:"
echo "https://installer.docs.pyansys.com/version/stable/installer.html"
exit 1
fi
# Check user input for sudo permission
while true; do
read -p "Require sudo permission to install this package and the dependencies. Do you want to continue?(Y/N): " user_selection
Expand All @@ -26,15 +35,15 @@ if [ "$user_selection" = "Y" ]; then
dependencies_available=false
fi
# check other dependencies
yum grouplist | grep 'Development Tools'
$pkg_manager group list --installed 2>/dev/null | grep -q 'Development Tools'
ret=$?
if [ $ret -eq 0 ]; then
:
else
missing_deps+=("Development Tools")
dependencies_available=false
fi
arr=("wget" "gnome-terminal" "libffi-devel" "openssl-devel" "rpm-build" "sqlite-devel" "sqlite-libs" "libXinerama-devel" "coreutils")
arr=("wget" "gnome-terminal" "libffi-devel" "openssl-devel" "rpm-build" "sqlite-devel" "sqlite-libs" "libXinerama-devel" "coreutils" "mesa-libGL" "mesa-libEGL" "xcb-util-cursor")
for x in "${arr[@]}"; do
c="rpm -qa | grep $x"
eval $c
Expand All @@ -47,7 +56,10 @@ if [ "$user_selection" = "Y" ]; then
fi
done
if [ $dependencies_available = true ]; then
sudo rpm -iv ansys_python_manager_*.rpm
if ! sudo rpm -iv ansys_python_manager_*.rpm; then
printf "\nInstallation failed...\n"
exit 1
fi
available=$(cat ~/.bashrc | grep -zoP "# Add alias for Ansys Python Manager \nalias ansys_python_manager=~/.local/opt/ansys_python_manager/ansys_python_manager" | wc -l)
echo $available
if [ $available -lt 1 ]
Expand All @@ -57,21 +69,38 @@ if [ "$user_selection" = "Y" ]; then
printf "\nInstallation success...\nIt is suggested to restart your machine to begin using the software....\n"
else
echo "Missing dependencies..."
install_script="sudo yum update -y; sudo yum install "
install_script="true"
packages=""
install_zlib=false
install_dev_tools=false
for x in "${missing_deps[@]}"; do
if [ $x == "zlib" ]; then
if [ "$x" == "zlib" ]; then
install_zlib=true
elif [ "$x" == "Development Tools" ]; then
install_dev_tools=true
else
install_script="$install_script $x"
packages="$packages $x"
fi
done
install_script="$install_script -y"
if [ -n "$packages" ]; then
install_script="$install_script && sudo $pkg_manager install$packages -y"
fi
if [ $install_dev_tools = true ]; then
# dnf5 (Fedora 41+) only accepts the group ID
install_script="$install_script && { sudo $pkg_manager group install 'Development Tools' -y || sudo $pkg_manager group install development-tools -y; }"
fi
sudo $pkg_manager update -y
if ! eval $install_script; then
printf "\nFailed to install the dependencies. Installation aborted...\n"
exit 1
fi
if [ $install_zlib = true ]; then
install_script="$install_script; mkdir ansys-prereq; cd ansys-prereq; wget https://zlib.net/current/zlib.tar.gz; tar xvzf zlib.tar.gz; cd zlib-*; sudo make clean; ./configure; sudo make; sudo make install; cd ../..; rm -rf ansys-prereq;"
mkdir ansys-prereq; cd ansys-prereq; wget https://zlib.net/current/zlib.tar.gz; tar xvzf zlib.tar.gz; cd zlib-*; sudo make clean; ./configure; sudo make; sudo make install; cd ../..; rm -rf ansys-prereq;
fi
if ! sudo rpm -iv ansys_python_manager_*.rpm; then
printf "\nInstallation failed...\n"
exit 1
fi
eval $install_script
sudo rpm -iv ansys_python_manager_*.rpm
printf "\nInstallation success...\n"
fi
else
Expand Down
30 changes: 26 additions & 4 deletions src/ansys/tools/installer/create_virtual_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,28 @@ def create_venv(self):
Path(venv_dir).mkdir(parents=True, exist_ok=True)
try:
self.cmd_create_venv(venv_dir)
except:
self.failed_to_create_dialog()
except Exception as err:
LOG.error(err)
error = str(err)
else:
error = None
# Linux terminals do not report the exit status of the command
if is_linux_os() and not os.path.exists(
os.path.join(venv_dir, "bin", "python")
):
error = (
"The virtual environment was not created. Check the "
"terminal output for details."
)
LOG.error(f"{error} Path: {venv_dir}")

if error is not None:
# Allow retrying with the same name
if os.path.isdir(venv_dir) and not os.listdir(venv_dir):
os.rmdir(venv_dir)
self.failed_to_create_dialog(details=error)
self.update_table()
return

self.update_table()
self.venv_success_dialog()
Expand All @@ -143,7 +163,7 @@ def venv_success_dialog(self):
msg.setWindowIcon(self.app_icon)
msg.exec_()

def failed_to_create_dialog(self, case_1=False, case_2=False):
def failed_to_create_dialog(self, case_1=False, case_2=False, details=None):
"""Dialogs for if environment gets failed to create."""
if case_1:
# Case 1: check for name of environment
Expand Down Expand Up @@ -172,7 +192,9 @@ def failed_to_create_dialog(self, case_1=False, case_2=False):
# In case of critical error
msg = QtWidgets.QMessageBox()
msg.setText("Error: Failed to create virtual environment!")
msg.setInformativeText("There might be some issue with application.")
msg.setInformativeText(
details or "There might be some issue with application."
)
msg.setWindowTitle("Error")
msg.setIcon(msg.Icon.Critical)
msg.setWindowIcon(self.app_icon)
Expand Down
50 changes: 44 additions & 6 deletions src/ansys/tools/installer/installed_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ def _update_pck_mnger(self):
"""
if self.is_chk_box_active():
if "Python" in self.table.active_version:
if is_linux_os():
# run_linux_command already updates pip and uv first
return
cmd = "python -m pip install -U pip uv && exit"
else: # Otherwise, conda
cmd = "conda update conda --yes && exit"
Expand Down Expand Up @@ -595,12 +598,31 @@ def delete_virtual_environment(self, point):
subprocess.call(f'start /w /min cmd /K "{shell_cmd}"', shell=True)
if os.path.exists(parent_path):
shutil.rmtree(parent_path)
except:
pass
except Exception as err:
LOG.error(err)
if self._parent is not None and hasattr(self._parent, "show_error"):
self._parent.show_error(str(err))

# Finally, update the venv table
self.venv_table.update()

def _run_linux_or_report_error(self, func, *args, **kwargs):
"""Run a Linux command launcher, surfacing failures to the user.

Notes
-----
This is primarily needed to catch ``NoLinuxTerminalError``, which is
raised when no supported terminal emulator (such as ``gnome-terminal``)
is available. This is a common situation on WSL (Windows Subsystem for
Linux), where no terminal emulator is installed by default.
"""
try:
func(*args, **kwargs)
except Exception as err:
LOG.error(err)
if self._parent is not None and hasattr(self._parent, "show_error"):
self._parent.show_error(str(err))

def launch_cmd(
self,
extra: str = "",
Expand Down Expand Up @@ -672,7 +694,9 @@ def launch_cmd(
cmd = f"&& echo Python set to {py_path}"

if is_linux_os():
run_linux_command(py_path, extra, working_dir=working_dir)
self._run_linux_or_report_error(
run_linux_command, py_path, extra, working_dir=working_dir
)
else:
# Update the package managers
shell_cmd = f"set PATH={new_path} && python -m pip install --upgrade pip uv && exit"
Expand All @@ -687,7 +711,9 @@ def launch_cmd(
else:
cmd = f"&& echo Python set to {py_path}"
if is_linux_os():
run_linux_command(py_path, extra, True, working_dir=working_dir)
self._run_linux_or_report_error(
run_linux_command, py_path, extra, True, working_dir=working_dir
)
else:
shell_cmd = f'set PATH={myenv} && {py_path}\\Scripts\\activate.bat && cd /d ""{working_dir}"" {cmd}'
subprocess.call(f'start {min_win} cmd /K "{shell_cmd}"', shell=True)
Expand All @@ -702,7 +728,13 @@ def launch_cmd(
else:
cmd = f"&& echo Activating conda forge at path {py_path}"
if is_linux_os():
run_linux_command_conda(py_path, extra, True, working_dir=working_dir)
self._run_linux_or_report_error(
run_linux_command_conda,
py_path,
extra,
True,
working_dir=working_dir,
)
else:
shell_cmd = f'set PATH={myenv} && {miniforge_path}\\Scripts\\activate.bat && conda activate {py_path} && cd /d ""{working_dir}"" {cmd}'
subprocess.call(f'start {min_win} cmd /K "{shell_cmd}"', shell=True)
Expand All @@ -717,7 +749,13 @@ def launch_cmd(
else:
cmd = f"&& echo Activating conda forge at path {py_path}"
if is_linux_os():
run_linux_command_conda(py_path, extra, False, working_dir=working_dir)
self._run_linux_or_report_error(
run_linux_command_conda,
py_path,
extra,
False,
working_dir=working_dir,
)
else:
shell_cmd = f'set PATH={myenv} && {miniforge_path}\\Scripts\\activate.bat && conda activate {py_path} && cd /d ""{working_dir}"" {cmd}'
subprocess.call(f'start {min_win} cmd /K "{shell_cmd}"', shell=True)
Loading
Loading