Repository: spyder-ide/spyder

Issue:
Improvements to the Linux installer
I installed using the bash file. Since I did that it's not showing as installed anywhere. So, how do I uninstall it?


Discussion:
Hey @aknight2015, thanks for reporting. Are you talking about the Linux experimental installer?
Yes, the experiemental linux installer.
Ok, did you install it for your user or with `sudo`?
I used chmod a+x on the bash file, and executed as ./
Ok, thanks. After the installer finishes, you should be able to start it using the facilities provided by Gnome Shell/KDE to run applications. What desktop environment are you using?

Also, could you take a look at this one @mrclary? Perhaps the installer should have a message at the end saying how to run the app and how to uninstall/remove it.
@aknight2015, I'm sorry you're having issues with the Linux installer.
You should find the following on your system if it was installed correctly:
- the file `/home/<user>/.local/share/applications/spyder_Spyder.desktop`
- the directory `/home/<user>/.local/Spyder-5.4.1.dev0`

On Ubuntu, you should be able to launch Spyder by searching in the Activities menu bar
![Screenshot from 2022-12-09 15-51-47](https://user-images.githubusercontent.com/9618975/206813858-396b3771-2808-40d0-966c-6a3edeee98ac.png)
or the Show Applications in the Dock
![Screenshot from 2022-12-09 15-52-42](https://user-images.githubusercontent.com/9618975/206813946-8c93648b-4c4c-430a-9699-a42e74bf9b13.png)

The permissions of the install script is a known issue. Another known issue is that the desktop file name should be `spyder.desktop`, not `spyder_Spyder.desktop`. If you change the name of the file, you should be able to pin Spyder in the Dock.
![Screenshot from 2022-12-09 15-55-08](https://user-images.githubusercontent.com/9618975/206813819-f6fbb0cc-4deb-48cf-88ef-97d9a3c71e74.png)

However, if this was not helpful to you, you should be able to uninstall Spyder by deleting the file and directory listed above. Thank you for reporting any issues that you find with our experimental installer; this will help us make necessary improvements and fixes.



Resolving patch:
diff --git a/installers-conda/build_conda_pkgs.py b/installers-conda/build_conda_pkgs.py
--- a/installers-conda/build_conda_pkgs.py
+++ b/installers-conda/build_conda_pkgs.py
@@ -66,6 +66,8 @@ def __init__(self, data={}, debug=False, shallow=False):
         self._get_source(shallow=shallow)
         self._get_version()
 
+        self._patch_source()
+
         self.data = {'version': self.version}
         self.data.update(data)
 
@@ -77,7 +79,7 @@ def _get_source(self, shallow=False):
 
         if self.source == HERE.parent:
             self._bld_src = self.source
-            repo = Repo(self.source)
+            self.repo = Repo(self.source)
         else:
             # Determine source and commit
             if self.source is not None:
@@ -97,10 +99,8 @@ def _get_source(self, shallow=False):
                     f"Cloning source shallow from tag {self.shallow_ver}...")
             else:
                 self.logger.info("Cloning source...")
-            repo = Repo.clone_from(remote, **kwargs)
-            repo.git.checkout(commit)
-
-        self._patch_source(repo)
+            self.repo = Repo.clone_from(remote, **kwargs)
+            self.repo.git.checkout(commit)
 
         # Clone feedstock
         self.logger.info("Cloning feedstock...")
@@ -117,7 +117,7 @@ def _get_version(self):
         """Get source version using setuptools_scm"""
         self.version = get_version(self._bld_src).split('+')[0]
 
-    def _patch_source(self, repo):
+    def _patch_source(self):
         pass
 
     def _patch_meta(self, meta):
@@ -127,7 +127,12 @@ def _patch_build_script(self):
         pass
 
     def patch_recipe(self):
-        """Patch conda build recipe"""
+        """
+        Patch conda build recipe
+
+        1. Patch meta.yaml
+        2. Patch build script
+        """
         if self._recipe_patched:
             return
 
@@ -161,9 +166,8 @@ def build(self):
         Build the conda package.
 
         1. Patch the recipe
-        2. Patch the build script
-        3. Build the package
-        4. Remove cloned repositories
+        2. Build the package
+        3. Remove cloned repositories
         """
         t0 = time()
         try:
@@ -193,16 +197,27 @@ class SpyderCondaPkg(BuildCondaPkg):
     feedstock = "https://github.com/conda-forge/spyder-feedstock"
     shallow_ver = "v5.3.2"
 
-    def _patch_source(self, repo):
+    def _patch_source(self):
         self.logger.info("Creating Spyder source patch...")
 
-        patch = repo.git.format_patch("..origin/installers-conda-patch",
-                                      "--stdout")
+        patch = self.repo.git.format_patch(
+            "..origin/installers-conda-patch", "--stdout", "-U3"
+        )
         # newline keyword is not added to pathlib until Python>=3.10,
         # so we must use open to ensure LF on Windows
         with open(SPYPATCHFILE, 'w', newline='\n') as f:
             f.write(patch)
 
+        self.logger.info("Creating Spyder menu file...")
+        _menufile = RESOURCES / "spyder-menu.json"
+        menufile = DIST / "spyder-menu.json"
+        commit, branch = self.repo.head.commit.name_rev.split()
+        text = _menufile.read_text()
+        text = text.replace("__PKG_VERSION__", self.version)
+        text = text.replace("__SPY_BRANCH__", branch)
+        text = text.replace("__SPY_COMMIT__", commit[:8])
+        menufile.write_text(text)
+
     def _patch_meta(self, meta):
         # Add source code patch
         search_patches = re.compile(
@@ -265,18 +280,30 @@ def _patch_build_script(self):
 
         if os.name == 'posix':
             file = self._fdstk_path / "recipe" / "build.sh"
-            build_patch = RESOURCES / "build-patch.sh"
             text = file.read_text()
-            text += build_patch.read_text()
+            text += dedent(
+                """
+                # Create the Menu directory
+                mkdir -p "${PREFIX}/Menu"
+
+                # Copy menu.json template
+                cp "${SRC_DIR}/installers-conda/dist/spyder-menu.json" "${PREFIX}/Menu/spyder-menu.json"
+
+                # Copy application icons
+                if [[ $OSTYPE == "darwin"* ]]; then
+                    cp "${SRC_DIR}/img_src/spyder.icns" "${PREFIX}/Menu/spyder.icns"
+                else
+                    cp "${SRC_DIR}/branding/logo/logomark/spyder-logomark-background.png" "${PREFIX}/Menu/spyder.png"
+                fi
+                """
+            )
+
         if os.name == 'nt':
             file = self._fdstk_path / "recipe" / "bld.bat"
             text = file.read_text()
             text = text.replace(
                 r"copy %RECIPE_DIR%\menu-windows.json %MENU_DIR%\spyder_shortcut.json",
-                r"""powershell -Command"""
-                r""" "(gc %SRC_DIR%\installers-conda\resources\spyder-menu.json)"""
-                r""" -replace '__PKG_VERSION__', '%PKG_VERSION%' | """
-                r"""Out-File -encoding ASCII %MENU_DIR%\spyder-menu.json" """
+                r"copy %SRC_DIR%\installers-conda\dist\spyder-menu.json %MENU_DIR%\spyder-menu.json"
             )
         file.rename(file.parent / ("_" + file.name))  # keep copy of original
         file.write_text(text)
diff --git a/installers-conda/build_installers.py b/installers-conda/build_installers.py
--- a/installers-conda/build_installers.py
+++ b/installers-conda/build_installers.py
@@ -239,9 +239,6 @@ def _definitions():
                 "specs": [k + v for k, v in specs.items()],
             },
         },
-        "menu_packages": [
-            "spyder",
-        ],
         "extra_files": [
             {str(RESOURCES / "bundle_readme.md"): "README.txt"},
             {condarc: ".condarc"},
@@ -252,11 +249,16 @@ def _definitions():
         definitions["channels"].insert(0, "local")
 
     if LINUX:
-        definitions["default_prefix"] = os.path.join(
-            "$HOME", ".local", INSTALLER_DEFAULT_PATH_STEM
+        definitions.update(
+            {
+                "default_prefix": os.path.join(
+                    "$HOME", ".local", INSTALLER_DEFAULT_PATH_STEM
+                ),
+                "license_file": str(SPYREPO / "LICENSE.txt"),
+                "installer_type": "sh",
+                "post_install": str(RESOURCES / "post-install.sh"),
+            }
         )
-        definitions["license_file"] = str(SPYREPO / "LICENSE.txt")
-        definitions["installer_type"] = "sh"
 
     if MACOS:
         welcome_text_tmpl = \
@@ -276,7 +278,6 @@ def _definitions():
                 "welcome_file": str(welcome_file),
                 "conclusion_text": "",
                 "readme_text": "",
-                "post_install": str(RESOURCES / "post-install.sh"),
             }
         )
 


Test patch: