From e10ec726926e51495a641cea2d5cb8d22e1cde87 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 21 Aug 2023 19:40:30 +0200 Subject: [PATCH 01/54] Require menuinst >=2 --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index e6721b5..a390f78 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -35,7 +35,7 @@ requirements: - python ={{ python_version }} - conda ={{ conda_version }} - conda-package-handling >=1.6 - - menuinst >=1.4.18,<2.0a0 # [win] + - menuinst >=2 - conda-libmamba-solver ={{ conda_libmamba_solver_version }} - libmambapy ={{ libmambapy_version }} run_constrained: From 02e8a966877b9e910cca9595a23b5ce5cc28fd71 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 21 Aug 2023 19:51:20 +0200 Subject: [PATCH 02/54] use canary channel for menuinst --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 31efa14..f262ac3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,7 +56,10 @@ jobs: env: CONDA_SOLVER: libmamba CONDA_BLD_PATH: ${{ runner.temp }}/bld - run: conda build recipe + run: | + # TEMPORARY + # conda build recipe + conda build recipe --override-channels -c conda-forge -c conda-canary/label/dev - name: Upload package to anaconda.org shell: bash -el {0} From 5a9f29f2492e9b8f2eecdce6d9a76d17f130bb6b Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 12:47:54 +0200 Subject: [PATCH 03/54] update sha --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index a390f78..73547cd 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -12,7 +12,7 @@ package: source: - path: ../ - url: https://github.com/conda/conda/archive/{{ conda_version }}.tar.gz - sha256: 4fd44862ef87c73e4641b0c40a0873e103a097d6fd4a992041cfa9177ce20ac8 + sha256: 141ddbc101c67df54a344f0e41e044b7215f9b73c0876d2bee0c97ecc124e0d4 folder: conda_src patches: - ../src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch From 60cc7fec85e57c047b2fa25e3b3a1dd9b457e002 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 17:21:40 +0200 Subject: [PATCH 04/54] include alphas --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 73547cd..ae0168c 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -35,7 +35,7 @@ requirements: - python ={{ python_version }} - conda ={{ conda_version }} - conda-package-handling >=1.6 - - menuinst >=2 + - menuinst >=2.0.0a0 - conda-libmamba-solver ={{ conda_libmamba_solver_version }} - libmambapy ={{ libmambapy_version }} run_constrained: From 5ac360d4d538ca339367576091a04d2940b44e0d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 18:30:10 +0200 Subject: [PATCH 05/54] add news --- news/36-update-menuinst | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/36-update-menuinst diff --git a/news/36-update-menuinst b/news/36-update-menuinst new file mode 100644 index 0000000..723ed97 --- /dev/null +++ b/news/36-update-menuinst @@ -0,0 +1,19 @@ +### Enhancements + +* Bundle `menuinst` v2.0.0a0. (#36) + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +* From 48f2c052ceab91ff4348c6d61162eecfac9c32cc Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 18:44:21 +0200 Subject: [PATCH 06/54] update imports and datas for menuinst --- src/conda.exe.spec | 39 ++++++++++++++++++++++++++++++++++----- src/imports.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 99b6ffe..da919be 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -1,5 +1,6 @@ # -*- mode: python ; coding: utf-8 -*- import os +import site import sys # __file__ is not defined in the pyinstaller context, @@ -12,18 +13,46 @@ else: HERE = os.path.join(os.path.getcwd(), "src") block_cipher = None +sitepackages = os.environ.get( + "SP_DIR", # site-packages in conda-build's host environment + # if not defined, get running Python's site-packages + # Windows puts sys.prefix in this list first + next( + path for path in site.getsitepackages() + if path.endswith("site-packages") + ) +) extra_exe_kwargs = {} -datas = [] +# Non imported files need to be added manually via datas or binaries: +# Datas are not analyzed, just copied over. Binaries go through some +# linkage analysis to also bring necessary libs. This includes plain +# text files like JSON, modules never imported, or standalone binaries +# Shared objects and DLLs should have been caught by pyinstaller import hooks, +# but if not, add them. +# Format: a list of tuples like (file-path, target-DIRECTORY) +binaries = [] +datas = [ + (os.path.join(sitepackages, 'menuinst', 'data', 'menuinst.default.json'), 'menuinst/data'), + (os.path.join(sitepackages, 'menuinst', 'data', 'menuinst.schema.json'), 'menuinst/data'), +] if sys.platform == "win32": - datas = [(os.path.join(os.getcwd(), 'constructor_src', 'constructor', 'nsis', '_nsis.py'), 'Lib'), - (os.path.join(os.getcwd(), 'entry_point_base.exe'), '.')] + datas += [ + (os.path.join(os.getcwd(), 'constructor', 'constructor', 'nsis', '_nsis.py'), 'Lib'), + (os.path.join(os.getcwd(), 'entry_point_base.exe'), '.'), + ] elif sys.platform == "darwin": - extra_exe_kwargs["entitlements_file"] = os.path.join(HERE, "entitlements.plist") + datas += [ + (os.path.join(sitepackages, 'menuinst', 'data', 'osx_launcher_arm64'), 'menuinst/data'), + (os.path.join(sitepackages, 'menuinst', 'data', 'osx_launcher_x86_64'), 'menuinst/data'), + (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_arm64'), 'menuinst/data'), + (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_x86_64'), 'menuinst/data'), + ] + extra_exe_kwargs["entitlements_file"] = "entitlements.plist" a = Analysis(['entry_point.py', 'imports.py'], pathex=['.'], - binaries=[], + binaries=binaries, datas=datas, hiddenimports=['pkg_resources.py2_warn'], hookspath=[], diff --git a/src/imports.py b/src/imports.py index 7ea0e2f..723491a 100644 --- a/src/imports.py +++ b/src/imports.py @@ -14,7 +14,15 @@ "conda_libmamba_solver", "libmambapy", ] -site_packages = os.getenv("SP_DIR", site.getsitepackages()[0]) +site_packages = os.environ.get( + "SP_DIR", # site-packages in conda-build's host environment + # if not defined, get running Python's site-packages + # Windows puts sys.prefix in this list first + next( + path for path in site.getsitepackages() + if path.endswith("site-packages") + ) +) files = [ f for package in packages @@ -263,7 +271,26 @@ import libmambapy.__init__ import libmambapy._version import libmambapy.bindings - +import menuinst.__init__ +# import menuinst._schema +import menuinst.api +import menuinst.platforms.__init__ +import menuinst.platforms.base +import menuinst.platforms.linux +import menuinst.platforms.osx +import menuinst.utils +if os.name == "nt": + import menuinst._legacy.__init__ + import menuinst._legacy.cwp + import menuinst._legacy.main + import menuinst._legacy.utils + import menuinst._legacy.win32 + import menuinst.platforms.win + import menuinst.platforms.win_utils.__init__ + import menuinst.platforms.win_utils.knownfolders + import menuinst.platforms.win_utils.registry + import menuinst.platforms.win_utils.win_elevate + import menuinst.platforms.win_utils.winshortcut try: import conda_env.__main__ except Exception: From 8c630c1512485d6d5b001d3b6c0cfd1897d4eb21 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 19:06:32 +0200 Subject: [PATCH 07/54] use new menuinst api --- src/entry_point.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/src/entry_point.py b/src/entry_point.py index 89c729b..5f8a951 100755 --- a/src/entry_point.py +++ b/src/entry_point.py @@ -9,6 +9,7 @@ import os import sys from multiprocessing import freeze_support +from pathlib import Path def _create_dummy_executor(*args, **kwargs): @@ -169,23 +170,12 @@ def _constructor_extract_tarball(): def _constructor_menuinst(prefix, pkg_names=None, root_prefix=None, remove=False): - import importlib.util - - root_prefix = root_prefix or prefix - - utility_script = os.path.join(root_prefix, "Lib", "_nsis.py") - spec = importlib.util.spec_from_file_location("constructor_utils", utility_script) - module = importlib.util.module_from_spec(spec) - spec.loader.exec_module(module) - if remove: - module.rm_menus(prefix=prefix, root_prefix=prefix) - elif pkg_names is not None: - module.mk_menus( - remove=False, - prefix=prefix, - pkg_names=pkg_names, - root_prefix=prefix, - ) + from menuinst import install + + for json_path in Path(prefix, "Menu").glob("*.json"): + if pkg_names and json_path.stem not in pkg_names: + continue + install(json_path, remove=remove, prefix=prefix, root_prefix=root_prefix) def _constructor_subcommand(): @@ -212,10 +202,6 @@ def _constructor_subcommand(): # when called with --make-menus and no package names, the value is an empty list # hence the explicit check for None elif (args.make_menus is not None) or args.rm_menus: - if sys.platform != "win32": - raise NotImplementedError( - "Menu creation and removal is only supported on Windows" - ) _constructor_menuinst( prefix=args.prefix, pkg_names=args.make_menus, From 408dcc3bf3e2e7f58c02defa9a58b3d9720a31b5 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 19:08:08 +0200 Subject: [PATCH 08/54] add test --- tests/test_main.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index 8e53682..6b8cebc 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -56,6 +56,34 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ) +def test_menuinst(tmp_path: Path): + # Check 'regular' conda can process menuinst JSONs + prefix1 = tmp_path / "prefix1" + p = run_conda( + "create", + "-p", + prefix1, + "miniforge_console_shortcut", + check=True, + capture_output=True, + text=True, + ) + assert "menuinst Exception" not in p.stdout + assert list(prefix1.glob("Menu/*.json")) + + # The constructor helper should also be able to process them + prefix2 = tmp_path / "prefix2" + p = run_conda( + "create", + "-p", + prefix2, + "--no-shortcuts", + "miniforge_console_shortcut", + check=True, + ) + p = run_conda("constructor", "--prefix", prefix2, "--make-menus", check=True) + + def test_python(): p = run_conda("python", "-V", check=True, capture_output=True, text=True) assert p.stdout.startswith("Python 3.") From 9ef8ffbc3e35cfb1f5934cdc2fbf7bd982f0a9e5 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 19:10:42 +0200 Subject: [PATCH 09/54] pre-commit --- src/conda.exe.spec | 8 ++++---- src/imports.py | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index da919be..8c22962 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -15,7 +15,7 @@ else: block_cipher = None sitepackages = os.environ.get( "SP_DIR", # site-packages in conda-build's host environment - # if not defined, get running Python's site-packages + # if not defined, get running Python's site-packages # Windows puts sys.prefix in this list first next( path for path in site.getsitepackages() @@ -25,10 +25,10 @@ sitepackages = os.environ.get( extra_exe_kwargs = {} # Non imported files need to be added manually via datas or binaries: -# Datas are not analyzed, just copied over. Binaries go through some -# linkage analysis to also bring necessary libs. This includes plain +# Datas are not analyzed, just copied over. Binaries go through some +# linkage analysis to also bring necessary libs. This includes plain # text files like JSON, modules never imported, or standalone binaries -# Shared objects and DLLs should have been caught by pyinstaller import hooks, +# Shared objects and DLLs should have been caught by pyinstaller import hooks, # but if not, add them. # Format: a list of tuples like (file-path, target-DIRECTORY) binaries = [] diff --git a/src/imports.py b/src/imports.py index 723491a..5396164 100644 --- a/src/imports.py +++ b/src/imports.py @@ -16,7 +16,7 @@ ] site_packages = os.environ.get( "SP_DIR", # site-packages in conda-build's host environment - # if not defined, get running Python's site-packages + # if not defined, get running Python's site-packages # Windows puts sys.prefix in this list first next( path for path in site.getsitepackages() @@ -272,6 +272,7 @@ import libmambapy._version import libmambapy.bindings import menuinst.__init__ + # import menuinst._schema import menuinst.api import menuinst.platforms.__init__ @@ -279,6 +280,7 @@ import menuinst.platforms.linux import menuinst.platforms.osx import menuinst.utils + if os.name == "nt": import menuinst._legacy.__init__ import menuinst._legacy.cwp From 43557ffb6bb4784c22d912cc53a5b5db8256eef9 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 19:18:32 +0200 Subject: [PATCH 10/54] fix data path on windows --- src/conda.exe.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 8c22962..27bd715 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -38,7 +38,7 @@ datas = [ ] if sys.platform == "win32": datas += [ - (os.path.join(os.getcwd(), 'constructor', 'constructor', 'nsis', '_nsis.py'), 'Lib'), + (os.path.join(sitepackages, 'constructor', 'nsis', '_nsis.py'), 'Lib'), (os.path.join(os.getcwd(), 'entry_point_base.exe'), '.'), ] elif sys.platform == "darwin": From 1b3e8ba4ddafba44acc36f89bed8e04c854925d2 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 19:19:55 +0200 Subject: [PATCH 11/54] pre-commit --- src/conda.exe.spec | 2 +- src/imports.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 27bd715..348da91 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -14,7 +14,7 @@ else: block_cipher = None sitepackages = os.environ.get( - "SP_DIR", # site-packages in conda-build's host environment + "SP_DIR", # site-packages in conda-build's host environment # if not defined, get running Python's site-packages # Windows puts sys.prefix in this list first next( diff --git a/src/imports.py b/src/imports.py index 5396164..a0ac74c 100644 --- a/src/imports.py +++ b/src/imports.py @@ -15,7 +15,7 @@ "libmambapy", ] site_packages = os.environ.get( - "SP_DIR", # site-packages in conda-build's host environment + "SP_DIR", # site-packages in conda-build's host environment # if not defined, get running Python's site-packages # Windows puts sys.prefix in this list first next( From 957ae2369366f353b42be882ec89878998632c9d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 20:10:52 +0200 Subject: [PATCH 12/54] fix exit codes --- src/entry_point.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entry_point.py b/src/entry_point.py index 5f8a951..807cca7 100755 --- a/src/entry_point.py +++ b/src/entry_point.py @@ -278,7 +278,7 @@ def _conda_main(): from conda.cli import main _fix_sys_path() - main() + return main() def main(): From c0411876a183f1765b836f255a42547b9a3afcc7 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 20:11:03 +0200 Subject: [PATCH 13/54] refine test --- tests/test_main.py | 62 +++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 17 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 6b8cebc..219a04c 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -13,8 +13,15 @@ HERE = Path(__file__).parent -def run_conda(*args, **kwargs): - return subprocess.run([CONDA_EXE, *args], **kwargs) +def run_conda(*args, **kwargs) -> subprocess.CompletedProcess: + check = kwargs.pop("check", False) + p = subprocess.run([CONDA_EXE, *args], **kwargs) + if check: + if kwargs.get("capture_output") and p.returncode: + print(p.stdout) + print(p.stderr, file=sys.stderr) + p.check_returncode() + return p @pytest.mark.parametrize("solver", ["classic", "libmamba"]) @@ -56,32 +63,53 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ) -def test_menuinst(tmp_path: Path): - # Check 'regular' conda can process menuinst JSONs - prefix1 = tmp_path / "prefix1" +_pkg_specs = ["napari-menu"] +if os.name == "nt": + _pkg_specs.append("miniforge_console_shortcut") +_pkg_specs_params = pytest.mark.parametrize("pkg_spec", _pkg_specs) + + +@_pkg_specs_params +def test_menuinst_conda(tmp_path: Path, pkg_spec: str): + "Check 'regular' conda can process menuinst JSONs" + (tmp_path / ".nonadmin").touch() # prevent elevation p = run_conda( "create", "-p", - prefix1, - "miniforge_console_shortcut", - check=True, + tmp_path, + "-y", + f"conda-forge::{pkg_spec}", + "--no-deps", capture_output=True, text=True, + check=True, ) assert "menuinst Exception" not in p.stdout - assert list(prefix1.glob("Menu/*.json")) + assert list(tmp_path.glob("Menu/*.json")) - # The constructor helper should also be able to process them - prefix2 = tmp_path / "prefix2" - p = run_conda( + +@_pkg_specs_params +def test_menuinst_constructor(tmp_path: Path, pkg_spec: str): + "The constructor helper should also be able to process menuinst JSONs" + run_kwargs = dict(capture_output=True, text=True, check=True) + (tmp_path / ".nonadmin").touch() # prevent elevation + + # --no-shortcuts on non-Windows needs https://github.com/conda/conda/pull/11882 + env = os.environ.copy() + env["CONDA_SHORTCUTS"] = "false" + run_conda( "create", "-p", - prefix2, - "--no-shortcuts", - "miniforge_console_shortcut", - check=True, + tmp_path, + "-y", + f"conda-forge::{pkg_spec}", + "--no-deps", + env=env, + **run_kwargs, ) - p = run_conda("constructor", "--prefix", prefix2, "--make-menus", check=True) + assert list(tmp_path.glob("Menu/*.json")) + run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) + run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) def test_python(): From c45d2735d1ef3c2b68e8ab64aa721a30bcfed675 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 21:17:18 +0200 Subject: [PATCH 14/54] refine test --- tests/test_main.py | 59 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 219a04c..7354aa0 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -24,6 +24,35 @@ def run_conda(*args, **kwargs) -> subprocess.CompletedProcess: return p +def _get_shortcut_dir(prefix=None): + user_mode = "user" if Path(prefix or sys.prefix, ".nonadmin").is_file() else "system" + if sys.platform == "win32": + try: + from menuinst.platforms.win_utils.knownfolders import ( + dirs_src as win_locations, + ) + + return Path(win_locations[user_mode]["start"][0]) + except ImportError: + try: + from menuinst.win32 import dirs_src as win_locations + + return Path(win_locations[user_mode]["start"][0]) + except ImportError: + from menuinst.win32 import dirs as win_locations + + return Path(win_locations[user_mode]["start"]) + if sys.platform == "darwin": + if user_mode == "user": + return Path(os.environ["HOME"], "Applications") + return Path("/Applications") + if sys.platform == "linux": + if user_mode == "user": + return Path(os.environ["HOME"], ".local", "share", "applications") + return Path("/usr/share/applications") + raise NotImplementedError(sys.platform) + + @pytest.mark.parametrize("solver", ["classic", "libmamba"]) def test_new_environment(tmp_path, solver): env = os.environ.copy() @@ -63,14 +92,24 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ) -_pkg_specs = ["napari-menu"] +_pkg_specs = [ + ( + "jaimergp/label/menuinst-tests::package_1", + {"win32": "Package 1/A.lnk", "darwin": "A.app/Contents/MacOS/a", "linux": "package-1_a.desktop"}, + ), +] if os.name == "nt": - _pkg_specs.append("miniforge_console_shortcut") -_pkg_specs_params = pytest.mark.parametrize("pkg_spec", _pkg_specs) + _pkg_specs.append( + ( + "conda-forge::miniforge_console_shortcut", + {"win32": "Anaconda3 (64-bit)/Anaconda Prompt ({prefix}).lnk"}, + ), + ) +_pkg_specs_params = pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs) @_pkg_specs_params -def test_menuinst_conda(tmp_path: Path, pkg_spec: str): +def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "Check 'regular' conda can process menuinst JSONs" (tmp_path / ".nonadmin").touch() # prevent elevation p = run_conda( @@ -78,7 +117,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str): "-p", tmp_path, "-y", - f"conda-forge::{pkg_spec}", + pkg_spec, "--no-deps", capture_output=True, text=True, @@ -86,10 +125,13 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str): ) assert "menuinst Exception" not in p.stdout assert list(tmp_path.glob("Menu/*.json")) + assert ( + _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format(prefix=tmp_path) + ).is_file() @_pkg_specs_params -def test_menuinst_constructor(tmp_path: Path, pkg_spec: str): +def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str): "The constructor helper should also be able to process menuinst JSONs" run_kwargs = dict(capture_output=True, text=True, check=True) (tmp_path / ".nonadmin").touch() # prevent elevation @@ -102,13 +144,16 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str): "-p", tmp_path, "-y", - f"conda-forge::{pkg_spec}", + pkg_spec, "--no-deps", env=env, **run_kwargs, ) assert list(tmp_path.glob("Menu/*.json")) run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) + assert ( + _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format(prefix=tmp_path) + ).is_file() run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) From 343ca654a71a6d27138132c071ff4a9334809a29 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 22 Aug 2023 21:19:33 +0200 Subject: [PATCH 15/54] pre-commit --- tests/test_main.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 7354aa0..1301c6f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -25,7 +25,9 @@ def run_conda(*args, **kwargs) -> subprocess.CompletedProcess: def _get_shortcut_dir(prefix=None): - user_mode = "user" if Path(prefix or sys.prefix, ".nonadmin").is_file() else "system" + user_mode = ( + "user" if Path(prefix or sys.prefix, ".nonadmin").is_file() else "system" + ) if sys.platform == "win32": try: from menuinst.platforms.win_utils.knownfolders import ( @@ -95,7 +97,11 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): _pkg_specs = [ ( "jaimergp/label/menuinst-tests::package_1", - {"win32": "Package 1/A.lnk", "darwin": "A.app/Contents/MacOS/a", "linux": "package-1_a.desktop"}, + { + "win32": "Package 1/A.lnk", + "darwin": "A.app/Contents/MacOS/a", + "linux": "package-1_a.desktop", + }, ), ] if os.name == "nt": @@ -126,7 +132,8 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): assert "menuinst Exception" not in p.stdout assert list(tmp_path.glob("Menu/*.json")) assert ( - _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format(prefix=tmp_path) + _get_shortcut_dir(tmp_path) + / shortcut_path[sys.platform].format(prefix=tmp_path) ).is_file() @@ -152,7 +159,8 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) assert list(tmp_path.glob("Menu/*.json")) run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) assert ( - _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format(prefix=tmp_path) + _get_shortcut_dir(tmp_path) + / shortcut_path[sys.platform].format(prefix=tmp_path) ).is_file() run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) From 6cad42367577c01a2d9edbe0d34592863c0a73c7 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 4 Sep 2023 12:45:05 +0200 Subject: [PATCH 16/54] update news --- news/36-update-menuinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/36-update-menuinst b/news/36-update-menuinst index 723ed97..f782e6a 100644 --- a/news/36-update-menuinst +++ b/news/36-update-menuinst @@ -1,6 +1,6 @@ ### Enhancements -* Bundle `menuinst` v2.0.0a0. (#36) +* Bundle `menuinst` v2.0.0a0 and import `menuinst` directly without relying on `constructor`'s `_nsis.py` module. (#36) ### Bug fixes From 42fdb7a22a073d08cd6836113906d4de36030a34 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 12:50:51 +0100 Subject: [PATCH 17/54] bump to conda 23.11 and cls 23.11.1 --- recipe/meta.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 536eae3..19e504e 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,7 +1,7 @@ -{% set conda_version = "23.7.3" %} -{% set conda_libmamba_solver_version = "23.7.0" %} -{% set libmambapy_version = "1.4.1" %} -{% set constructor_version = "3.4.5" %} +{% set conda_version = "23.11.0" %} +{% set conda_libmamba_solver_version = "23.11.1" %} +{% set libmambapy_version = "1.5.5" %} +{% set constructor_version = "3.5.0" %} {% set python_version = "3.9.15" %} {% set pyver = "".join(python_version.split(".")[:2]) %} @@ -35,7 +35,7 @@ requirements: - python ={{ python_version }} - conda ={{ conda_version }} - conda-package-handling >=1.6 - - menuinst >=2.0.0a0 + - menuinst >=2.0.1 - conda-libmamba-solver ={{ conda_libmamba_solver_version }} - libmambapy ={{ libmambapy_version }} run_constrained: From 05d2f4a1451da68e98fec242b9f4ec77ca59f87a Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 12:53:17 +0100 Subject: [PATCH 18/54] revert --- .github/workflows/tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f262ac3..31efa14 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,10 +56,7 @@ jobs: env: CONDA_SOLVER: libmamba CONDA_BLD_PATH: ${{ runner.temp }}/bld - run: | - # TEMPORARY - # conda build recipe - conda build recipe --override-channels -c conda-forge -c conda-canary/label/dev + run: conda build recipe - name: Upload package to anaconda.org shell: bash -el {0} From 3e75998cfad77ad67cb002b606d7fd70beeb13f3 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 12:53:22 +0100 Subject: [PATCH 19/54] update news --- news/36-update-menuinst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/news/36-update-menuinst b/news/36-update-menuinst index f782e6a..d8dd5eb 100644 --- a/news/36-update-menuinst +++ b/news/36-update-menuinst @@ -1,6 +1,7 @@ ### Enhancements -* Bundle `menuinst` v2.0.0a0 and import `menuinst` directly without relying on `constructor`'s `_nsis.py` module. (#36) +* Bump to `23.11.0`, `conda-libmamba-solver` 23.11.1 and `libmambapy` 1.5.5. (#36) +* Bundle `menuinst` v2.0.1 and import `menuinst` directly without relying on `constructor`'s `_nsis.py` module. (#36) ### Bug fixes From 210b0bc706b07e41506893e274faeba3a520952b Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:02:58 +0100 Subject: [PATCH 20/54] update tests --- tests/test_main.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 1301c6f..f7e179d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -96,7 +96,7 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): _pkg_specs = [ ( - "jaimergp/label/menuinst-tests::package_1", + "conda-test/label/menuinst-tests::package_1", { "win32": "Package 1/A.lnk", "darwin": "A.app/Contents/MacOS/a", @@ -131,10 +131,21 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): ) assert "menuinst Exception" not in p.stdout assert list(tmp_path.glob("Menu/*.json")) - assert ( - _get_shortcut_dir(tmp_path) - / shortcut_path[sys.platform].format(prefix=tmp_path) - ).is_file() + created_shortcut = _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format( + prefix=tmp_path + ) + assert created_shortcut.is_file() + p = run_conda( + "remove", + "-p", + tmp_path, + "-y", + pkg_spec, + capture_output=True, + text=True, + check=True, + ) + assert not created_shortcut.is_file() @_pkg_specs_params @@ -158,11 +169,12 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) ) assert list(tmp_path.glob("Menu/*.json")) run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) - assert ( - _get_shortcut_dir(tmp_path) - / shortcut_path[sys.platform].format(prefix=tmp_path) - ).is_file() + created_shortcut = _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format( + prefix=tmp_path + ) + assert created_shortcut.is_file() run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) + assert not created_shortcut.is_file() def test_python(): From 9665f4e88a3a5de29970d46f8f67607fc2e4df2b Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:10:01 +0100 Subject: [PATCH 21/54] update hash --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index cde420d..b655312 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -12,7 +12,7 @@ package: source: - path: ../ - url: https://github.com/conda/conda/archive/{{ conda_version }}.tar.gz - sha256: 273d49db8ea723426b87866381daf2df27c7bca2c3474196460d637b62de2a1c + sha256: 9276686c8a6ee536dc451cc6557685724fe275a44949ac4f741066fd23cdc7b4 folder: conda_src patches: - ../src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch From 0b7ccdb0d6b3197d04775c63d35c5a6363688df1 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:22:57 +0100 Subject: [PATCH 22/54] simply gha workflow --- .github/workflows/tests.yml | 9 ++------- recipe/meta.yaml | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 31efa14..aa080ed 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,19 +42,14 @@ jobs: with: auto-activate-base: true activate-environment: "" - miniforge-variant: Mambaforge - miniforge-version: latest - use-mamba: true run-post: false - name: Install conda-libmamba-solver shell: bash -el {0} - run: | - mamba install "conda>=22.11.1" conda-libmamba-solver conda-build anaconda-client - conda update --all --solver=libmamba + run: conda install -y conda-build anaconda-client + - name: Build recipe shell: bash -el {0} env: - CONDA_SOLVER: libmamba CONDA_BLD_PATH: ${{ runner.temp }}/bld run: conda build recipe diff --git a/recipe/meta.yaml b/recipe/meta.yaml index b655312..acde7e7 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -11,6 +11,7 @@ package: source: - path: ../ + - url: https://github.com/conda/conda/archive/{{ conda_version }}.tar.gz sha256: 9276686c8a6ee536dc451cc6557685724fe275a44949ac4f741066fd23cdc7b4 folder: conda_src From 5b60c213771a076a04ede794abee61bdb486b25f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:25:39 +0100 Subject: [PATCH 23/54] use 1.5.3 --- .github/workflows/tests.yml | 4 +--- news/36-update-menuinst | 2 +- recipe/meta.yaml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa080ed..681a953 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,13 +29,10 @@ jobs: include: - os: ubuntu-latest subdir: linux-64 - python-version: "3.9" - os: macos-latest subdir: osx-64 - python-version: "3.9" - os: windows-latest subdir: win-64 - python-version: "3.9" steps: - uses: actions/checkout@v3 - uses: conda-incubator/setup-miniconda@v2 @@ -43,6 +40,7 @@ jobs: auto-activate-base: true activate-environment: "" run-post: false + - name: Install conda-libmamba-solver shell: bash -el {0} run: conda install -y conda-build anaconda-client diff --git a/news/36-update-menuinst b/news/36-update-menuinst index d8dd5eb..c832016 100644 --- a/news/36-update-menuinst +++ b/news/36-update-menuinst @@ -1,6 +1,6 @@ ### Enhancements -* Bump to `23.11.0`, `conda-libmamba-solver` 23.11.1 and `libmambapy` 1.5.5. (#36) +* Bump to `23.11.0`, `conda-libmamba-solver` 23.11.1 and `libmambapy` 1.5.3. (#36) * Bundle `menuinst` v2.0.1 and import `menuinst` directly without relying on `constructor`'s `_nsis.py` module. (#36) ### Bug fixes diff --git a/recipe/meta.yaml b/recipe/meta.yaml index acde7e7..435020f 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,6 +1,6 @@ {% set conda_version = "23.11.0" %} {% set conda_libmamba_solver_version = "23.11.1" %} -{% set libmambapy_version = "1.5.5" %} +{% set libmambapy_version = "1.5.3" %} {% set constructor_version = "3.5.0" %} {% set python_version = "3.9.15" %} {% set pyver = "".join(python_version.split(".")[:2]) %} From b3b4a241151e9a9682eb5f941b48978ff0de0ce5 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:29:13 +0100 Subject: [PATCH 24/54] use python 3.10.13 --- news/36-update-menuinst | 2 +- recipe/meta.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/news/36-update-menuinst b/news/36-update-menuinst index c832016..959bb2f 100644 --- a/news/36-update-menuinst +++ b/news/36-update-menuinst @@ -1,6 +1,6 @@ ### Enhancements -* Bump to `23.11.0`, `conda-libmamba-solver` 23.11.1 and `libmambapy` 1.5.3. (#36) +* Bump to `python` 3.10.13, `conda` 23.11.0, `conda-libmamba-solver` 23.11.1 and `libmambapy` 1.5.3. (#36) * Bundle `menuinst` v2.0.1 and import `menuinst` directly without relying on `constructor`'s `_nsis.py` module. (#36) ### Bug fixes diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 435020f..be36403 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -2,7 +2,7 @@ {% set conda_libmamba_solver_version = "23.11.1" %} {% set libmambapy_version = "1.5.3" %} {% set constructor_version = "3.5.0" %} -{% set python_version = "3.9.15" %} +{% set python_version = "3.10.13" %} {% set pyver = "".join(python_version.split(".")[:2]) %} package: From 2a3fc3fb03684ace471cec040d213f46a9a054c9 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:31:19 +0100 Subject: [PATCH 25/54] pin to conda-build 3.27? --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 681a953..c993f4f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,9 +41,9 @@ jobs: activate-environment: "" run-post: false - - name: Install conda-libmamba-solver + - name: Install dependencies shell: bash -el {0} - run: conda install -y conda-build anaconda-client + run: conda install -y conda-build=3.27 anaconda-client - name: Build recipe shell: bash -el {0} From 5a662a52bbaf7c07102de42f2afa6d3bf27756bf Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 13:52:47 +0100 Subject: [PATCH 26/54] remove package name --- tests/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index f7e179d..a512bba 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -140,7 +140,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "-p", tmp_path, "-y", - pkg_spec, + pkg_spec.split("::")[-1], capture_output=True, text=True, check=True, From 528a866d3f0bc9a3594121617e0b3934b5faa2b9 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 14:00:36 +0100 Subject: [PATCH 27/54] fix some paths --- src/conda.exe.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index fb5b21d..5ea2439 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -44,7 +44,7 @@ datas = [ ] if sys.platform == "win32": datas += [ - (os.path.join(sitepackages, 'constructor', 'nsis', '_nsis.py'), 'Lib'), + (os.path.join(os.getcwd(), 'constructor_src', 'constructor', 'nsis', '_nsis.py'), 'Lib'), (os.path.join(os.getcwd(), 'entry_point_base.exe'), '.'), ] elif sys.platform == "darwin": @@ -54,7 +54,7 @@ elif sys.platform == "darwin": (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_arm64'), 'menuinst/data'), (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_x86_64'), 'menuinst/data'), ] - extra_exe_kwargs["entitlements_file"] = "entitlements.plist" + extra_exe_kwargs["entitlements_file"] = str(HERE / "entitlements.plist") a = Analysis(['entry_point.py', 'imports.py'], pathex=['.'], From 4f6c8f66db1dffa5a01e3694309a3216f9173440 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 19:53:53 +0100 Subject: [PATCH 28/54] paths must be str --- src/conda.exe.spec | 2 +- src/entry_point.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 5ea2439..f2168c8 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -54,7 +54,7 @@ elif sys.platform == "darwin": (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_arm64'), 'menuinst/data'), (os.path.join(sitepackages, 'menuinst', 'data', 'appkit_launcher_x86_64'), 'menuinst/data'), ] - extra_exe_kwargs["entitlements_file"] = str(HERE / "entitlements.plist") + extra_exe_kwargs["entitlements_file"] = os.path.join(HERE, "entitlements.plist") a = Analysis(['entry_point.py', 'imports.py'], pathex=['.'], diff --git a/src/entry_point.py b/src/entry_point.py index 807cca7..1d0a7be 100755 --- a/src/entry_point.py +++ b/src/entry_point.py @@ -175,7 +175,7 @@ def _constructor_menuinst(prefix, pkg_names=None, root_prefix=None, remove=False for json_path in Path(prefix, "Menu").glob("*.json"): if pkg_names and json_path.stem not in pkg_names: continue - install(json_path, remove=remove, prefix=prefix, root_prefix=root_prefix) + install(str(json_path), remove=remove, prefix=prefix, root_prefix=root_prefix) def _constructor_subcommand(): From fbe60c13459b4571a5d92900f40650640da6c7a3 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 20:02:52 +0100 Subject: [PATCH 29/54] adjust outdated docstring --- src/entry_point.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/entry_point.py b/src/entry_point.py index 1d0a7be..24e3597 100755 --- a/src/entry_point.py +++ b/src/entry_point.py @@ -186,9 +186,6 @@ def _constructor_subcommand(): - extract conda packages - extract the tarball payload contained in the shell installers - invoke menuinst to create and remove menu items on Windows - - It is supported by a module included in `constructor`, `_nsis.py`, which is placed - in `$INSTDIR\Lib\_nsis.py` on Windows installations. """ args, _ = _constructor_parse_cli() os.chdir(args.prefix) From 85ac540f9e8eafa74a246fd35a59921299e66be8 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 20:45:32 +0100 Subject: [PATCH 30/54] update test reqs --- recipe/meta.yaml | 1 + tests/requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index be36403..533a264 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -45,6 +45,7 @@ requirements: test: requires: - pytest + - menuinst # [win] source_files: - tests commands: diff --git a/tests/requirements.txt b/tests/requirements.txt index e079f8a..d93fb60 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1 +1,2 @@ pytest +menuinst From 528a5ca9c43b4f6b331ea949a19e24475ee67365 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 12 Dec 2023 21:48:35 +0100 Subject: [PATCH 31/54] debug with prints --- tests/test_main.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index a512bba..3923471 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -129,6 +129,8 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): text=True, check=True, ) + print(p.stdout) + print(p.stderr, file=sys.stderr) assert "menuinst Exception" not in p.stdout assert list(tmp_path.glob("Menu/*.json")) created_shortcut = _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format( @@ -145,6 +147,8 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): text=True, check=True, ) + print(p.stdout) + print(p.stderr, file=sys.stderr) assert not created_shortcut.is_file() @@ -153,27 +157,28 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) "The constructor helper should also be able to process menuinst JSONs" run_kwargs = dict(capture_output=True, text=True, check=True) (tmp_path / ".nonadmin").touch() # prevent elevation - - # --no-shortcuts on non-Windows needs https://github.com/conda/conda/pull/11882 - env = os.environ.copy() - env["CONDA_SHORTCUTS"] = "false" - run_conda( + p = run_conda( "create", "-p", tmp_path, "-y", pkg_spec, "--no-deps", - env=env, **run_kwargs, ) + print(p.stdout) + print(p.stderr, file=sys.stderr) assert list(tmp_path.glob("Menu/*.json")) - run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) + p = run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) + print(p.stdout) + print(p.stderr, file=sys.stderr) created_shortcut = _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format( prefix=tmp_path ) assert created_shortcut.is_file() - run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) + p = run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) + print(p.stdout) + print(p.stderr, file=sys.stderr) assert not created_shortcut.is_file() From 8891573f1159887ec0b278a96f013b057c260053 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 00:59:58 +0100 Subject: [PATCH 32/54] verbosity --- tests/test_main.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index 3923471..1eeefe3 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -120,6 +120,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): (tmp_path / ".nonadmin").touch() # prevent elevation p = run_conda( "create", + "-vvv", "-p", tmp_path, "-y", @@ -137,8 +138,10 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): prefix=tmp_path ) assert created_shortcut.is_file() + p = run_conda( "remove", + "-vvv", "-p", tmp_path, "-y", @@ -159,16 +162,19 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) (tmp_path / ".nonadmin").touch() # prevent elevation p = run_conda( "create", + "-vvv", "-p", tmp_path, "-y", pkg_spec, "--no-deps", + "--no-shortcuts", **run_kwargs, ) print(p.stdout) print(p.stderr, file=sys.stderr) assert list(tmp_path.glob("Menu/*.json")) + p = run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) print(p.stdout) print(p.stderr, file=sys.stderr) @@ -176,6 +182,7 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) prefix=tmp_path ) assert created_shortcut.is_file() + p = run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) print(p.stdout) print(p.stderr, file=sys.stderr) From 32b65da6863d5f05d2ed09b11453df0981414247 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 12:57:03 +0100 Subject: [PATCH 33/54] use needs_admin --- recipe/meta.yaml | 2 +- tests/test_main.py | 23 +++++++---------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 533a264..586d77f 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -45,7 +45,7 @@ requirements: test: requires: - pytest - - menuinst # [win] + - menuinst source_files: - tests commands: diff --git a/tests/test_main.py b/tests/test_main.py index 1eeefe3..d09ff81 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -25,25 +25,16 @@ def run_conda(*args, **kwargs) -> subprocess.CompletedProcess: def _get_shortcut_dir(prefix=None): + from menuinst.utils import needs_admin + user_mode = ( - "user" if Path(prefix or sys.prefix, ".nonadmin").is_file() else "system" + "user" if needs_admin(prefix or sys.prefix, sys.prefix) else "system" ) if sys.platform == "win32": - try: - from menuinst.platforms.win_utils.knownfolders import ( - dirs_src as win_locations, - ) - - return Path(win_locations[user_mode]["start"][0]) - except ImportError: - try: - from menuinst.win32 import dirs_src as win_locations - - return Path(win_locations[user_mode]["start"][0]) - except ImportError: - from menuinst.win32 import dirs as win_locations - - return Path(win_locations[user_mode]["start"]) + from menuinst.platforms.win_utils.knownfolders import ( + dirs_src as win_locations, + ) + return Path(win_locations[user_mode]["start"][0]) if sys.platform == "darwin": if user_mode == "user": return Path(os.environ["HOME"], "Applications") From d556efba30a6dfa26f804904af00d60c7a877968 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 12:59:24 +0100 Subject: [PATCH 34/54] require menuinst >=2 for tests --- recipe/meta.yaml | 2 +- tests/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 586d77f..94cdbdc 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -45,7 +45,7 @@ requirements: test: requires: - pytest - - menuinst + - menuinst >=2 source_files: - tests commands: diff --git a/tests/requirements.txt b/tests/requirements.txt index d93fb60..5be11a5 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,2 +1,2 @@ pytest -menuinst +menuinst>=2 From b89ab423c4e908f9fd17c87597573b74e101d4ba Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 13:31:27 +0100 Subject: [PATCH 35/54] invert --- tests/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index d09ff81..662bc7e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -28,7 +28,7 @@ def _get_shortcut_dir(prefix=None): from menuinst.utils import needs_admin user_mode = ( - "user" if needs_admin(prefix or sys.prefix, sys.prefix) else "system" + "system" if needs_admin(prefix or sys.prefix, sys.prefix) else "user" ) if sys.platform == "win32": from menuinst.platforms.win_utils.knownfolders import ( From 6114f0142c27523247fc647f424059791b3a68c0 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 13:36:15 +0100 Subject: [PATCH 36/54] pre-commit --- tests/test_main.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 662bc7e..98ac5da 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -31,9 +31,7 @@ def _get_shortcut_dir(prefix=None): "system" if needs_admin(prefix or sys.prefix, sys.prefix) else "user" ) if sys.platform == "win32": - from menuinst.platforms.win_utils.knownfolders import ( - dirs_src as win_locations, - ) + from menuinst.platforms.win_utils.knownfolders import dirs_src as win_locations return Path(win_locations[user_mode]["start"][0]) if sys.platform == "darwin": if user_mode == "user": From f3e60355abb8a3da0e8c91e03917b0890c72b015 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 13:58:01 +0100 Subject: [PATCH 37/54] try both locations because we can't know which one will be used for sure --- tests/test_main.py | 47 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 98ac5da..f1b0a93 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -24,23 +24,19 @@ def run_conda(*args, **kwargs) -> subprocess.CompletedProcess: return p -def _get_shortcut_dir(prefix=None): - from menuinst.utils import needs_admin - - user_mode = ( - "system" if needs_admin(prefix or sys.prefix, sys.prefix) else "user" - ) +def _get_shortcut_dirs(): if sys.platform == "win32": from menuinst.platforms.win_utils.knownfolders import dirs_src as win_locations - return Path(win_locations[user_mode]["start"][0]) + + return Path(win_locations["user"]["start"][0]), Path( + win_locations["system"]["start"][0] + ) if sys.platform == "darwin": - if user_mode == "user": - return Path(os.environ["HOME"], "Applications") - return Path("/Applications") + return Path(os.environ["HOME"], "Applications"), Path("/Applications") if sys.platform == "linux": - if user_mode == "user": - return Path(os.environ["HOME"], ".local", "share", "applications") - return Path("/usr/share/applications") + return Path(os.environ["HOME"], ".local", "share", "applications"), Path( + "/usr/share/applications" + ) raise NotImplementedError(sys.platform) @@ -106,7 +102,6 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): @_pkg_specs_params def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "Check 'regular' conda can process menuinst JSONs" - (tmp_path / ".nonadmin").touch() # prevent elevation p = run_conda( "create", "-vvv", @@ -123,11 +118,10 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): print(p.stderr, file=sys.stderr) assert "menuinst Exception" not in p.stdout assert list(tmp_path.glob("Menu/*.json")) - created_shortcut = _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format( - prefix=tmp_path + assert any( + (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + for folder in _get_shortcut_dirs() ) - assert created_shortcut.is_file() - p = run_conda( "remove", "-vvv", @@ -141,14 +135,16 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): ) print(p.stdout) print(p.stderr, file=sys.stderr) - assert not created_shortcut.is_file() + assert all( + not (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + for folder in _get_shortcut_dirs() + ) @_pkg_specs_params def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str): "The constructor helper should also be able to process menuinst JSONs" run_kwargs = dict(capture_output=True, text=True, check=True) - (tmp_path / ".nonadmin").touch() # prevent elevation p = run_conda( "create", "-vvv", @@ -167,15 +163,18 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) p = run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) print(p.stdout) print(p.stderr, file=sys.stderr) - created_shortcut = _get_shortcut_dir(tmp_path) / shortcut_path[sys.platform].format( - prefix=tmp_path + assert any( + (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + for folder in _get_shortcut_dirs() ) - assert created_shortcut.is_file() p = run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) print(p.stdout) print(p.stderr, file=sys.stderr) - assert not created_shortcut.is_file() + assert all( + not (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + for folder in _get_shortcut_dirs() + ) def test_python(): From 3b191b90efb5fb47674a62b8da82d250671b0c77 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 13 Dec 2023 14:01:16 +0100 Subject: [PATCH 38/54] add comment --- tests/test_main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index f1b0a93..9f5f43f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -6,6 +6,8 @@ import pytest +# TIP: You can debug the tests with this setup: +# CONDA_STANDALONE=src/entry_point.py pytest ... CONDA_EXE = os.environ.get( "CONDA_STANDALONE", os.path.join(sys.prefix, "standalone_conda", "conda.exe"), From bfeb7e61b1a7427ecd631f4f7a45e754814dfd03 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 10:13:42 +0100 Subject: [PATCH 39/54] debug with tmate --- .github/workflows/tests.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c993f4f..76cadc2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,10 +27,10 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-latest - subdir: linux-64 - - os: macos-latest - subdir: osx-64 + # - os: ubuntu-latest + # subdir: linux-64 + # - os: macos-latest + # subdir: osx-64 - os: windows-latest subdir: win-64 steps: @@ -50,6 +50,10 @@ jobs: env: CONDA_BLD_PATH: ${{ runner.temp }}/bld run: conda build recipe + + - name: Debug with tmate + uses: mxschmitt/action-tmate@v2 + timeout-minutes: 60 - name: Upload package to anaconda.org shell: bash -el {0} From 48a4f9cc761e9c6bcf56b8129c725f93ece0956f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 10:30:55 +0100 Subject: [PATCH 40/54] if always --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 76cadc2..25cd67c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,6 +52,7 @@ jobs: run: conda build recipe - name: Debug with tmate + if: always() uses: mxschmitt/action-tmate@v2 timeout-minutes: 60 From e70b7e06542af3b6cf7e8f7a1bee4982d6c427b2 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 10:37:59 +0100 Subject: [PATCH 41/54] v3 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 25cd67c..3985b32 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,7 +53,7 @@ jobs: - name: Debug with tmate if: always() - uses: mxschmitt/action-tmate@v2 + uses: mxschmitt/action-tmate@v3 timeout-minutes: 60 - name: Upload package to anaconda.org From b29d49bfe3b9d084b42169bb574189b32e089910 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 11:12:55 +0100 Subject: [PATCH 42/54] debug earlier --- .github/workflows/tests.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3985b32..fb611b7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,16 +45,17 @@ jobs: shell: bash -el {0} run: conda install -y conda-build=3.27 anaconda-client + - name: Debug with tmate + if: always() + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 60 + - name: Build recipe shell: bash -el {0} env: CONDA_BLD_PATH: ${{ runner.temp }}/bld run: conda build recipe - - name: Debug with tmate - if: always() - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 60 - name: Upload package to anaconda.org shell: bash -el {0} From 9f08097381342a6edc9193844b8d847e4f525db1 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 11:18:48 +0100 Subject: [PATCH 43/54] retrigger From 95e99a857f2407891d75d3b3c22a1e916eb0f11e Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 15:41:12 +0100 Subject: [PATCH 44/54] retrigger From 9ba2451f2e3a596a6c571a65986bed040a4e77ea Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 15:54:50 +0100 Subject: [PATCH 45/54] retrigger From f56962da7c4cc6e70dbf558ed3b850691e9d8e3d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 16:56:14 +0100 Subject: [PATCH 46/54] try different tests --- .github/workflows/tests.yml | 19 ++++++++---------- tests/test_main.py | 40 +++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fb611b7..1616f6f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,10 +27,10 @@ jobs: fail-fast: false matrix: include: - # - os: ubuntu-latest - # subdir: linux-64 - # - os: macos-latest - # subdir: osx-64 + - os: ubuntu-latest + subdir: linux-64 + - os: macos-latest + subdir: osx-64 - os: windows-latest subdir: win-64 steps: @@ -45,18 +45,15 @@ jobs: shell: bash -el {0} run: conda install -y conda-build=3.27 anaconda-client - - name: Debug with tmate - if: always() - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 60 - - name: Build recipe shell: bash -el {0} env: CONDA_BLD_PATH: ${{ runner.temp }}/bld run: conda build recipe - - + - name: Debug with tmate + if: failure() + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 60 - name: Upload package to anaconda.org shell: bash -el {0} if: github.event_name == 'push' && github.ref == 'refs/heads/main' diff --git a/tests/test_main.py b/tests/test_main.py index 9f5f43f..8deb820 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -81,7 +81,7 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ) -_pkg_specs = [ +_pkg_specs_v2 = [ ( "conda-test/label/menuinst-tests::package_1", { @@ -92,18 +92,23 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ), ] if os.name == "nt": - _pkg_specs.append( + _pkg_specs_conda = [ + *_pkg_specs_v2, ( "conda-forge::miniforge_console_shortcut", - {"win32": "Anaconda3 (64-bit)/Anaconda Prompt ({prefix}).lnk"}, + {"win32": "{base}/{base} Prompt ({name}).lnk"}, ), - ) -_pkg_specs_params = pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs) + ] +else: + _pkg_specs_conda = _pkg_specs_v2 -@_pkg_specs_params +@pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs_conda) def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "Check 'regular' conda can process menuinst JSONs" + variables = {"base": Path(sys.prefix).name, "name": tmp_path.name} + env = os.environ.copy() + env["CONDA_ROOT_PREFIX"] = sys.prefix p = run_conda( "create", "-vvv", @@ -112,6 +117,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "-y", pkg_spec, "--no-deps", + env=env, capture_output=True, text=True, check=True, @@ -121,7 +127,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): assert "menuinst Exception" not in p.stdout assert list(tmp_path.glob("Menu/*.json")) assert any( - (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() ) p = run_conda( @@ -138,12 +144,24 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): print(p.stdout) print(p.stderr, file=sys.stderr) assert all( - not (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + not (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() ) -@_pkg_specs_params +if os.name == "nt": + _pkg_specs_constructor = [ + *_pkg_specs_v2, + ( + "conda-forge::miniforge_console_shortcut", + {"win32": "{name}/{name} Prompt.lnk"}, + ), + ] +else: + _pkg_specs_constructor = _pkg_specs_v2 + + +@pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs_constructor) def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str): "The constructor helper should also be able to process menuinst JSONs" run_kwargs = dict(capture_output=True, text=True, check=True) @@ -166,7 +184,7 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) print(p.stdout) print(p.stderr, file=sys.stderr) assert any( - (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + (folder / shortcut_path[sys.platform].format(name=tmp_path.name)).is_file() for folder in _get_shortcut_dirs() ) @@ -174,7 +192,7 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) print(p.stdout) print(p.stderr, file=sys.stderr) assert all( - not (folder / shortcut_path[sys.platform].format(prefix=tmp_path)).is_file() + not (folder / shortcut_path[sys.platform].format(name=tmp_path.name)).is_file() for folder in _get_shortcut_dirs() ) From a00b6554650ed959411f28e7008ec801c02c18e7 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 17:53:32 +0100 Subject: [PATCH 47/54] use env in both calls --- tests/test_main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 8deb820..aa219fb 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -106,9 +106,13 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): @pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs_conda) def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "Check 'regular' conda can process menuinst JSONs" - variables = {"base": Path(sys.prefix).name, "name": tmp_path.name} env = os.environ.copy() env["CONDA_ROOT_PREFIX"] = sys.prefix + # The shortcut will take 'root_prefix' as the base, but conda-standalone + # sets that to its temporary 'sys.prefix' as provided by the pyinstaller + # self-extraction. We override it via 'CONDA_ROOT_PREFIX' in the same + # way 'constructor' will do it. + variables = {"base": Path(sys.prefix).name, "name": tmp_path.name} p = run_conda( "create", "-vvv", @@ -137,6 +141,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): tmp_path, "-y", pkg_spec.split("::")[-1], + env=env, capture_output=True, text=True, check=True, From ddc2421cbbc9831893e69d9c207aef5bde3e477e Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 18:03:58 +0100 Subject: [PATCH 48/54] remove tmate --- .github/workflows/tests.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1616f6f..c993f4f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,10 +50,7 @@ jobs: env: CONDA_BLD_PATH: ${{ runner.temp }}/bld run: conda build recipe - - name: Debug with tmate - if: failure() - uses: mxschmitt/action-tmate@v3 - timeout-minutes: 60 + - name: Upload package to anaconda.org shell: bash -el {0} if: github.event_name == 'push' && github.ref == 'refs/heads/main' From 7df391e26146f47146b33fe74234b4f4c5d13ae3 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 18:10:44 +0100 Subject: [PATCH 49/54] use root-prefix in both --- tests/test_main.py | 51 ++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index aa219fb..f117419 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -81,7 +81,7 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ) -_pkg_specs_v2 = [ +_pkg_specs = [ ( "conda-test/label/menuinst-tests::package_1", { @@ -92,18 +92,16 @@ def test_extract_conda_pkgs_num_processors(tmp_path: Path): ), ] if os.name == "nt": - _pkg_specs_conda = [ - *_pkg_specs_v2, + _pkg_specs.append( ( "conda-forge::miniforge_console_shortcut", {"win32": "{base}/{base} Prompt ({name}).lnk"}, ), - ] -else: - _pkg_specs_conda = _pkg_specs_v2 + ) +_pkg_specs_params = pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs) -@pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs_conda) +@_pkg_specs_params def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): "Check 'regular' conda can process menuinst JSONs" env = os.environ.copy() @@ -154,22 +152,11 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): ) -if os.name == "nt": - _pkg_specs_constructor = [ - *_pkg_specs_v2, - ( - "conda-forge::miniforge_console_shortcut", - {"win32": "{name}/{name} Prompt.lnk"}, - ), - ] -else: - _pkg_specs_constructor = _pkg_specs_v2 - - -@pytest.mark.parametrize("pkg_spec, shortcut_path", _pkg_specs_constructor) +@_pkg_specs_params def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str): "The constructor helper should also be able to process menuinst JSONs" run_kwargs = dict(capture_output=True, text=True, check=True) + variables = {"base": Path(sys.prefix).name, "name": tmp_path.name} p = run_conda( "create", "-vvv", @@ -185,19 +172,35 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) print(p.stderr, file=sys.stderr) assert list(tmp_path.glob("Menu/*.json")) - p = run_conda("constructor", "--prefix", tmp_path, "--make-menus", **run_kwargs) + p = run_conda( + "constructor", + "--root-prefix", + sys.prefix, + "--prefix", + tmp_path, + "--make-menus", + **run_kwargs, + ) print(p.stdout) print(p.stderr, file=sys.stderr) assert any( - (folder / shortcut_path[sys.platform].format(name=tmp_path.name)).is_file() + (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() ) - p = run_conda("constructor", "--prefix", tmp_path, "--rm-menus", **run_kwargs) + p = run_conda( + "constructor", + "--root-prefix", + sys.prefix, + "--prefix", + tmp_path, + "--rm-menus", + **run_kwargs, + ) print(p.stdout) print(p.stderr, file=sys.stderr) assert all( - not (folder / shortcut_path[sys.platform].format(name=tmp_path.name)).is_file() + not (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() ) From 2979d049077216a95c8b416cf172dca7be97b740 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Thu, 14 Dec 2023 18:33:49 +0100 Subject: [PATCH 50/54] use env var instead --- tests/test_main.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index f117419..d9a0649 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -172,14 +172,19 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) print(p.stderr, file=sys.stderr) assert list(tmp_path.glob("Menu/*.json")) + env = os.environ.copy() + env["CONDA_ROOT_PREFIX"] = sys.prefix p = run_conda( "constructor", - "--root-prefix", - sys.prefix, + # Not supported in micromamba's interface yet + # use CONDA_ROOT_PREFIX instead + # "--root-prefix", + # sys.prefix, "--prefix", tmp_path, "--make-menus", **run_kwargs, + env=env, ) print(p.stdout) print(p.stderr, file=sys.stderr) @@ -190,12 +195,15 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) p = run_conda( "constructor", - "--root-prefix", - sys.prefix, + # Not supported in micromamba's interface yet + # use CONDA_ROOT_PREFIX instead + # "--root-prefix", + # sys.prefix, "--prefix", tmp_path, "--rm-menus", **run_kwargs, + env=env, ) print(p.stdout) print(p.stderr, file=sys.stderr) From 7b2e7f826e80f048a2fe2e8b355e6fe96f3de09d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Sun, 17 Dec 2023 21:36:25 +0100 Subject: [PATCH 51/54] Apply suggestions from code review Co-authored-by: Jannis Leidel --- tests/test_main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index d9a0649..e11b671 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -17,13 +17,13 @@ def run_conda(*args, **kwargs) -> subprocess.CompletedProcess: check = kwargs.pop("check", False) - p = subprocess.run([CONDA_EXE, *args], **kwargs) + process = subprocess.run([CONDA_EXE, *args], **kwargs) if check: - if kwargs.get("capture_output") and p.returncode: - print(p.stdout) - print(p.stderr, file=sys.stderr) - p.check_returncode() - return p + if kwargs.get("capture_output") and process.returncode: + print(process.stdout) + print(process.stderr, file=sys.stderr) + process.check_returncode() + return process def _get_shortcut_dirs(): From 1781a745fadff7842731194f2c2213f38e9d234f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Sun, 17 Dec 2023 21:37:53 +0100 Subject: [PATCH 52/54] more p -> process --- tests/test_main.py | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index e11b671..352ab38 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -111,7 +111,7 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): # self-extraction. We override it via 'CONDA_ROOT_PREFIX' in the same # way 'constructor' will do it. variables = {"base": Path(sys.prefix).name, "name": tmp_path.name} - p = run_conda( + process = run_conda( "create", "-vvv", "-p", @@ -124,15 +124,15 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): text=True, check=True, ) - print(p.stdout) - print(p.stderr, file=sys.stderr) - assert "menuinst Exception" not in p.stdout + print(process.stdout) + print(process.stderr, file=sys.stderr) + assert "menuinst Exception" not in process.stdout assert list(tmp_path.glob("Menu/*.json")) assert any( (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() ) - p = run_conda( + process = run_conda( "remove", "-vvv", "-p", @@ -144,8 +144,8 @@ def test_menuinst_conda(tmp_path: Path, pkg_spec: str, shortcut_path: str): text=True, check=True, ) - print(p.stdout) - print(p.stderr, file=sys.stderr) + print(process.stdout) + print(process.stderr, file=sys.stderr) assert all( not (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() @@ -157,7 +157,7 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) "The constructor helper should also be able to process menuinst JSONs" run_kwargs = dict(capture_output=True, text=True, check=True) variables = {"base": Path(sys.prefix).name, "name": tmp_path.name} - p = run_conda( + process = run_conda( "create", "-vvv", "-p", @@ -168,13 +168,13 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) "--no-shortcuts", **run_kwargs, ) - print(p.stdout) - print(p.stderr, file=sys.stderr) + print(process.stdout) + print(process.stderr, file=sys.stderr) assert list(tmp_path.glob("Menu/*.json")) env = os.environ.copy() env["CONDA_ROOT_PREFIX"] = sys.prefix - p = run_conda( + process = run_conda( "constructor", # Not supported in micromamba's interface yet # use CONDA_ROOT_PREFIX instead @@ -186,14 +186,14 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) **run_kwargs, env=env, ) - print(p.stdout) - print(p.stderr, file=sys.stderr) + print(process.stdout) + print(process.stderr, file=sys.stderr) assert any( (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() ) - p = run_conda( + process = run_conda( "constructor", # Not supported in micromamba's interface yet # use CONDA_ROOT_PREFIX instead @@ -205,8 +205,8 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) **run_kwargs, env=env, ) - print(p.stdout) - print(p.stderr, file=sys.stderr) + print(process.stdout) + print(process.stderr, file=sys.stderr) assert all( not (folder / shortcut_path[sys.platform].format(**variables)).is_file() for folder in _get_shortcut_dirs() @@ -214,10 +214,10 @@ def test_menuinst_constructor(tmp_path: Path, pkg_spec: str, shortcut_path: str) def test_python(): - p = run_conda("python", "-V", check=True, capture_output=True, text=True) - assert p.stdout.startswith("Python 3.") + process = run_conda("python", "-V", check=True, capture_output=True, text=True) + assert process.stdout.startswith("Python 3.") - p = run_conda( + process = run_conda( "python", "-m", "calendar", @@ -227,9 +227,9 @@ def test_python(): capture_output=True, text=True, ) - assert "2023" in p.stdout + assert "2023" in process.stdout - p = run_conda( + process = run_conda( "python", "-c", "import sys; print(sys.argv)", @@ -238,4 +238,4 @@ def test_python(): capture_output=True, text=True, ) - assert eval(p.stdout) == ["-c", "extra-arg"] + assert eval(process.stdout) == ["-c", "extra-arg"] From c650ca107f9c0272b18de9c402ee52f19b0c3430 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 18 Dec 2023 16:54:09 +0100 Subject: [PATCH 53/54] Update .github/workflows/tests.yml Co-authored-by: jaimergp --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c993f4f..81caf0c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,7 +43,7 @@ jobs: - name: Install dependencies shell: bash -el {0} - run: conda install -y conda-build=3.27 anaconda-client + run: conda install -y "conda-build!=3.28.0,!=3.28.1" anaconda-client - name: Build recipe shell: bash -el {0} From 7996542c14968732412d911b54d3fe0384cb8c11 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 18 Dec 2023 17:17:42 +0100 Subject: [PATCH 54/54] Update constructor's sha --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 94cdbdc..a468b46 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -21,7 +21,7 @@ source: - ../src/conda_patches/0003-Return-unknown-module-in-deprecations.patch - url: https://github.com/conda/constructor/archive/{{ constructor_version }}.tar.gz # [win] - sha256: 787ffd85e9414bdf70fe531f01eab3987a040e3f6a6ac3a01409f4d332f7de9e # [win] + sha256: 928ddd32942093a89563ef2eb3abb116be17795cf277545ea9f6e9a0a4ba7a17 # [win] folder: constructor_src # [win] build: