From 5478a74a1f38529444e3c475030b915a1174924c Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 20 Jun 2023 17:36:06 +0200 Subject: [PATCH 01/24] Try to update recipe --- recipe/meta.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index bb93496..3dd92cb 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,5 +1,5 @@ -{% set conda_version = "22.11.1" %} -{% set constructor_version = "3.3.1" %} +{% set conda_version = "23.5.0" %} +{% set constructor_version = "3.4.3" %} {% set python_version = "3.9.15" %} package: From 219d82013234eaeae3d364602b05c204c53d49e3 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 20 Jun 2023 17:45:48 +0200 Subject: [PATCH 02/24] update hash --- recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 3dd92cb..5a8e263 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -9,7 +9,7 @@ package: source: - path: ../ - url: https://github.com/conda/conda/archive/{{ conda_version }}.tar.gz - sha256: f9256a7e71a9f35063b683f6c7823acf05c1f75468fc609954f1f5efae7c03ac + sha256: 57155b96dd94ba95e421b4c36695dbf6972bcfb9b5e41ee0674bb796b8386f58 folder: conda_src patches: - ../src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch From fcdb2580f96c873916daaf9e045f7088b78279e3 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 21 Jun 2023 11:39:33 +0200 Subject: [PATCH 03/24] update patches --- ...name-and-replace-entrypoint-stub-exe.patch | 19 ++++++++++--------- ...-directly-instead-of-_call_ing-conda.patch | 7 ++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch b/src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch index f39d3bb..f5813f6 100644 --- a/src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch +++ b/src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch @@ -2,27 +2,28 @@ From 1bac6f78cfb77b5c4ab4814e8693a0b7ab6762f9 Mon Sep 17 00:00:00 2001 From: Nehal J Wani Date: Tue, 13 Aug 2019 07:43:35 -0400 Subject: [PATCH 1/2] Rename and replace entrypoint stub exe +Updated: 2023-06-21 by @jaimergp, conda 23.5.0 compatibility --- conda/core/path_actions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/conda/core/path_actions.py b/conda/core/path_actions.py -index 01c6938f7..70ca2166b 100644 +index ab306cf7d..99b8acbb3 100644 --- a/conda/core/path_actions.py +++ b/conda/core/path_actions.py -@@ -258,8 +258,12 @@ class LinkPathAction(CreateInPrefixPathAction): - def create_python_entry_point_windows_exe_action(cls, transaction_context, package_info, - target_prefix, requested_link_type, - entry_point_def): +@@ -299,8 +299,12 @@ class LinkPathAction(CreateInPrefixPathAction): + requested_link_type, + entry_point_def, + ): - source_directory = context.conda_prefix -- source_short_path = 'Scripts/conda.exe' -+ if lexists(join(sys.prefix, 'entry_point_base.exe')): +- source_short_path = "Scripts/conda.exe" ++ if lexists(join(sys.prefix, "entry_point_base.exe")): + source_directory = sys.prefix -+ source_short_path = 'entry_point_base.exe' ++ source_short_path = "entry_point_base.exe" + else: + source_directory = context.conda_prefix -+ source_short_path = 'Scripts/conda.exe' ++ source_short_path = "Scripts/conda.exe" command, _, _ = parse_entry_point_def(entry_point_def) target_short_path = "Scripts/%s.exe" % command source_path_data = PathDataV1( diff --git a/src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch b/src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch index 73fdcb8..f7509f3 100644 --- a/src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch +++ b/src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch @@ -2,12 +2,13 @@ From: Nehal J Wani Date: Tue, 13 Aug 2019 07:46:10 -0400 Subject: [PATCH 2/2] Manipulate PATH directly instead of _call_ing conda.bat Updated: 2022-12-14 by @jaimergp, conda 22.11.1 compatibility +Updated: 2023-06-21 by @jaimergp, conda 23.5.0 compatibility diff --git a/conda/utils.py b/conda/utils.py -index b39912282..c3a2a8e89 100644 +index bc340fb10..d6b8a208d 100644 --- a/conda/utils.py +++ b/conda/utils.py -@@ -395,7 +395,16 @@ def wrap_subprocess_call( +@@ -419,7 +419,16 @@ def wrap_subprocess_call( # after all! # fh.write("@FOR /F \"tokens=100\" %%F IN ('chcp') DO @SET CONDA_OLD_CHCP=%%F\n") # fh.write('@chcp 65001>NUL\n') @@ -24,4 +25,4 @@ index b39912282..c3a2a8e89 100644 + ) fh.write(f"{silencer}IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL%\n") if debug_wrapper_scripts: - fh.write('echo *** environment after *** 1>&2\n') + fh.write("echo *** environment after *** 1>&2\n") From 737f413f0f1c55be5fc1a7f60d459d0134ad559d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Wed, 21 Jun 2023 11:57:08 +0200 Subject: [PATCH 04/24] update hash; do not run action cleanup --- .github/workflows/tests.yml | 1 + recipe/meta.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a7855d..2c1025c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -38,6 +38,7 @@ jobs: miniforge-version: latest use-mamba: true conda-build-version: "*" + run-post: false - name: Install conda-libmamba-solver shell: bash -el {0} run: conda install "conda>=22.11.1" conda-libmamba-solver diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 5a8e263..83f5519 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -16,7 +16,7 @@ source: - ../src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch - url: https://github.com/conda/constructor/archive/{{ constructor_version }}.tar.gz # [win] - sha256: b000dde0ac8641c92f7342362173968505d4e85845be37655b5b9221cb65f3a8 # [win] + sha256: 4a1f5ae2ba74175cc5d0770d6d43147253091f8869fa20568a02d5ddb7963dee # [win] folder: constructor_src # [win] build: From 3cde6ab0161a910018b2306abbd68df1dd7935da Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 12:08:18 +0200 Subject: [PATCH 05/24] try conda 23.7.2 and constructor 3.4.5 --- recipe/bld.bat | 2 ++ recipe/build.sh | 2 +- recipe/meta.yaml | 11 ++++++----- ...eturn-unknown-module-in-deprecations.patch | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/conda_patches/0003-Return-unknown-module-in-deprecations.patch diff --git a/recipe/bld.bat b/recipe/bld.bat index 0fe24c7..f18aaad 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -4,6 +4,8 @@ RENAME "%SP_DIR%\conda\core\path_actions.py" path_actions.py.bak || goto :error COPY conda_src\conda\core\path_actions.py "%SP_DIR%\conda\core\path_actions.py" || goto :error RENAME "%SP_DIR%\conda\utils.py" utils.py.bak || goto :error COPY conda_src\conda\utils.py "%SP_DIR%\conda\utils.py" || goto :error +RENAME "%SP_DIR%\conda\deprecations.py" deprecations.py.bak || goto :error +COPY conda_src\conda\deprecations.py "%SP_DIR%\conda\deprecations.py" || goto :error :: we need these for noarch packages with entry points to work on windows COPY "conda_src\conda\shell\cli-%ARCH%.exe" entry_point_base.exe || goto :error diff --git a/recipe/build.sh b/recipe/build.sh index 628cbcb..e819f4c 100644 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -2,7 +2,7 @@ set -euxo pipefail # patched conda files # new files in patches need to be added here -for fname in "core/path_actions.py" "utils.py"; do +for fname in "core/path_actions.py" "utils.py" "deprecations.py"; do mv "$SP_DIR/conda/${fname}" "$SP_DIR/conda/${fname}.bak" cp "conda_src/conda/${fname}" "$SP_DIR/conda/${fname}" done diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 83f5519..c2ddb34 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,5 +1,5 @@ -{% set conda_version = "23.5.0" %} -{% set constructor_version = "3.4.3" %} +{% set conda_version = "23.7.2" %} +{% set constructor_version = "3.4.5" %} {% set python_version = "3.9.15" %} package: @@ -9,14 +9,15 @@ package: source: - path: ../ - url: https://github.com/conda/conda/archive/{{ conda_version }}.tar.gz - sha256: 57155b96dd94ba95e421b4c36695dbf6972bcfb9b5e41ee0674bb796b8386f58 + sha256: 4fd44862ef87c73e4641b0c40a0873e103a097d6fd4a992041cfa9177ce20ac8 folder: conda_src patches: - ../src/conda_patches/0001-Rename-and-replace-entrypoint-stub-exe.patch - ../src/conda_patches/0002-Manipulate-PATH-directly-instead-of-_call_ing-conda.patch + - ../src/conda_patches/0003-Return-unknown-module-in-deprecations.patch - url: https://github.com/conda/constructor/archive/{{ constructor_version }}.tar.gz # [win] - sha256: 4a1f5ae2ba74175cc5d0770d6d43147253091f8869fa20568a02d5ddb7963dee # [win] + sha256: 425a7b6825a3dba21c21d9234ff1ceac8efea6ebc14e2b0e80d0880f502b3e01 # [win] folder: constructor_src # [win] build: @@ -30,7 +31,7 @@ requirements: - python ={{ python_version }} - conda ={{ conda_version }} - conda-package-handling >=1.6 - - menuinst >=1.4.18 # [win] + - menuinst >=1.4.18,<2.0a0 # [win] run_constrained: - constructor >={{ constructor_version }} diff --git a/src/conda_patches/0003-Return-unknown-module-in-deprecations.patch b/src/conda_patches/0003-Return-unknown-module-in-deprecations.patch new file mode 100644 index 0000000..0df3d51 --- /dev/null +++ b/src/conda_patches/0003-Return-unknown-module-in-deprecations.patch @@ -0,0 +1,19 @@ +From: jaimergp +Date: Wed Jun 21 18:53:36 CEST 2023 +Subject: Return 'unknown' instead of raising an exception when the calling module cannot be determined + +diff --git a/conda/deprecations.py b/conda/deprecations.py +index 61154a1ee..9273cdde6 100644 +--- a/conda/deprecations.py ++++ b/conda/deprecations.py +@@ -284,7 +284,9 @@ class DeprecationHandler: + module = inspect.getmodule(frame[0]) + return (module, module.__name__) + except (IndexError, AttributeError): +- raise DeprecatedError("unable to determine the calling module") from None ++ # raise DeprecatedError("unable to determine the calling module") from None ++ import sys as unknown ++ return (unknown, "") + + def _generate_message( + self, deprecate_in: str, remove_in: str, prefix: str, addendum: str From e197d097b3207333cd2120efc4d2963d02170c08 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 12:14:15 +0200 Subject: [PATCH 06/24] exclude patches from pre-commit --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3034036..730f559 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: - id: mixed-line-ending - id: end-of-file-fixer - id: trailing-whitespace + # ensure syntaxes are valid - id: check-toml - id: check-yaml @@ -33,3 +34,4 @@ repos: rev: 6.0.0 hooks: - id: flake8 +exclude: "^src/conda_patches/.*patch$" From c7373bc1ddf67eb2d9776a20511e70b5f67f4159 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 12:16:52 +0200 Subject: [PATCH 07/24] try to update everything --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c1025c..2eba45c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,7 +41,9 @@ jobs: run-post: false - name: Install conda-libmamba-solver shell: bash -el {0} - run: conda install "conda>=22.11.1" conda-libmamba-solver + run: | + conda install "conda>=22.11.1" conda-libmamba-solver + conda update --all --solver=libmamba - name: Build recipe shell: bash -el {0} env: From d0e9d8d914c3c94beb239e951dd8f189379971a4 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 12:39:07 +0200 Subject: [PATCH 08/24] install conda-build via mamba --- .github/workflows/tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2eba45c..9f024b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,12 +37,11 @@ jobs: miniforge-variant: Mambaforge miniforge-version: latest use-mamba: true - conda-build-version: "*" run-post: false - name: Install conda-libmamba-solver shell: bash -el {0} run: | - conda install "conda>=22.11.1" conda-libmamba-solver + mamba install "conda>=22.11.1" conda-libmamba-solver conda-build conda update --all --solver=libmamba - name: Build recipe shell: bash -el {0} From 832fa9798eb568a36ef964fbbc067686c858bfcf Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 12:56:22 +0200 Subject: [PATCH 09/24] add news --- news/25-update-conda-constructor | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/25-update-conda-constructor diff --git a/news/25-update-conda-constructor b/news/25-update-conda-constructor new file mode 100644 index 0000000..ae7b820 --- /dev/null +++ b/news/25-update-conda-constructor @@ -0,0 +1,19 @@ +### Enhancements + +* Update to use `conda` 23.7.2 and `constructor` 3.4.5. (#25) + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +* From a2ae564ca6623263a282092d5bd4d3a02d680244 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:00:35 +0200 Subject: [PATCH 10/24] update imports.py --- src/imports.py | 175 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 120 insertions(+), 55 deletions(-) diff --git a/src/imports.py b/src/imports.py index d420da0..9c26731 100644 --- a/src/imports.py +++ b/src/imports.py @@ -1,63 +1,37 @@ -# These help pyinstaller find all the stuff it needs. Add your packages to generate more -# specific imports. +# These help pyinstaller find all the stuff it needs. Add your packages to generate more specific imports. + +import importlib.util import glob import os import site -import sys -packages = ['conda', 'conda-package-handling'] -if sys.platform == "win32": - packages.append('menuinst') +packages = ['conda', 'conda_package_handling', 'menuinst', 'conda_env'] +site_packages = os.getenv('SP_DIR', site.getsitepackages()[0]) files = [ f for package in packages - for f in glob.glob( - os.path.join( - os.getenv("SP_DIR", site.getsitepackages()[0]), package, "**/*.py" - ), - recursive=True, - ) + for f in glob.glob(os.path.join(site_packages, package, "**/*.py"), recursive=True) ] -import importlib.util - modules = {} -for f in files: +for f in sorted(files): + if "__main__" in f: + continue spec = importlib.util.spec_from_file_location(f, f) modules[f] = importlib.util.module_from_spec(spec) - -print(modules.keys()) + print(os.path.relpath(f, site_packages).removesuffix('.py').replace(os.path.sep, '.')) import conda.__init__ -import conda.__main__ +import conda.__version__ import conda._vendor.__init__ import conda._vendor.appdirs -import conda._vendor.auxlib.__init__ -import conda._vendor.auxlib._vendor.__init__ -import conda._vendor.auxlib._vendor.boltons.__init__ -import conda._vendor.auxlib._vendor.boltons.timeutils -import conda._vendor.auxlib._vendor.five -import conda._vendor.auxlib._vendor.six -import conda._vendor.auxlib.collection -import conda._vendor.auxlib.compat -import conda._vendor.auxlib.configuration -import conda._vendor.auxlib.crypt -import conda._vendor.auxlib.decorators -import conda._vendor.auxlib.deprecation -import conda._vendor.auxlib.entity -import conda._vendor.auxlib.exceptions -import conda._vendor.auxlib.factory -import conda._vendor.auxlib.ish -import conda._vendor.auxlib.logz -import conda._vendor.auxlib.packaging -import conda._vendor.auxlib.path -import conda._vendor.auxlib.type_coercion import conda._vendor.boltons.__init__ import conda._vendor.boltons.setutils import conda._vendor.boltons.timeutils -import conda._vendor.cpuinfo -import conda._vendor.distro -import conda._vendor.frozendict +import conda._vendor.cpuinfo.__init__ +import conda._vendor.cpuinfo.cpuinfo +# import conda._vendor.distro +import conda._vendor.frozendict.__init__ import conda._vendor.toolz.__init__ import conda._vendor.toolz.compatibility import conda._vendor.toolz.dicttoolz @@ -65,46 +39,58 @@ import conda._vendor.toolz.recipes import conda._vendor.toolz.utils import conda._vendor.tqdm.__init__ -import conda._vendor.tqdm.__main__ +# import conda._vendor.tqdm.__main__ import conda._vendor.tqdm._main import conda._vendor.tqdm._monitor import conda._vendor.tqdm._tqdm import conda._vendor.tqdm._utils -import conda._vendor.tqdm._version -import conda._vendor.urllib3.__init__ -import conda._vendor.urllib3.exceptions -import conda._vendor.urllib3.util.__init__ -import conda._vendor.urllib3.util.url +import conda._vendor.tqdm.asyncio +import conda._vendor.tqdm.auto +import conda._vendor.tqdm.cli +import conda._vendor.tqdm.std +import conda._vendor.tqdm.utils +import conda._vendor.tqdm.version import conda.activate import conda.api +import conda.auxlib.__init__ +import conda.auxlib.collection +import conda.auxlib.compat +import conda.auxlib.decorators +import conda.auxlib.entity +import conda.auxlib.exceptions +import conda.auxlib.ish +import conda.auxlib.logz +import conda.auxlib.packaging +import conda.auxlib.type_coercion import conda.base.__init__ import conda.base.constants import conda.base.context import conda.base.exceptions import conda.cli.__init__ -import conda.cli.activate import conda.cli.common import conda.cli.conda_argparse import conda.cli.find_commands import conda.cli.install import conda.cli.main import conda.cli.main_clean +import conda.cli.main_compare import conda.cli.main_config import conda.cli.main_create -import conda.cli.main_help import conda.cli.main_info import conda.cli.main_init import conda.cli.main_install import conda.cli.main_list +import conda.cli.main_notices import conda.cli.main_package import conda.cli.main_pip import conda.cli.main_remove +import conda.cli.main_rename import conda.cli.main_run import conda.cli.main_search import conda.cli.main_update -import conda.cli.parsers import conda.cli.python_api import conda.common.__init__ +import conda.common._logic import conda.common._os.__init__ import conda.common._os.linux import conda.common._os.unix @@ -116,15 +102,15 @@ import conda.common.decorators import conda.common.disk import conda.common.io +import conda.common.iterators import conda.common.logic import conda.common.path import conda.common.pkg_formats.__init__ -import conda.common.pkg_formatsthon +import conda.common.pkg_formats.python import conda.common.serialize import conda.common.signals import conda.common.toposort import conda.common.url -import conda.compat import conda.core.__init__ import conda.core.envs_manager import conda.core.index @@ -137,6 +123,8 @@ import conda.core.prefix_data import conda.core.solve import conda.core.subdir_data +import conda.deprecations +import conda.exception_handler import conda.exceptions import conda.exports import conda.gateways.__init__ @@ -157,9 +145,14 @@ import conda.gateways.disk.test import conda.gateways.disk.update import conda.gateways.logging +import conda.gateways.repodata.__init__ +import conda.gateways.repodata.jlap.__init__ +import conda.gateways.repodata.jlap.core +import conda.gateways.repodata.jlap.fetch +import conda.gateways.repodata.jlap.interface +import conda.gateways.repodata.lock import conda.gateways.subprocess import conda.history -import conda.install import conda.instructions import conda.lock import conda.misc @@ -173,16 +166,88 @@ import conda.models.prefix_graph import conda.models.records import conda.models.version +import conda.notices.__init__ +import conda.notices.cache +import conda.notices.core +import conda.notices.fetch +import conda.notices.types +import conda.notices.views import conda.plan +import conda.plugins.__init__ +import conda.plugins.hookspec +import conda.plugins.manager +import conda.plugins.solvers +import conda.plugins.subcommands.__init__ +import conda.plugins.subcommands.doctor.__init__ +import conda.plugins.subcommands.doctor.cli +import conda.plugins.subcommands.doctor.health_checks +import conda.plugins.types +import conda.plugins.virtual_packages.__init__ +import conda.plugins.virtual_packages.archspec +import conda.plugins.virtual_packages.cuda +import conda.plugins.virtual_packages.linux +import conda.plugins.virtual_packages.osx +import conda.plugins.virtual_packages.windows import conda.resolve +import conda.testing.__init__ +import conda.testing.cases +import conda.testing.fixtures +import conda.testing.gateways.__init__ +try: + import conda.testing.gateways.fixtures +except Exception: + pass +import conda.testing.helpers +import conda.testing.integration +import conda.testing.notices.__init__ +import conda.testing.notices.fixtures +import conda.testing.notices.helpers +import conda.testing.solver_helpers +import conda.trust.__init__ +import conda.trust.constants +import conda.trust.signature_verification import conda.utils +import conda_env.__init__ +import conda_env.cli.__init__ +import conda_env.cli.common +import conda_env.cli.main +import conda_env.cli.main_config +import conda_env.cli.main_create +import conda_env.cli.main_export +import conda_env.cli.main_list +import conda_env.cli.main_remove +import conda_env.cli.main_update +import conda_env.cli.main_vars +import conda_env.env +import conda_env.installers.__init__ +import conda_env.installers.base +import conda_env.installers.conda +import conda_env.installers.pip +import conda_env.pip_util +import conda_env.specs.__init__ +import conda_env.specs.binstar +import conda_env.specs.requirements +import conda_env.specs.yaml_file import conda_package_handling.__init__ -import conda_package_handling.__main__ -import conda_package_handling._version import conda_package_handling.api import conda_package_handling.cli import conda_package_handling.conda_fmt +import conda_package_handling.exceptions import conda_package_handling.interface +import conda_package_handling.streaming import conda_package_handling.tarball import conda_package_handling.utils import conda_package_handling.validate + +try: + import conda_env.__main__ +except Exception: + pass +try: + import conda_package_handling.__main__ +except Exception: + pass +try: + import conda.__main__ +except Exception: + pass From 6513af1fa6aa1d25ee032bc5ed7aa2746d4ec225 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:11:02 +0200 Subject: [PATCH 11/24] add entitlements to macos builds this allows us to not having to patch things on constructor when signing has been requested --- src/_generate_entitlements.py | 23 +++++++++++++++++++++++ src/conda.exe.spec | 6 +++++- src/entitlements.plist | 16 ++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/_generate_entitlements.py create mode 100644 src/entitlements.plist diff --git a/src/_generate_entitlements.py b/src/_generate_entitlements.py new file mode 100644 index 0000000..8cc7899 --- /dev/null +++ b/src/_generate_entitlements.py @@ -0,0 +1,23 @@ +""" +Script to generate the entitlements.plist file +""" + +import os +import plistlib + + +plist = dict.fromkeys( + ( + "com.apple.security.cs.allow-jit", + "com.apple.security.cs.allow-unsigned-executable-memory", + "com.apple.security.cs.disable-executable-page-protection", + "com.apple.security.cs.disable-library-validation", + "com.apple.security.cs.allow-dyld-environment-variables", + ), + True +) + + +here = os.path.dirname(__file__) +with open(os.path.join(here, "entitlements.plist"), "wb") as f: + plistlib.dump(plist, f) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 5e2ea48..7f4a381 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -4,10 +4,13 @@ import sys block_cipher = None +extra_exe_kwargs = {} datas = [] 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'), '.')] +elif sys.platform == "darwin": + extra_exe_kwargs["entitlements_file"] = "entitlements.plist" a = Analysis(['entry_point.py', 'imports.py'], pathex=['.'], @@ -37,4 +40,5 @@ exe = EXE(pyz, upx=True, upx_exclude=[], runtime_tmpdir=None, - console=True ) + console=True, + **extra_exe_kwargs) diff --git a/src/entitlements.plist b/src/entitlements.plist new file mode 100644 index 0000000..00f46d6 --- /dev/null +++ b/src/entitlements.plist @@ -0,0 +1,16 @@ + + + + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.disable-executable-page-protection + + com.apple.security.cs.disable-library-validation + + + From 98f1fe4af2cc2c0f0ab374215480d455585f6cbc Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:12:54 +0200 Subject: [PATCH 12/24] pre-commit --- src/_generate_entitlements.py | 1 - src/imports.py | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/_generate_entitlements.py b/src/_generate_entitlements.py index 8cc7899..ecf6b2f 100644 --- a/src/_generate_entitlements.py +++ b/src/_generate_entitlements.py @@ -5,7 +5,6 @@ import os import plistlib - plist = dict.fromkeys( ( "com.apple.security.cs.allow-jit", diff --git a/src/imports.py b/src/imports.py index 9c26731..7d0d42e 100644 --- a/src/imports.py +++ b/src/imports.py @@ -1,7 +1,8 @@ -# These help pyinstaller find all the stuff it needs. Add your packages to generate more specific imports. +# These help pyinstaller find all the stuff it needs. +# Add your packages to generate more specific imports. -import importlib.util import glob +import importlib.util import os import site @@ -30,6 +31,7 @@ import conda._vendor.boltons.timeutils import conda._vendor.cpuinfo.__init__ import conda._vendor.cpuinfo.cpuinfo + # import conda._vendor.distro import conda._vendor.frozendict.__init__ import conda._vendor.toolz.__init__ @@ -39,6 +41,7 @@ import conda._vendor.toolz.recipes import conda._vendor.toolz.utils import conda._vendor.tqdm.__init__ + # import conda._vendor.tqdm.__main__ import conda._vendor.tqdm._main import conda._vendor.tqdm._monitor @@ -193,6 +196,7 @@ import conda.testing.cases import conda.testing.fixtures import conda.testing.gateways.__init__ + try: import conda.testing.gateways.fixtures except Exception: From 6cfeb6457d39e45bfa8b3fbdd4fbe15d69012457 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:16:30 +0200 Subject: [PATCH 13/24] amend news --- news/25-update-conda-constructor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/news/25-update-conda-constructor b/news/25-update-conda-constructor index ae7b820..9ff16b7 100644 --- a/news/25-update-conda-constructor +++ b/news/25-update-conda-constructor @@ -1,10 +1,11 @@ ### Enhancements -* Update to use `conda` 23.7.2 and `constructor` 3.4.5. (#25) +* Update recipe and patches to use `conda` 23.7.2 and `constructor` 3.4.5. (#25) +* Sign macOS builds with entitlements so that they can be notarized. (#25) ### Bug fixes -* +* Adjust `imports.py` to include some previously missing modules. (#25) ### Deprecations From 5d3e9c29e3e7955c708acfac32433fd7ba65b8b5 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:27:54 +0200 Subject: [PATCH 14/24] use pytest --- recipe/meta.yaml | 11 +++++------ tests/requirements.txt | 1 + tests/test_main.py | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 tests/requirements.txt create mode 100644 tests/test_main.py diff --git a/recipe/meta.yaml b/recipe/meta.yaml index c2ddb34..2f312ca 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -36,13 +36,12 @@ requirements: - constructor >={{ constructor_version }} test: + requires: + - pytest + source_files: + - tests commands: - - export CONDA_SOLVER="classic" # [unix] - - ${PREFIX}/standalone_conda/conda.exe -V # [unix] - - ${PREFIX}/standalone_conda/conda.exe create -y -p ./env_test zlib tqdm # [unix] - - set "CONDA_SOLVER=classic" # [win] - - '%PREFIX%\standalone_conda\conda.exe -V' # [win] - - '%PREFIX%\standalone_conda\conda.exe create -y -p env_test zlib tqdm' # [win] + - pytest -vv about: home: https://github.com/conda/conda-standalone diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..e079f8a --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1 @@ +pytest diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 0000000..c64c875 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,20 @@ +import os +import subprocess +import sys + + +CONDA_EXE = os.environ.get( + "CONDA_STANDALONE", + os.path.join(sys.prefix, "standalone_conda", "conda.exe") +) + + +def run_conda(*args, **kwargs): + args = (CONDA_EXE, *args) + return subprocess.run([CONDA_EXE, *args], **kwargs) + + +def test_new_environment(tmp_path): + p = run_conda("create", "-p", tmp_path / "env", "-y", "-c", "conda-forge", "libzlib") + p.check_returncode() + assert list((tmp_path / "env" / "conda-meta").glob("libzlib-*.json")) From b3e85d2a63c41994013fe1aa8786c7f28372c6cc Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:28:49 +0200 Subject: [PATCH 15/24] amend news --- news/25-update-conda-constructor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/25-update-conda-constructor b/news/25-update-conda-constructor index 9ff16b7..e324c97 100644 --- a/news/25-update-conda-constructor +++ b/news/25-update-conda-constructor @@ -17,4 +17,4 @@ ### Other -* +* Start a `pytest` test suite. (#25) From 9d3f2dd886be2a0983c7eb1db934495e730fa424 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 13:29:08 +0200 Subject: [PATCH 16/24] pre-commit --- tests/test_main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index c64c875..438116e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -2,7 +2,6 @@ import subprocess import sys - CONDA_EXE = os.environ.get( "CONDA_STANDALONE", os.path.join(sys.prefix, "standalone_conda", "conda.exe") From 23555614180e7cf21f8dc212ecb9ea3963a0967b Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 15:51:09 +0200 Subject: [PATCH 17/24] remove dup args --- tests/test_main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 438116e..48ad73c 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -9,7 +9,6 @@ def run_conda(*args, **kwargs): - args = (CONDA_EXE, *args) return subprocess.run([CONDA_EXE, *args], **kwargs) From 023c30fcee8dc1704c0658727a3a1a719c2b4dae Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 18:48:05 +0200 Subject: [PATCH 18/24] configure solver --- tests/test_main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 48ad73c..4cfa234 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -13,6 +13,16 @@ def run_conda(*args, **kwargs): def test_new_environment(tmp_path): - p = run_conda("create", "-p", tmp_path / "env", "-y", "-c", "conda-forge", "libzlib") - p.check_returncode() + env = os.environ.copy() + env["CONDA_SOLVER"] = "classic" + run_conda("create", + "-p", + tmp_path / "env", + "-y", + "-c", + "conda-forge", + "libzlib", + env=env, + check=True, + ) assert list((tmp_path / "env" / "conda-meta").glob("libzlib-*.json")) From 962c88751f31c911bd83b681e4b266d3a38f047f Mon Sep 17 00:00:00 2001 From: jaimergp Date: Fri, 4 Aug 2023 18:50:55 +0200 Subject: [PATCH 19/24] pre-commit --- tests/test_main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 4cfa234..5b2cf41 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -15,7 +15,8 @@ def run_conda(*args, **kwargs): def test_new_environment(tmp_path): env = os.environ.copy() env["CONDA_SOLVER"] = "classic" - run_conda("create", + run_conda( + "create", "-p", tmp_path / "env", "-y", From 9918a0f526318087f97ac17dab4598c6b354c8b5 Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 7 Aug 2023 18:55:18 +0200 Subject: [PATCH 20/24] paths are relative to working directory, not input file --- src/conda.exe.spec | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index 7f4a381..dc28c31 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -2,6 +2,13 @@ import os import sys +for arg in sys.argv: + if arg.endswith("conda.exe.spec"): + HERE = os.path.abspath(os.path.dirname(arg)) + break +else: + HERE = os.path.join(os.path.getcwd(), "src") + block_cipher = None extra_exe_kwargs = {} @@ -10,7 +17,7 @@ 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'), '.')] elif sys.platform == "darwin": - extra_exe_kwargs["entitlements_file"] = "entitlements.plist" + extra_exe_kwargs["entitlements_file"] = os.path.join(HERE, "entitlements.plist") a = Analysis(['entry_point.py', 'imports.py'], pathex=['.'], @@ -33,7 +40,7 @@ exe = EXE(pyz, a.datas, [], name='conda.exe', - icon="icon.ico", + icon=os.path.join(HERE, "icon.ico"), debug=False, bootloader_ignore_signals=False, strip=(sys.platform!="win32"), From d8c2ffac2598c5ac6ef0cdd398bc5a053fb7e67e Mon Sep 17 00:00:00 2001 From: jaimergp Date: Mon, 7 Aug 2023 18:59:05 +0200 Subject: [PATCH 21/24] add a comment about the sys.argv loop --- src/conda.exe.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/conda.exe.spec b/src/conda.exe.spec index dc28c31..99b6ffe 100644 --- a/src/conda.exe.spec +++ b/src/conda.exe.spec @@ -2,6 +2,8 @@ import os import sys +# __file__ is not defined in the pyinstaller context, +# so we will get it from sys.argv instead for arg in sys.argv: if arg.endswith("conda.exe.spec"): HERE = os.path.abspath(os.path.dirname(arg)) From fa4c48ceca78137a79714626fa943e6f877a390c Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 8 Aug 2023 11:45:02 +0200 Subject: [PATCH 22/24] bundle conda-libmamba-solver --- recipe/meta.yaml | 4 ++++ src/imports.py | 14 +++++++++++++- tests/test_main.py | 8 ++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 2f312ca..dc95401 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -1,4 +1,6 @@ {% set conda_version = "23.7.2" %} +{% set conda_libmamba_solver_version = "23.7.0" %} +{% set libmambapy_version = "1.4.1" %} {% set constructor_version = "3.4.5" %} {% set python_version = "3.9.15" %} @@ -32,6 +34,8 @@ requirements: - conda ={{ conda_version }} - conda-package-handling >=1.6 - menuinst >=1.4.18,<2.0a0 # [win] + - conda-libmamba-solver ={{ conda_libmamba_solver_version }} + - libmambapy ={{ libmambapy_version }} run_constrained: - constructor >={{ constructor_version }} diff --git a/src/imports.py b/src/imports.py index 7d0d42e..5943b9c 100644 --- a/src/imports.py +++ b/src/imports.py @@ -6,7 +6,7 @@ import os import site -packages = ['conda', 'conda_package_handling', 'menuinst', 'conda_env'] +packages = ['conda', 'conda_package_handling', 'menuinst', 'conda_env', 'conda_libmamba_solver', 'libmambapy'] site_packages = os.getenv('SP_DIR', site.getsitepackages()[0]) files = [ f @@ -232,6 +232,15 @@ import conda_env.specs.binstar import conda_env.specs.requirements import conda_env.specs.yaml_file +import conda_libmamba_solver.__init__ +import conda_libmamba_solver.exceptions +import conda_libmamba_solver.index +import conda_libmamba_solver.mamba_utils +import conda_libmamba_solver.models +import conda_libmamba_solver.plugin +import conda_libmamba_solver.solver +import conda_libmamba_solver.state +import conda_libmamba_solver.utils import conda_package_handling.__init__ import conda_package_handling.api import conda_package_handling.cli @@ -242,6 +251,9 @@ import conda_package_handling.tarball import conda_package_handling.utils import conda_package_handling.validate +import libmambapy.__init__ +import libmambapy._version +import libmambapy.bindings try: import conda_env.__main__ diff --git a/tests/test_main.py b/tests/test_main.py index 5b2cf41..85fbc2e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -2,6 +2,9 @@ import subprocess import sys +import pytest + + CONDA_EXE = os.environ.get( "CONDA_STANDALONE", os.path.join(sys.prefix, "standalone_conda", "conda.exe") @@ -12,9 +15,10 @@ def run_conda(*args, **kwargs): return subprocess.run([CONDA_EXE, *args], **kwargs) -def test_new_environment(tmp_path): +@pytest.mark.parametrize("solver", ["classic", "libmamba"]) +def test_new_environment(tmp_path, solver): env = os.environ.copy() - env["CONDA_SOLVER"] = "classic" + env["CONDA_SOLVER"] = solver run_conda( "create", "-p", From 39c1bb2253513bdd7a803f8b17d8b34da558d90b Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 8 Aug 2023 11:48:09 +0200 Subject: [PATCH 23/24] pre-commit --- src/imports.py | 15 ++++++++++++--- tests/test_main.py | 1 - 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/imports.py b/src/imports.py index 5943b9c..7ea0e2f 100644 --- a/src/imports.py +++ b/src/imports.py @@ -6,8 +6,15 @@ import os import site -packages = ['conda', 'conda_package_handling', 'menuinst', 'conda_env', 'conda_libmamba_solver', 'libmambapy'] -site_packages = os.getenv('SP_DIR', site.getsitepackages()[0]) +packages = [ + "conda", + "conda_package_handling", + "menuinst", + "conda_env", + "conda_libmamba_solver", + "libmambapy", +] +site_packages = os.getenv("SP_DIR", site.getsitepackages()[0]) files = [ f for package in packages @@ -20,7 +27,9 @@ continue spec = importlib.util.spec_from_file_location(f, f) modules[f] = importlib.util.module_from_spec(spec) - print(os.path.relpath(f, site_packages).removesuffix('.py').replace(os.path.sep, '.')) + print( + os.path.relpath(f, site_packages).removesuffix(".py").replace(os.path.sep, ".") + ) import conda.__init__ import conda.__version__ diff --git a/tests/test_main.py b/tests/test_main.py index 85fbc2e..3edfde0 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -4,7 +4,6 @@ import pytest - CONDA_EXE = os.environ.get( "CONDA_STANDALONE", os.path.join(sys.prefix, "standalone_conda", "conda.exe") From cbc2f76709b44d3c04a73787d63c0f62c8e48c0d Mon Sep 17 00:00:00 2001 From: jaimergp Date: Tue, 8 Aug 2023 11:49:00 +0200 Subject: [PATCH 24/24] add news --- news/27-add-conda-libmamba-solver | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 news/27-add-conda-libmamba-solver diff --git a/news/27-add-conda-libmamba-solver b/news/27-add-conda-libmamba-solver new file mode 100644 index 0000000..b47695e --- /dev/null +++ b/news/27-add-conda-libmamba-solver @@ -0,0 +1,19 @@ +### Enhancements + +* Add `conda-libmamba-solver` to the list of bundled packages. (#27) + +### Bug fixes + +* + +### Deprecations + +* + +### Docs + +* + +### Other + +*