diff options
9 files changed, 395 insertions, 24 deletions
diff --git a/pkgs/by-name/li/libmamba/package.nix b/pkgs/by-name/li/libmamba/package.nix new file mode 100644 index 0000000000000..2c31119e2bfa6 --- /dev/null +++ b/pkgs/by-name/li/libmamba/package.nix @@ -0,0 +1,60 @@ +{ + fetchFromGitHub, + lib, + stdenv, + cmake, + fmt, + spdlog, + tl-expected, + nlohmann_json, + yaml-cpp, + simdjson, + reproc, + libsolv, + curl, + libarchive, + zstd, + bzip2, + python3Packages, +}: +stdenv.mkDerivation rec { + pname = "libmamba"; + version = "1.5.7"; + src = fetchFromGitHub { + owner = "mamba-org"; + repo = "mamba"; + rev = "${pname}-${version}"; + hash = "sha256-HfmvLi9IBWlaGAn2Ej4Bnm4b3l19jEXwNl5IUkdVxi0="; + }; + nativeBuildInputs = [ + cmake + python3Packages.python + ]; + buildInputs = [ + fmt + spdlog + tl-expected + nlohmann_json + yaml-cpp + simdjson + reproc + libsolv + curl + libarchive + zstd + bzip2 + ]; + + cmakeFlags = [ + (lib.cmakeBool "BUILD_LIBMAMBA" true) + (lib.cmakeBool "BUILD_SHARED" true) + ]; + + meta = { + description = "The library for the fast Cross-Platform Package Manager"; + homepage = "https://github.com/mamba-org/mamba"; + license = lib.licenses.bsd3; + platforms = lib.platforms.all; + maintainers = [ lib.maintainers.ericthemagician ]; + }; +} diff --git a/pkgs/development/libraries/libsolv/default.nix b/pkgs/development/libraries/libsolv/default.nix index 6af948f678284..60e7da2907263 100644 --- a/pkgs/development/libraries/libsolv/default.nix +++ b/pkgs/development/libraries/libsolv/default.nix @@ -13,6 +13,7 @@ , withRpm ? !stdenv.isDarwin , rpm , db +, withConda ? true }: stdenv.mkDerivation rec { @@ -23,11 +24,12 @@ stdenv.mkDerivation rec { owner = "openSUSE"; repo = "libsolv"; rev = version; - sha256 = "sha256-cL7SDwCzXM2qJQfiu/3nfAiFbcFNn1YXD23Sl3n9nzY="; + hash = "sha256-cL7SDwCzXM2qJQfiu/3nfAiFbcFNn1YXD23Sl3n9nzY="; }; cmakeFlags = [ "-DENABLE_COMPLEX_DEPS=true" + (lib.cmakeBool "ENABLE_CONDA" withConda) "-DENABLE_LZMA_COMPRESSION=true" "-DENABLE_BZIP2_COMPRESSION=true" "-DENABLE_ZSTD_COMPRESSION=true" diff --git a/pkgs/development/python-modules/conda-libmamba-solver/default.nix b/pkgs/development/python-modules/conda-libmamba-solver/default.nix new file mode 100644 index 0000000000000..050b99fe83b05 --- /dev/null +++ b/pkgs/development/python-modules/conda-libmamba-solver/default.nix @@ -0,0 +1,47 @@ +{ + lib, + buildPythonPackage, + pythonRelaxDepsHook, + fetchFromGitHub, + libmambapy, + hatchling, + hatch-vcs, + boltons, +}: +buildPythonPackage rec { + pname = "conda-libmamba-solver"; + version = "24.1.0"; + pyproject = true; + + src = fetchFromGitHub { + inherit pname version; + owner = "conda"; + repo = "conda-libmamba-solver"; + rev = version; + hash = "sha256-vsUYrDVNMKHd3mlaAFYCP4uPQ9HxeKsose5O8InaMcE="; + }; + + nativeBuildInputs = [ pythonRelaxDepsHook ]; + + build-system = [ + hatchling + hatch-vcs + ]; + + dependencies = [ + boltons + libmambapy + ]; + + # this package depends on conda for the import to run succesfully, but conda depends on this package to execute. + # pythonImportsCheck = [ "conda_libmamba_solver" ]; + + pythonRemoveDeps = [ "conda" ]; + + meta = { + description = "The libmamba based solver for conda."; + homepage = "https://github.com/conda/conda-libmamba-solver"; + license = lib.licenses.bsd3; + maintainers = [ lib.maintainers.ericthemagician ]; + }; +} diff --git a/pkgs/development/python-modules/conda-package-handling/default.nix b/pkgs/development/python-modules/conda-package-handling/default.nix new file mode 100644 index 0000000000000..59736724577bf --- /dev/null +++ b/pkgs/development/python-modules/conda-package-handling/default.nix @@ -0,0 +1,30 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + conda-package-streaming, +}: +buildPythonPackage rec { + pname = "conda-package-handling"; + version = "2.2.0"; + src = fetchFromGitHub { + owner = "conda"; + repo = "conda-package-handling"; + rev = version; + hash = "sha256-WeGfmT6lLwcwhheLBPMFcVMudY+zPsvTuXuOsiEAorQ="; + }; + + pyproject = true; + build-system = [ setuptools ]; + dependencies = [ conda-package-streaming ]; + + pythonImportsCheck = [ "conda_package_handling" ]; + + meta = { + description = "Create and extract conda packages of various formats"; + homepage = "https://github.com/conda/conda-package-handling"; + license = lib.licenses.bsd3; + maintainers = [ lib.maintainers.ericthemagician ]; + }; +} diff --git a/pkgs/development/python-modules/conda-package-streaming/default.nix b/pkgs/development/python-modules/conda-package-streaming/default.nix new file mode 100644 index 0000000000000..e849195f8461c --- /dev/null +++ b/pkgs/development/python-modules/conda-package-streaming/default.nix @@ -0,0 +1,35 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + flit-core, + requests, + zstandard, +}: +buildPythonPackage rec { + pname = "conda-package-streaming"; + version = "0.9.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "conda"; + repo = "conda-package-streaming"; + rev = "v${version}"; + hash = "sha256-UTql2M+9eFDuHOwLYYKJ751wEcOfLJYzfU6+WF8Je2g="; + }; + + build-system = [ flit-core ]; + dependencies = [ + requests + zstandard + ]; + + pythonImportsCheck = [ "conda_package_streaming" ]; + + meta = { + description = "An efficient library to read from new and old format .conda and .tar.bz2 conda packages."; + homepage = "https://github.com/conda/conda-package-streaming"; + license = lib.licenses.bsd3; + maintainers = [ lib.maintainers.ericthemagician ]; + }; +} diff --git a/pkgs/development/python-modules/conda/0001-conda_exe.patch b/pkgs/development/python-modules/conda/0001-conda_exe.patch new file mode 100644 index 0000000000000..12ea4bc5ab0dc --- /dev/null +++ b/pkgs/development/python-modules/conda/0001-conda_exe.patch @@ -0,0 +1,51 @@ +--- a/conda/base/context.py ++++ b/conda/base/context.py +@@ -754,7 +754,7 @@ + + @property + def conda_prefix(self): +- return abspath(sys.prefix) ++ return expand("~/.conda") + + @property + @deprecated( +@@ -787,28 +787,17 @@ + The vars can refer to each other if necessary since the dict is ordered. + None means unset it. + """ +- if context.dev: +- return { +- "CONDA_EXE": sys.executable, +- # do not confuse with os.path.join, we are joining paths with ; or : delimiters +- "PYTHONPATH": os.pathsep.join( +- (CONDA_SOURCE_ROOT, os.environ.get("PYTHONPATH", "")) +- ), +- "_CE_M": "-m", +- "_CE_CONDA": "conda", +- "CONDA_PYTHON_EXE": sys.executable, +- } +- else: +- bin_dir = "Scripts" if on_win else "bin" +- exe = "conda.exe" if on_win else "conda" +- # I was going to use None to indicate a variable to unset, but that gets tricky with +- # error-on-undefined. +- return { +- "CONDA_EXE": os.path.join(sys.prefix, bin_dir, exe), +- "_CE_M": "", +- "_CE_CONDA": "", +- "CONDA_PYTHON_EXE": sys.executable, +- } ++ import sys ++ return { ++ "CONDA_EXE": sys.executable, ++ # do not confuse with os.path.join, we are joining paths with ; or : delimiters ++ "PYTHONPATH": os.pathsep.join( ++ [CONDA_SOURCE_ROOT, os.environ.get("PYTHONPATH", "")] + [path for path in sys.path if "site-packages" in path] ++ ), ++ "_CE_M": "-m", ++ "_CE_CONDA": "conda", ++ "CONDA_PYTHON_EXE": sys.executable, ++ } + + @memoizedproperty + def channel_alias(self): diff --git a/pkgs/development/python-modules/conda/default.nix b/pkgs/development/python-modules/conda/default.nix index e6dbe10914e7c..e2ec8bd2d46ef 100644 --- a/pkgs/development/python-modules/conda/default.nix +++ b/pkgs/development/python-modules/conda/default.nix @@ -1,38 +1,83 @@ -{ lib -, buildPythonPackage -, pythonAtLeast -, fetchPypi -, pycosat -, requests -, ruamel-yaml -, isPy3k -, enum34 +{ + lib, + buildPythonPackage, + pythonRelaxDepsHook, + hostPlatform, + fetchFromGitHub, + # build dependencies + hatchling, + hatch-vcs, + # runtime dependencies + archspec, + conda-libmamba-solver, + conda-package-handling, + distro, + jsonpatch, + packaging, + platformdirs, + pluggy, + pycosat, + requests, + ruamel-yaml, + tqdm, + truststore, + # runtime options + defaultEnvPath ? "~/.conda/envs", # default path to store conda environments + defaultPkgPath ? "~/.conda/pkgs", # default path to store download conda packages }: - -# Note: this installs conda as a library. The application cannot be used. -# This is likely therefore NOT what you're looking for. - buildPythonPackage rec { pname = "conda"; - version = "4.3.16"; - format = "setuptools"; + version = "24.1.2"; + pyproject = true; - # this is a very outdated version of conda that isn't compatible with python 3.10+ - disabled = pythonAtLeast "3.10"; - - src = fetchPypi { + src = fetchFromGitHub { inherit pname version; - sha256 = "a91ef821343dea3ba9670f3d10b36c1ace4f4c36d70c175d8fc8886e94285953"; + owner = "conda"; + repo = "conda"; + rev = version; + hash = "sha256-L/Y7Bb3R5YqXbjTN4CRPFnkgymVLrxuFmjVzpvt28dE="; }; - propagatedBuildInputs = [ pycosat requests ruamel-yaml ] ++ lib.optional (!isPy3k) enum34; + nativeBuildInputs = [ pythonRelaxDepsHook ]; + + build-system = [ + hatchling + hatch-vcs + ]; + + dependencies = [ + archspec + conda-libmamba-solver + conda-package-handling + distro + jsonpatch + packaging + platformdirs + pluggy + pycosat + requests + ruamel-yaml + tqdm + truststore + ]; + + patches = [ ./0001-conda_exe.patch ]; + + makeWrapperArgs = [ + "--set CONDA_EXE ${placeholder "out"}/bin/conda" + ''--set-default CONDA_ENVS_PATH "${defaultEnvPath}"'' + ''--set-default CONDA_PKGS_DIRS "${defaultPkgPath}"'' + ]; + + pythonImportsCheck = [ "conda" ]; - # No tests - doCheck = false; + # menuinst is currently not packaged + pythonRemoveDeps = lib.optionals (!hostPlatform.isWindows) [ "menuinst" ]; meta = { description = "OS-agnostic, system-level binary package manager"; homepage = "https://github.com/conda/conda"; license = lib.licenses.bsd3; + maintainers = [ lib.maintainers.ericthemagician ]; }; } diff --git a/pkgs/development/python-modules/libmambapy/default.nix b/pkgs/development/python-modules/libmambapy/default.nix new file mode 100644 index 0000000000000..0466bebfe3099 --- /dev/null +++ b/pkgs/development/python-modules/libmambapy/default.nix @@ -0,0 +1,93 @@ +{ + lib, + fetchFromGitHub, + pythonPackages, + buildPythonPackage, + cmake, + ninja, + libmamba, + pybind11, + setuptools, + fmt, + spdlog, + tl-expected, + nlohmann_json, + yaml-cpp, + reproc, + libsolv, + curl, + zstd, + bzip2, + wheel, +}: +buildPythonPackage rec { + pname = "libmambapy"; + version = "1.5.7"; + pyproject = true; + + src = fetchFromGitHub { + owner = "mamba-org"; + repo = "mamba"; + rev = "${pname}-${version}"; + hash = "sha256-HfmvLi9IBWlaGAn2Ej4Bnm4b3l19jEXwNl5IUkdVxi0="; + }; + + nativeBuildInputs = [ + cmake + ninja + ]; + + buildInputs = [ + (libmamba.override { python3Packages = pythonPackages; }) + pybind11 + fmt + spdlog + tl-expected + nlohmann_json + yaml-cpp + reproc + libsolv + curl + zstd + bzip2 + ]; + + build-system = [ + setuptools + wheel + ]; + + # patch needed to fix setuptools errors + # see these for reference + # https://stackoverflow.com/questions/72294299/multiple-top-level-packages-discovered-in-a-flat-layout + # https://github.com/pypa/setuptools/issues/3197#issuecomment-1078770109 + postPatch = '' + substituteInPlace libmambapy/setup.py --replace-warn "setuptools.setup()" "setuptools.setup(py_modules=[])" + ''; + + cmakeFlags = [ + "-GNinja" + (lib.cmakeBool "BUILD_LIBMAMBAPY" true) + ]; + + buildPhase = '' + ninjaBuildPhase + cp -r libmambapy ../libmambapy + cd ../libmambapy + pypaBuildPhase + ''; + + pythonRemoveDeps = [ "scikit-build" ]; + + pythonImportsCheck = [ + "libmambapy" + "libmambapy.bindings" + ]; + + meta = { + description = "The python library for the fast Cross-Platform Package Manager"; + homepage = "https://github.com/mamba-org/mamba"; + license = lib.licenses.bsd3; + maintainers = [ lib.maintainers.ericthemagician ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 9f1185611005c..e11da9f378497 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2400,6 +2400,12 @@ self: super: with self; { conda = callPackage ../development/python-modules/conda { }; + conda-libmamba-solver = callPackage ../development/python-modules/conda-libmamba-solver { }; + + conda-package-handling = callPackage ../development/python-modules/conda-package-handling { }; + + conda-package-streaming = callPackage ../development/python-modules/conda-package-streaming { }; + confection = callPackage ../development/python-modules/confection { }; configargparse = callPackage ../development/python-modules/configargparse { }; @@ -6621,6 +6627,8 @@ self: super: with self; { inherit (pkgs) lzfse; }; + libmambapy = callPackage ../development/python-modules/libmambapy { }; + libmodulemd = lib.pipe pkgs.libmodulemd [ toPythonModule (p: |