Skip to content

Commit 80bd667

Browse files
anssakthitusharbana-ansyspre-commit-ci[bot]RobPasMue
authored
Uninstaller script and configure virtual environment create & search path. (#230)
Co-authored-by: Tushar Bana <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent 9fc0b6e commit 80bd667

File tree

16 files changed

+927
-48
lines changed

16 files changed

+927
-48
lines changed

.github/workflows/ci_cd.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ jobs:
208208
find package/opt/ansys_python_manager -type d -exec chmod 755 -- {} +
209209
find package/share -type f -exec chmod 644 -- {} +
210210
chmod +x package/opt/ansys_python_manager/ansys_python_manager
211+
chmod +x package/opt/ansys_python_manager/_internal/assets/uninstaller_ubuntu.sh
211212
version=v`cat ./src/ansys/tools/installer/VERSION`
212213
echo "APPLICATION_VERSION=$version" >> $GITHUB_ENV
213214
fpm -v $version --fpm-options-file linux/debian/fpm-options-debian
@@ -287,11 +288,31 @@ jobs:
287288
yum install ruby -y
288289
gem install fpm
289290
290-
- name: Create OS version & Github Workspace variable
291+
- name: Create OS version, Github Workspace, Folder Name variables
291292
run: |
292293
os_version_processed=`echo ${{ matrix.os }} | sed 's/\:/_/g' | sed 's/\./_/g' | awk -F/ '{print $NF}'`
293294
echo "OS_VERSION_PROCESSED=$os_version_processed" >> $GITHUB_ENV
294295
echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_ENV
296+
folder_name=`echo $os_version_processed | awk -F_ '{print $1}'`
297+
echo "FOLDER_NAME=$folder_name" >> $GITHUB_ENV
298+
299+
- name: Create python-3.11 artifact
300+
run: |
301+
mkdir -p cd ${{ env.GITHUB_WORKSPACE }}/.cache
302+
cd ${{ env.GITHUB_WORKSPACE }}/.cache
303+
wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tar.xz
304+
tar -xf Python-3.11.6.tar.xz
305+
cd Python-3.11.6
306+
./configure --prefix=${{ env.GITHUB_WORKSPACE }}/python-3.11.6
307+
cd ${{ env.GITHUB_WORKSPACE }}/.cache/Python-3.11.6
308+
make;
309+
make install;
310+
cd ${{ env.GITHUB_WORKSPACE }}/python-3.11.6
311+
cd ..
312+
tar -czf python-3.11.6.tar.gz python-3.11.6/
313+
mkdir -p ${{ env.GITHUB_WORKSPACE }}/src/ansys/tools/installer/assets/python-asset/${{ env.FOLDER_NAME }}
314+
mv python-3.11.6.tar.gz ${{ env.GITHUB_WORKSPACE }}/src/ansys/tools/installer/assets/python-asset/${{ env.FOLDER_NAME }}
315+
ls -l ${{ env.GITHUB_WORKSPACE }}/src/ansys/tools/installer/assets/python-asset/${{ env.FOLDER_NAME }}
295316
296317
- name: Update pip
297318
run: |
@@ -313,6 +334,7 @@ jobs:
313334
mkdir -p package_CentOS/opt
314335
mkdir -p package_CentOS/usr/share/applications
315336
mkdir -p package_CentOS/usr/share/icons/hicolor/scalable/apps
337+
chmod +x src/ansys/tools/installer/assets/scripts/uninstaller_yum.sh
316338
cp -r dist/ansys_python_manager package_CentOS/opt/ansys_python_manager
317339
cp src/ansys/tools/installer/assets/pyansys_icon.svg package_CentOS/usr/share/icons/hicolor/scalable/apps/pyansys_icon.svg
318340
cp linux/non-debian/ansys_python_manager.desktop package_CentOS/usr/share/applications
@@ -335,6 +357,7 @@ jobs:
335357
mkdir -p package_Fedora/opt
336358
mkdir -p package_Fedora/usr/share/applications
337359
mkdir -p package_Fedora/usr/share/icons/hicolor/scalable/apps
360+
chmod +x src/ansys/tools/installer/assets/scripts/uninstaller_yum.sh
338361
cp -r dist/ansys_python_manager package_Fedora/opt/ansys_python_manager
339362
cp src/ansys/tools/installer/assets/pyansys_icon.svg package_Fedora/usr/share/icons/hicolor/scalable/apps/pyansys_icon.svg
340363
cp linux/non-debian/ansys_python_manager.desktop package_Fedora/usr/share/applications

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ celerybeat.pid
123123

124124
# Environments
125125
.env
126-
.venv
126+
.venv*
127127
env/
128128
venv/
129129
ENV/

doc/source/installer.rst

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ Installing the ``Ansys Python Manager``
6565

6666
The ``Ansys Python Manager`` window should appear at this stage.
6767

68+
To uninstall the ``Ansys Python Manager``, follow below steps.
69+
70+
#. Go to File menu. Click Uninstall option.
71+
72+
#. In the pop up window:
73+
74+
* If you want to remove all the virtual environments as part of
75+
uninstallation, mark ``Delete virtual environment`` checkbox
76+
77+
* If you want to remove all the configurations as part of
78+
uninstallation, mark ``Delete configurations`` checkbox
79+
80+
#. Click ``Uninstall`` button.
81+
82+
6883
.. tab-item:: CentOS9, RHEL9
6984

7085
Prerequisites:
@@ -109,6 +124,22 @@ Installing the ``Ansys Python Manager``
109124

110125
The ``Ansys Python Manager`` window should appear at this stage.
111126

127+
To uninstall the ``Ansys Python Manager``, follow below steps.
128+
129+
#. Go to File menu. Click Uninstall option.
130+
131+
#. In the pop up window:
132+
133+
* If you want to remove all the virtual environments as part of
134+
uninstallation, mark ``Delete virtual environment`` checkbox
135+
136+
* If you want to remove all the configurations as part of
137+
uninstallation, mark ``Delete configurations`` checkbox
138+
139+
#. Click ``Uninstall`` button.
140+
141+
#. Follow the uninstaller script & provide sudo permission to uninstall the application.
142+
112143
.. tab-item:: Fedora39
113144

114145
Prerequisites:
@@ -153,6 +184,22 @@ Installing the ``Ansys Python Manager``
153184

154185
The ``Ansys Python Manager`` window should appear at this stage.
155186

187+
To uninstall the ``Ansys Python Manager``, follow below steps.
188+
189+
#. Go to File menu. Click Uninstall option.
190+
191+
#. In the pop up window:
192+
193+
* If you want to remove all the virtual environments as part of
194+
uninstallation, mark ``Delete virtual environment`` checkbox
195+
196+
* If you want to remove all the configurations as part of
197+
uninstallation, mark ``Delete configurations`` checkbox
198+
199+
#. Click ``Uninstall`` button.
200+
201+
#. Follow the uninstaller script & provide sudo permission to uninstall the application.
202+
156203

157204
Installing Python
158205
=================
@@ -224,6 +271,27 @@ Regarding the available Python versions, users can select among the following on
224271

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

274+
Create Python virtual environment
275+
=================================
276+
277+
#. Search for the ``Ansys Python Manager`` and run it.
278+
279+
#. Access the ``Create Python Environments`` tab.
280+
281+
#. Select your desired ``Python version`` from the listed options.
282+
283+
#. Provide the name of the virtual environment in the ``Enter virtual environment name`` text box.
284+
285+
#. Finally, Click ``Create`` button to create.
286+
287+
By default, Ansys Python Manager create virtual environment under,
288+
289+
* ``{user directory}/.ansys_python_venvs`` for Windows
290+
* ``{user directory}/.local/ansys/.ansys_python_venvs`` for Linux
291+
292+
To configure the default virtual environment creation path, go to the ``File >> Configure`` section
293+
``(Ctrl + D)`` and provide your preferred path under the first text box. Then, click the ``Save`` button.
294+
227295

228296
Managing Python environments
229297
============================
@@ -232,11 +300,20 @@ Through the ``Ansys Python Manager``, users can also have access to their differ
232300
installations. Have a look at how to access it here:
233301

234302
#. Search for the ``Ansys Python Manager`` and run it.
235-
236303
#. Access the ``Manage Python Environments`` tab.
237-
238304
#. Select your desired ``Python`` environment and start one of the listed options.
239305

306+
By default, Ansys Python Manager list python environments available under,
307+
308+
* ``{user directory}/.ansys_python_venvs`` for Windows
309+
* ``{user directory}/.local/ansys/.ansys_python_venvs`` for Linux
310+
311+
To manage this directory, go to the ``File >> Configure`` section ``(Ctrl + D)`` and make the appropriate changes.
312+
313+
#. To add a new default directory path, provide the path in the corresponding text box.
314+
#. To add a new path where virtual environments are searched for, provide the path in the corresponding text box and click the ``Add`` button.
315+
#. To remove directory path select the respective path that you want remove from the dropdown and click the ``Remove`` button.
316+
#. Finally, click the ``Save`` button to save the configurations.
240317

241318
On the ``Launching options`` section, the following options are available:
242319

frozen.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ added_files += copy_metadata('ansys-tools-path')
4040
if is_linux() and os.getenv("ADD_PYTHON_BINARIES","true") == "true":
4141
added_files +=[(os.path.join(ASSETS_PATH, 'python-asset'), 'assets')]
4242

43+
if is_linux():
44+
added_files +=[(os.path.join(ASSETS_PATH, 'scripts'), 'assets')]
45+
4346
a = Analysis([main_py],
4447
pathex=[],
4548
binaries=[],

linux/debian/installer.sh

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /bin/bash
22
clear
3+
printf """Installation started.....\n"""
34
missing_deps=()
45
dependencies_available=true
56
# check zlib
@@ -54,10 +55,39 @@ else
5455
if [ $install_zlib = true ]; then
5556
install_script="$install_script rm -rf ansys-prereq/ ; mkdir -p ansys-prereq; cd ansys-prereq; wget https://zlib.net/current/zlib.tar.gz; tar xvzf zlib.tar.gz; cd zlib-*; make clean; ./configure; make; sudo make install; cd ../..; rm -rf ansys-prereq;"
5657
fi
58+
59+
dependencies_available=true
5760
eval $install_script
58-
dpkg -x ./ansys_python_manager.deb ${HOME}/.local
59-
./postInstallScript.sh
60-
printf "\nInstallation success...\n"
61+
# Confirmation
62+
# check zlib
63+
ls /usr/local/lib/libz.so >/dev/null 2>&1
64+
ret=$?
65+
if [ $ret -eq 0 ]; then
66+
:
67+
else
68+
missing_deps+=("zlib")
69+
dependencies_available=false
70+
fi
71+
# check other dependencies
72+
arr=("libffi-dev" "libssl-dev" "build-essential" "libsqlite3-dev" "libxcb-xinerama0")
73+
for x in "${arr[@]}"; do
74+
c="dpkg -s $x >/dev/null 2>&1"
75+
eval $c
76+
ret=$?
77+
if [ $ret -eq 0 ]; then
78+
:
79+
else
80+
missing_deps+=("$x")
81+
dependencies_available=false
82+
fi
83+
done
84+
if [ $dependencies_available = false ]; then
85+
echo "Unable to install dependencies. Check above logs and try again..."
86+
else
87+
dpkg -x ./ansys_python_manager.deb ${HOME}/.local
88+
./postInstallScript.sh
89+
printf "\nInstallation success...\n"
90+
fi
6191
else
6292
echo "You don't have access to sudo. Please try again..."
6393
fi
@@ -66,7 +96,7 @@ else
6696
for x in "${missing_deps[@]}"; do
6797
echo "$x"
6898
done
69-
echo "Dependencies installation required sudo access.\n"
70-
99+
printf "Dependencies installation required sudo access.\n"
100+
echo -e '\e]8;;https://installer.docs.pyansys.com/version/stable/installer.html\aFollow prerequisites in this link\e]8;;\a'
71101
fi
72-
fi
102+
fi
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
echo "Uninstalling Ansys Python Manager......."
2+
sleep 3
3+
4+
rm -rf ${HOME}/.local/share/icons/pyansys_icon.svg
5+
rm -rf ${HOME}/.local/share/applications/ansys_python_manager.desktop
6+
rm -rf ${HOME}/.local/usr/share/doc/ansys-python-manager
7+
8+
rm -rf ${HOME}/.local/opt/ansys_python_manager
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
while true; do
2+
read -p "Require sudo permission to uninstall this package and the dependencies. Do you want to continue?(Y/N): " user_selection
3+
if [ "$user_selection" = "Y" ] || [ "$user_selection" = "N" ]; then
4+
break
5+
fi
6+
clear
7+
done
8+
printf "\n"
9+
if [ "$user_selection" = "Y" ]; then
10+
#Check sudo
11+
sudo -v >/dev/null 2>&1
12+
root_check=$?
13+
if [ $root_check -eq 0 ]; then
14+
echo "Uninstalling Ansys Python Manager......."
15+
sleep 2
16+
sudo yum remove -y ansys_python_manager.x86_64
17+
printf "\nUninstalled successfully...\n"
18+
else
19+
echo "You don't have access to sudo. Please try again..."
20+
fi
21+
else
22+
# Script aborted by user
23+
printf "Aborting....\nUser permission denied.... \n\n"
24+
echo "Ansys Python Manager and required dependencies require sudo access to uninstall."
25+
fi

0 commit comments

Comments
 (0)