diff --git a/.flake8 b/.flake8 index 7884148db9..0a150bea68 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] -max-line-length=88 +max-line-length=100 extend-ignore=E203,D104,D100,I004 -exclude=test/*,docs/source/tools/* +exclude=*/tests/*,docs/source/tools/* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d321b940c6..e6fd50bdba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,20 +9,14 @@ on: - master jobs: - mamba_python_tests: + libmamba_static: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] - python-version: ["3.8"] - steps: - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - name: free disk space if: matrix.os == 'ubuntu-latest' run: | @@ -31,86 +25,79 @@ jobs: sudo apt clean docker rmi $(docker image ls -aq) df -h - - name: Cache CCACHE paths + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%F)" + - name: cache CCACHE paths uses: actions/cache@v2 with: path: | ~/ccache - key: ${{ runner.os }}-ccache - - name: Conda info - shell: bash -l {0} - run: conda info - - name: Create the conda environment - shell: bash -l {0} - run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -n base python=$PYTHON_VERSION pip pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json "cpp-filesystem>=1.5.8" conda cxx-compiler ccache cmake gtest gmock reproc-cpp yaml-cpp - env: - PYTHON_VERSION: ${{ matrix.python-version }} - - name: Install dependencies + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./libmamba/environment-dev.yml + environment-name: build_env + - name: build libmamba-static shell: bash -l {0} run: | - source "$CONDA/etc/profile.d/conda.sh" - conda activate base - python --version + micromamba activate build_env + mkdir build + cd build export CCACHE_DIR=$HOME/ccache - ccache --show-config - export CC="ccache $CC" - if [ "$RUNNER_OS" == "macOS" ]; then - export LDSHARED=$(python -c "import os;from distutils import sysconfig;print(sysconfig.get_config_var('LDSHARED'))") - fi - python -m pip install ".[test]" -vvv - ccache --print-stats - - name: Run tests OS X and Linux + cmake \ + -GNinja \ + -DBUILD_LIBMAMBA=ON \ + -DBUILD_STATIC=ON \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + .. + ninja + + libmamba_cpp_tests: + needs: [libmamba_static] + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v2 + - name: generate ccache timestamp + id: ccache_cache_timestamp shell: bash -l {0} - run: | - source "$CONDA/etc/profile.d/conda.sh" - conda activate base - pytest test --ignore=test/micromamba - mamba create -n test_env xtensor -c conda-forge -y - mamba env create -f test/test_env.yml - mamba env update -f test/update_env.yml - - name: Run tests OS X and Linux + run: echo ::set-output name=timestamp::"$(date --utc +%F)" + - name: cache CCACHE paths + uses: actions/cache@v2 + with: + path: | + ~/ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./libmamba/environment-dev.yml + environment-name: build_env + - name: build and run libmamba C++ tests shell: bash -l {0} run: | - conda activate base - conda install conda-build -c conda-forge -y - if [ "$RUNNER_OS" == "Linux" ]; then - mkdir -p $CONDA_PREFIX/conda-bld/linux-64 - wget -P $CONDA_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2 - wget -P $CONDA_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/linux-64/xtl-0.6.21-h0efe328_0.tar.bz2 - else - mkdir -p $CONDA_PREFIX/conda-bld/osx-64 - wget -P $CONDA_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/osx-64/xtensor-0.21.8-h879752b_0.tar.bz2 - wget -P $CONDA_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/osx-64/xtl-0.6.21-h6516342_0.tar.bz2 - fi - conda index $CONDA_PREFIX/conda-bld - - mamba create -n l_o_cal_test xtensor -c local -c conda-forge -y - conda activate l_o_cal_test - conda list - conda list | tail -n +3 > list.txt - if [ "$(grep -c "local" list.txt)" -ne 2 ]; then - exit 1 - fi - - name: Run server auth tests - shell: bash -l {0} -euo pipefail -x - run: | - cd test - source "$CONDA/etc/profile.d/conda.sh" - conda activate base - - if [[ "$(uname -s)" == "Linux" ]]; then - ./generate_gpg_keys.sh - pip install securesystemslib - fi - pip install rich - pip install git+https://github.com/conda/conda-content-trust.git@master - - ./testserver.sh + micromamba activate build_env + mkdir build + cd build + export CCACHE_DIR=$HOME/ccache + cmake \ + -GNinja \ + -DBUILD_LIBMAMBA_TESTS=ON \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + .. + ninja testing_libmamba_lock + ninja test - libmamba_cpp_tests: + umamba_tests: + needs: [libmamba_static] runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -126,58 +113,60 @@ jobs: sudo apt clean docker rmi $(docker image ls -aq) df -h - - name: Cache CCACHE paths + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%F)" + - name: cache CCACHE paths uses: actions/cache@v2 with: path: | ~/ccache - key: ${{ runner.os }}-ccache-libmamba - - name: install micromamba - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - wget -qO- https://api.anaconda.org/download/conda-forge/micromamba/0.4.0/linux-64/micromamba-0.4.0-hc2cb875_0.tar.bz2 | tar -xvj bin/micromamba --strip-components=1 - else - wget -qO- https://anaconda.org/conda-forge/micromamba/0.4.0/download/osx-64/micromamba-0.4.0-h8680c10_1.tar.bz2 | tar -xvj bin/micromamba - mv bin/micromamba ./micromamba - fi - ./micromamba shell init -s bash -p ~/mambaroot - - name: install deps - shell: bash -l {0} - run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - . $MAMBA_ROOT_PREFIX/etc/profile.d/mamba.sh - micromamba create -y -p ~/build_env pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json cxx-compiler ccache cmake gtest gmock "cpp-filesystem>=1.5.8" reproc-cpp yaml-cpp cli11 -c conda-forge - env: - PYTHON_VERSION: ${{ matrix.python-version }} - - name: build tests + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./micromamba/environment-dev.yml + environment-name: build_env + - name: build micromamba shell: bash -l {0} run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - . $MAMBA_ROOT_PREFIX/etc/profile.d/mamba.sh - micromamba activate ~/build_env - mkdir -p ~/.conda - touch ~/.conda/environments.txt + micromamba activate build_env + export CCACHE_DIR=$HOME/ccache mkdir build cd build - export CCACHE_DIR=$HOME/ccache - cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ - -DENABLE_TESTS=ON \ - -DBUILD_EXE=ON \ - -DBUILD_CRYPTO_PACKAGE_VALIDATION=ON \ - -DBUILD_BINDINGS=OFF \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache - make test_mamba_lock -j2 - make test -j2 + cmake .. \ + -GNinja \ + -DBUILD_MICROMAMBA=ON \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache + ninja + - name: install zsh, xonsh and fish in linux + if: matrix.os == 'ubuntu-latest' + shell: bash -l -eo pipefail {0} + run: | + sudo apt-get install zsh xonsh fish -y + - name: install fish in mac + if: matrix.os == 'macos-latest' + shell: bash -l -eo pipefail {0} + run: | + brew install fish + - name: micromamba python based tests + shell: bash -l -eo pipefail {0} + run: | + export TEST_MAMBA_EXE=$(pwd)/build/micromamba/micromamba + micromamba activate build_env + pytest ./micromamba/tests/ - umamba_tests: + mamba_python_tests: + needs: [libmamba_static] runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] + python-version: ["3.8"] + steps: - uses: actions/checkout@v2 - name: free disk space @@ -188,115 +177,133 @@ jobs: sudo apt clean docker rmi $(docker image ls -aq) df -h - - name: Cache CCACHE paths + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%F)" + - name: cache CCACHE paths uses: actions/cache@v2 with: path: | ~/ccache - key: ${{ runner.os }}-ccache-umamba - - name: install micromamba - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - wget -qO- https://api.anaconda.org/download/conda-forge/micromamba/0.4.0/linux-64/micromamba-0.4.0-hc2cb875_0.tar.bz2 | tar -xvj bin/micromamba --strip-components=1 - else - wget -qO- https://anaconda.org/conda-forge/micromamba/0.4.0/download/osx-64/micromamba-0.4.0-h8680c10_1.tar.bz2 | tar -xvj bin/micromamba - mv bin/micromamba ./micromamba - fi - ./micromamba shell init -s bash -p ~/mambaroot - - name: install deps + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./mamba/environment-dev.yml + environment-name: build_env + extra-specs: conda-build + - name: run conda init shell: bash -l {0} - run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - . $MAMBA_ROOT_PREFIX/etc/profile.d/mamba.sh - micromamba create -y -p ~/build_env pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json cxx-compiler ccache cmake gtest gmock "cpp-filesystem>=1.5.8" reproc-cpp yaml-cpp pyyaml cli11 -c conda-forge - env: - PYTHON_VERSION: ${{ matrix.python-version }} - - name: build micromamba + run: conda init + - name: build libmamba Python bindings shell: bash -l {0} run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - . $MAMBA_ROOT_PREFIX/etc/profile.d/mamba.sh - micromamba activate ~/build_env - export CCACHE_DIR=$HOME/ccache - mkdir -p ~/.conda - touch ~/.conda/environments.txt + micromamba activate build_env mkdir build cd build - cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ - -DENABLE_TESTS=OFF \ - -DBUILD_EXE=ON \ - -DBUILD_BINDINGS=OFF \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache - make -j2 - - name: run new micromamba + export CCACHE_DIR=$HOME/ccache + cmake \ + -GNinja \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ + -DBUILD_LIBMAMBAPY=ON \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + .. + ninja + ninja install + pip install -e ../libmambapy/ --no-deps + - name: install mamba shell: bash -l {0} run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - cd build - ./micromamba --version - if [ "$RUNNER_OS" == "Linux" ]; then - ./micromamba create -p ~/explicit_env -f ../test/explicit_env_linux.txt - else - ./micromamba create -p ~/explicit_env -f ../test/explicit_env_osx.txt - fi; - - name: run new micromamba yaml env + micromamba activate build_env + pip install ./mamba[test] --no-deps + - name: run mamba tests suite shell: bash -l {0} run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - cd build - ./micromamba create -f ../test/yaml_env.yml - - name: run new micromamba spec files + micromamba activate build_env + pytest mamba/tests + - name: run mamba create/update tests shell: bash -l {0} run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - cd build - ./micromamba create -f ../test/spec_file_1.txt -n testenv_one_file -c conda-forge - ./micromamba create -f ../test/spec_file_1.txt -f ../test/spec_file_2.txt -n testenv_two_files -c conda-forge - # test noarch packages - $MAMBA_ROOT_PREFIX/envs/testenv_two_files/bin/wheel --help - - name: micromamba prefix replacement / pkgconfig check - shell: bash -l -eo pipefail {0} + micromamba activate build_env + mamba create -n test_env xtensor -c conda-forge -y + mamba env create -f mamba/tests/test_env.yml + mamba env update -f mamba/tests/update_env.yml + - name: run mamba local channel test + shell: bash -l {0} run: | - cd build - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/micromamba - eval "$($MAMBA_EXE shell hook -s posix -p ~/mambaroot)" + micromamba activate build_env + if [ "$RUNNER_OS" == "Linux" ]; then + mkdir -p $CONDA_PREFIX/conda-bld/linux-64 + wget -P $CONDA_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/linux-64/xtensor-0.21.8-hc9558a2_0.tar.bz2 + wget -P $CONDA_PREFIX/conda-bld/linux-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/linux-64/xtl-0.6.21-h0efe328_0.tar.bz2 + else + mkdir -p $CONDA_PREFIX/conda-bld/osx-64 + wget -P $CONDA_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtensor/0.21.8/download/osx-64/xtensor-0.21.8-h879752b_0.tar.bz2 + wget -P $CONDA_PREFIX/conda-bld/osx-64 https://anaconda.org/conda-forge/xtl/0.6.21/download/osx-64/xtl-0.6.21-h6516342_0.tar.bz2 + fi + conda index $CONDA_PREFIX/conda-bld + mamba create -n l_o_cal_test xtensor -c local -c conda-forge -y - micromamba create -n pkgconf pkg-config=0.29.2 eigen -c conda-forge - micromamba activate pkgconf - IDIR=$(pkg-config eigen3 --cflags-only-I) - if [[ "${IDIR}" != "-I$CONDA_PREFIX/include/eigen3" ]]; - then - exit 1; + conda list -n l_o_cal_test + conda list -n l_o_cal_test | tail -n +3 > list.txt + if [ "$(grep -c "local" list.txt)" -ne 2 ]; then + exit 1 fi - - name: install zsh, xonsh and fish in linux - if: matrix.os == 'ubuntu-latest' - shell: bash -l -eo pipefail {0} - run: | - sudo apt-get install zsh xonsh fish -y - - name: install fish in mac - if: matrix.os == 'macos-latest' - shell: bash -l -eo pipefail {0} - run: | - brew install fish - - name: micromamba python based tests - shell: bash -l -eo pipefail {0} + - name: Run server auth tests + shell: bash -l {0} -euo pipefail -x run: | - export MAMBA_ROOT_PREFIX=~/mambaroot - export MAMBA_EXE=$(pwd)/build/micromamba - eval "$($MAMBA_EXE shell hook -s posix -p ~/mambaroot)" + micromamba activate build_env + cd mamba/tests + + if [[ "$(uname -s)" == "Linux" ]]; then + ./generate_gpg_keys.sh + pip install securesystemslib + fi + pip install rich + pip install git+https://github.com/conda/conda-content-trust.git@master - micromamba activate - micromamba install python=3.8 pytest pyyaml pytest-lazy-fixture -c conda-forge + ./testserver.sh - export TEST_MAMBA_EXE=$(pwd)/build/micromamba - pytest test/micromamba + # libmamba_static_win: + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [windows-2016] + + # steps: + # - uses: actions/checkout@v2 + # - name: generate ccache timestamp + # id: ccache_cache_timestamp + # shell: bash -l {0} + # run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + # - name: cache CCACHE paths + # uses: actions/cache@v2 + # with: + # path: | + # ~/ccache + # key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + # - name: create build environment + # uses: mamba-org/provision-with-micromamba@main + # with: + # environment-file: ./libmamba/environment-dev.yml + # environment-name: build_env + # - name: build libmamba-static + # shell: cmd /C call {0} + # run: | + # call micromamba activate build_env + # mkdir build + # cd build + # set CCACHE_DIR=%HOME%\ccache + # cmake .. -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ^ + # -DBUILD_LIBMAMBA=ON ^ + # -DBUILD_STATIC=ON ^ + # -GNinja ^ + # -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^ + # -DCMAKE_C_COMPILER_LAUNCHER=ccache + # ninja -j2 mamba_python_tests_win: runs-on: ${{ matrix.os }} @@ -308,67 +315,74 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Cache CCACHE paths + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + - name: cache CCACHE paths uses: actions/cache@v2 with: path: | ~/ccache - key: ${{ runner.os }}-ccache-mamba - - uses: conda-incubator/setup-miniconda@v2 + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - - name: Conda info - run: conda info - - name: Create the conda environment + environment-file: ./mamba/environment-dev.yml + environment-name: build_env + extra-specs: | + conda-build + curl + - name: run conda init + shell: bash -l {0} + run: conda init + - name: build libmamba Python bindings + shell: cmd /C call {0} run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda install -n base -q -y vs2017_win-64 ccache python=$PYTHON_VERSION pip pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json "cpp-filesystem>=1.5.8" conda cmake gtest gmock ninja reproc-cpp yaml-cpp cli11 - env: - PYTHON_VERSION: ${{ matrix.python-version }} - - name: Install dependencies + call micromamba activate build_env + mkdir build + cd build + set CCACHE_DIR=%HOME%\ccache + cmake .. -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library -DBUILD_LIBMAMBAPY=ON ^ + -GNinja ^ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^ + -DCMAKE_C_COMPILER_LAUNCHER=ccache + ninja + ninja install + pip install -e ..\libmambapy\ --no-deps + - name: install mamba + shell: bash -l {0} run: | - conda activate base python --version - - $Env:CCACHE_DIR="$HOME/ccache" - ccache --show-config - $Env:CC="ccache $Env:CC" - $Env:CXX="ccache $Env:CXX" - python -m pip install ".[test]" -vvv - ccache --print-stats - - name: Run pytests on Windows - run: | - conda activate base - pytest test --ignore=test/micromamba + pip install ./mamba[test] --no-deps + - name: run mamba tests suite + shell: bash -l {0} + run: pytest mamba/tests - name: Run create command - run: | - conda activate base - mamba create -n test_env xtensor -c conda-forge -y + shell: bash -l {0} + run: mamba create -n test_env xtensor -c conda-forge -y - name: Run env create command - run: | - conda activate base - mamba env create -f test/test_env.yml + shell: bash -l {0} + run: mamba env create -f mamba/tests/test_env.yml - name: Run env update command - run: | - conda activate base - mamba env update -f test/update_env.yml + shell: bash -l {0} + run: mamba env update -f mamba/tests/update_env.yml - name: Run local channel checks shell: bash -l {0} run: | - conda activate base - conda install conda-build -c conda-forge -y mkdir -p $CONDA_PREFIX/conda-bld/win-64 + echo $PATH + micromamba list + micromamba info + curl --version curl https://anaconda.org/conda-forge/xtensor/0.21.7/download/win-64/xtensor-0.21.7-h7ef1ec2_0.tar.bz2 -L -o $CONDA_PREFIX/conda-bld/win-64/xtensor-0.21.7-h7ef1ec2_0.tar.bz2 curl https://anaconda.org/conda-forge/xtl/0.6.21/download/win-64/xtl-0.6.21-h5362a0b_0.tar.bz2 -L -o $CONDA_PREFIX/conda-bld/win-64/xtl-0.6.21-h5362a0b_0.tar.bz2 conda index $CONDA_PREFIX/conda-bld - mamba create -n l_o_cal_test xtensor -c local -c conda-forge -y - conda activate l_o_cal_test - conda list + + conda list -n l_o_cal_test # cut first couple of lines to remove prefix path - conda list | tail -n +3 > list.txt + conda list -n l_o_cal_test | tail -n +3 > list.txt if [ "$(grep -c "local" list.txt)" -ne 2 ]; then exit 1 fi @@ -383,37 +397,33 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - - name: Cache CCACHE paths + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + - name: cache CCACHE paths uses: actions/cache@v2 with: path: | ~/ccache - key: ${{ runner.os }}-ccache-libmamba - - name: Conda info - run: conda info - - name: Create the conda environment - run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda create -q -y -n mamba-tests vs2017_win-64 ccache python=$PYTHON_VERSION pip pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json "cpp-filesystem>=1.5.8" conda cmake gtest gmock ninja reproc-cpp yaml-cpp cli11 pytest - env: - PYTHON_VERSION: ${{ matrix.python-version }} - - name: Run C++ tests Windows - shell: cmd + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./libmamba/environment-dev.yml + environment-name: build_env + - name: build and run libmamba C++ tests + shell: cmd /C call {0} run: | - call conda activate mamba-tests + call micromamba activate build_env mkdir build cd build - set "CCACHE_DIR=%HOME%\ccache" - cmake .. -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library -DENABLE_TESTS=ON ^ - -G "Ninja" ^ + set CCACHE_DIR=%HOME%\ccache + cmake .. -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library -DBUILD_LIBMAMBA_TESTS=ON ^ + -GNinja ^ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache ^ -DCMAKE_C_COMPILER_LAUNCHER=ccache - ninja test_mamba_lock -j2 + ninja testing_libmamba_lock -j2 ninja test -j2 umamba_tests_win: @@ -426,58 +436,36 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Cache CCACHE paths + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + - name: cache CCACHE paths uses: actions/cache@v2 with: path: | ~/ccache - key: ${{ runner.os }}-ccache-umamba - - name: create empty mamba-test env - shell: bash -l -eo pipefail {0} - run: | - cat > environment-test.yml <=1.5.8" conda cmake gtest gmock ninja reproc-cpp yaml-cpp pyyaml cli11 pytest pytest-lazy-fixture menuinst - env: - PYTHON_VERSION: ${{ matrix.python-version }} + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + - name: cache CCACHE paths + uses: actions/cache@v2 + with: + path: | + ~/ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./micromamba/environment-dev.yml + environment-name: build_env + extra-specs: menuinst - name: micromamba python based tests - shell: cmd + shell: cmd /C call {0} run: | - call conda activate mamba-tests - + call micromamba activate build_env set MAMBA_ROOT_PREFIX=%cd%\mambaroot set MAMBA_TEST_SHELL_TYPE=cmd.exe reg delete HKEY_CURRENT_USER\Software\Microsoft\Command Processor /v AutoRun - pytest test/micromamba + pytest micromamba/tests umamba_tests_win_pwsh: needs: [umamba_tests_win] @@ -535,10 +527,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - uses: actions/download-artifact@v2 with: name: micromamba_binary @@ -546,22 +534,30 @@ jobs: shell: bash -l -eo pipefail {0} run: | tar -xvf umamba.tar - - name: Create the conda environment - run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda create -q -y -n mamba-tests vs2017_win-64 python=$PYTHON_VERSION pip pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json "cpp-filesystem>=1.5.8" conda cmake gtest gmock ninja reproc-cpp yaml-cpp pyyaml cli11 pytest pytest-lazy-fixture menuinst - env: - PYTHON_VERSION: ${{ matrix.python-version }} + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + - name: cache CCACHE paths + uses: actions/cache@v2 + with: + path: | + ~/ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./micromamba/environment-dev.yml + environment-name: build_env + extra-specs: menuinst - name: micromamba python based tests with pwsh shell: powershell run: | - conda activate mamba-tests - + micromamba activate build_env $env:MAMBA_ROOT_PREFIX = Join-Path -Path $pwd -ChildPath 'mambaroot' $env:MAMBA_TEST_SHELL_TYPE='powershell' - pytest test/micromamba + pytest micromamba/tests umamba_tests_win_bash: needs: [umamba_tests_win] @@ -574,10 +570,6 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python-version }} - uses: actions/download-artifact@v2 with: name: micromamba_binary @@ -585,19 +577,27 @@ jobs: shell: bash -l -eo pipefail {0} run: | tar -xvf umamba.tar - - name: Create the conda environment - run: | - conda config --add channels conda-forge - conda config --set channel_priority strict - conda create -q -y -n mamba-tests vs2017_win-64 python=$PYTHON_VERSION pip pybind11 libsolv libsodium libarchive "libcurl=7.76.1=*_0" nlohmann_json "cpp-filesystem>=1.5.8" conda cmake gtest gmock ninja reproc-cpp yaml-cpp pyyaml cli11 pytest pytest-lazy-fixture menuinst - env: - PYTHON_VERSION: ${{ matrix.python-version }} + - name: generate ccache timestamp + id: ccache_cache_timestamp + shell: bash -l {0} + run: echo ::set-output name=timestamp::"$(date --utc +%FT%H)" + - name: cache CCACHE paths + uses: actions/cache@v2 + with: + path: | + ~/ccache + key: ${{ runner.os }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} + - name: create build environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: ./micromamba/environment-dev.yml + environment-name: build_env + extra-specs: menuinst - name: micromamba python based tests shell: bash -l -eo pipefail {0} run: | - conda activate mamba-tests - + micromamba activate build_env export MAMBA_ROOT_PREFIX=~/mambaroot export MAMBA_TEST_SHELL_TYPE=bash - pytest test/micromamba + pytest micromamba/tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 87b26289f6..075533fc2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,182 +8,24 @@ cmake_minimum_required (VERSION 3.2) if(POLICY CMP0025) cmake_policy(SET CMP0025 NEW) endif() +cmake_policy(SET CMP0077 NEW) #if(POLICY CMP0028) # cmake_policy(SET CMP0028 NEW) #endif() -project(mamba) - -set(MAMBA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) -set(MAMBA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) - -# Versionning -# =========== - -# Getting the mamba version from python -file (READ mamba/_version.py VERSION_FILE) - -STRING(REGEX REPLACE "\r?\n" ";" TMP_VERSION_FILE_LIST "${VERSION_FILE}") -LIST(GET TMP_VERSION_FILE_LIST 0 VERSION_LINE) -string(REGEX MATCHALL "version_info = \\(([0-9]*), ([0-9]*), ([0-9]*)\\)" MATCHES ${VERSION_LINE}) - -set(MAMBA_VERSION_MAJOR "${CMAKE_MATCH_1}") -set(MAMBA_VERSION_MINOR "${CMAKE_MATCH_2}") -set(MAMBA_VERSION_PATCH "${CMAKE_MATCH_3}") - -message("--> mamba version: ${MAMBA_VERSION_MAJOR}.${MAMBA_VERSION_MINOR}.${MAMBA_VERSION_PATCH}") -# Binary version -# See the following URL for explanations about the binary versionning -# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info -file(STRINGS "${MAMBA_INCLUDE_DIR}/mamba/core/version.hpp.in" mamba_version_defines - REGEX "#define MAMBA_BINARY_(CURRENT|REVISION|AGE)") -foreach(ver ${mamba_version_defines}) - if(ver MATCHES "#define MAMBA_BINARY_(CURRENT|REVISION|AGE) +([^ ]+)$") - set(MAMBA_BINARY_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") - endif() -endforeach() -set(MAMBA_BINARY_VERSION - ${MAMBA_BINARY_CURRENT}.${MAMBA_BINARY_REVISION}.${MAMBA_BINARY_AGE}) -message(STATUS "mamba binary version: v${MAMBA_BINARY_VERSION}") -configure_file(${MAMBA_INCLUDE_DIR}/mamba/core/version.hpp.in - ${CMAKE_SOURCE_DIR}/include/mamba/core/version.hpp @ONLY) +project(mamba) # Build options # ============= -option(BUILD_EXE "" OFF) -option(BUILD_SHARED "" OFF) -option(BUILD_STATIC "" ON) -option(BUILD_BINDINGS "" ON) -option(STATIC_DEPENDENCIES "" OFF) -option(BUILD_CRYPTO_PACKAGE_VALIDATION "Enable package validation using TUF" OFF) -option(ENABLE_TESTS "Enable C++ tests for mamba" OFF) - -if (STATIC_DEPENDENCIES) - add_definitions(-DUMAMBA_STATIC) -endif() - -add_definitions(-DGHC_WIN_DISABLE_WSTRING_STORAGE_TYPE) +option(BUILD_MICROMAMBA "Build micromamba" OFF) +option(BUILD_LIBMAMBA "Build libmamba library" OFF) +option(BUILD_LIBMAMBAPY "Build libmamba Python bindings" OFF) +option(BUILD_LIBMAMBA_TESTS "Build libmamba C++ tests" OFF) +option(MICROMAMBA_STATIC_LINK "" OFF) -# Dependencies -# ============ - -find_package(Threads REQUIRED) -find_package(nlohmann_json REQUIRED) - -message("Found libraries: ${MAMBA_DEPENDENCIES_LIBS}") - -# Source files -# ============ - -set(MAMBA_SOURCES - # Core API (low-level) - ${MAMBA_SOURCE_DIR}/core/activation.cpp - ${MAMBA_SOURCE_DIR}/core/channel.cpp - ${MAMBA_SOURCE_DIR}/core/context.cpp - ${MAMBA_SOURCE_DIR}/core/environments_manager.cpp - ${MAMBA_SOURCE_DIR}/core/fetch.cpp - ${MAMBA_SOURCE_DIR}/core/transaction_context.cpp - ${MAMBA_SOURCE_DIR}/core/link.cpp - ${MAMBA_SOURCE_DIR}/core/history.cpp - ${MAMBA_SOURCE_DIR}/core/match_spec.cpp - ${MAMBA_SOURCE_DIR}/core/menuinst.cpp - ${MAMBA_SOURCE_DIR}/core/url.cpp - ${MAMBA_SOURCE_DIR}/core/output.cpp - ${MAMBA_SOURCE_DIR}/core/package_handling.cpp - ${MAMBA_SOURCE_DIR}/core/package_cache.cpp - ${MAMBA_SOURCE_DIR}/core/pool.cpp - ${MAMBA_SOURCE_DIR}/core/prefix_data.cpp - ${MAMBA_SOURCE_DIR}/core/progress_bar.cpp - ${MAMBA_SOURCE_DIR}/core/pinning.cpp - ${MAMBA_SOURCE_DIR}/core/package_info.cpp - ${MAMBA_SOURCE_DIR}/core/package_paths.cpp - ${MAMBA_SOURCE_DIR}/core/query.cpp - ${MAMBA_SOURCE_DIR}/core/repo.cpp - ${MAMBA_SOURCE_DIR}/core/shell_init.cpp - ${MAMBA_SOURCE_DIR}/core/solver.cpp - ${MAMBA_SOURCE_DIR}/core/subdirdata.cpp - ${MAMBA_SOURCE_DIR}/core/thread_utils.cpp - ${MAMBA_SOURCE_DIR}/core/transaction.cpp - ${MAMBA_SOURCE_DIR}/core/util.cpp - ${MAMBA_SOURCE_DIR}/core/util_os.cpp - ${MAMBA_SOURCE_DIR}/core/validate.cpp - ${MAMBA_SOURCE_DIR}/core/version.cpp - ${MAMBA_SOURCE_DIR}/core/virtual_packages.cpp - # API (high-level) - ${MAMBA_SOURCE_DIR}/api/c_api.cpp - ${MAMBA_SOURCE_DIR}/api/clean.cpp - ${MAMBA_SOURCE_DIR}/api/config.cpp - ${MAMBA_SOURCE_DIR}/api/configuration.cpp - ${MAMBA_SOURCE_DIR}/api/create.cpp - ${MAMBA_SOURCE_DIR}/api/info.cpp - ${MAMBA_SOURCE_DIR}/api/install.cpp - ${MAMBA_SOURCE_DIR}/api/list.cpp - ${MAMBA_SOURCE_DIR}/api/remove.cpp - ${MAMBA_SOURCE_DIR}/api/shell.cpp - ${MAMBA_SOURCE_DIR}/api/update.cpp -) - -set(MAMBA_THIRD_PARTIES - ${MAMBA_SOURCE_DIR}/thirdparty/WinReg.hpp - ${MAMBA_SOURCE_DIR}/thirdparty/termcolor.hpp -) - -set(MAMBA_HEADERS - # Core API (low-level) - ${MAMBA_INCLUDE_DIR}/mamba/core/activation.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/channel.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/context.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/environment.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/environments_manager.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/fetch.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/fsutil.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/graph_util.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/history.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/link.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/mamba_fs.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/match_spec.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/menuinst.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/output.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/package_cache.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/package_handling.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/package_info.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/package_paths.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/pool.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/prefix_data.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/progress_bar.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/pinning.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/query.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/repo.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/shell_init.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/solver.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/subdirdata.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/thread_utils.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/transaction.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/transaction_context.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/url.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/util.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/util_os.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/validate.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/version.hpp - ${MAMBA_INCLUDE_DIR}/mamba/core/virtual_packages.hpp - # API (high-level) - ${MAMBA_INCLUDE_DIR}/mamba/api/c_api.h - ${MAMBA_INCLUDE_DIR}/mamba/api/clean.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/config.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/configuration.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/constants.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/create.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/info.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/install.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/list.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/remove.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/shell.hpp - ${MAMBA_INCLUDE_DIR}/mamba/api/update.hpp -) - -# Targets and link -# ================ +option(BUILD_SHARED "" OFF) +option(BUILD_STATIC "" OFF) if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX") @@ -193,168 +35,29 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") endif() -macro(mamba_create_target target_name linkage output_name) - string(TOUPPER "${linkage}" linkage_upper) - - if (NOT ${linkage_upper} MATCHES "^(SHARED|STATIC)$") - message(FATAL_ERROR "Invalid library linkage: ${linkage}") - endif () - - # Output - # ====== - - add_library(${target_name} ${linkage_upper} ${MAMBA_SOURCES} ${MAMBA_HEADERS} ${MAMBA_THIRD_PARTIES}) - if (NOT STATIC_DEPENDENCIES) - find_library(LIBSOLV_LIBRARIES NAMES solv) - find_library(LIBSOLVEXT_LIBRARIES NAMES solvext) - find_package(CURL REQUIRED) - find_package(LibArchive REQUIRED) - find_package(OpenSSL REQUIRED) - find_package(yaml-cpp CONFIG REQUIRED) - find_package(reproc++ CONFIG REQUIRED) - +# Variants +# ======== - set(MAMBA_DEPENDENCIES_LIBS - ${LIBSOLV_LIBRARIES} - ${LIBSOLVEXT_LIBRARIES} - ${LibArchive_LIBRARIES} - ${CURL_LIBRARIES} - ${OPENSSL_LIBRARIES} - ${YAML_CPP_LIBRARIES} - reproc++ - ) +if (BUILD_MICROMAMBA OR BUILD_LIBMAMBA_TESTS OR BUILD_LIBMAMBAPY) + set(BUILD_LIBMAMBA ON) + set(BUILD_STATIC ON) +endif() - target_link_libraries(${target_name} PUBLIC - ${MAMBA_DEPENDENCIES_LIBS} - ${MAMBA_FORCE_DYNAMIC_LIBS} - nlohmann_json::nlohmann_json - Threads::Threads) +# libmamba library and tests +if (BUILD_LIBMAMBA) + if (BUILD_LIBMAMBA_TESTS) + set(BUILD_TESTS ON) endif() - set_property(TARGET ${target_name} PROPERTY CXX_STANDARD 17) - - target_include_directories( - ${target_name} - PUBLIC - $ - $ - ) - - target_include_directories( - ${target_name} - PRIVATE ${MAMBA_SOURCE_DIR} - ) - - set_target_properties( - ${target_name} - PROPERTIES - PUBLIC_HEADER "${MAMBA_HEADERS}" - COMPILE_DEFINITIONS "MAMBA_EXPORTS" - PREFIX "" - VERSION ${MAMBA_BINARY_VERSION} - SOVERSION ${MAMBA_BINARY_CURRENT} - OUTPUT_NAME "lib${output_name}" - ) -endmacro() - - -set(mamba_targets "") - -if (BUILD_SHARED) - message(STATUS "BUILDING SHARED") - mamba_create_target(mamba SHARED mamba) - list(APPEND mamba_targets mamba) -endif () - -if (BUILD_STATIC) - message(STATUS "BUILDING STATIC") - # On Windows, a static library should use a different output name - # to avoid the conflict with the import library of a shared one. - if (CMAKE_HOST_WIN32) - mamba_create_target(mamba-static STATIC mamba_static) - else () - mamba_create_target(mamba-static STATIC mamba) - endif () - - find_package(nlohmann_json CONFIG REQUIRED) - - target_link_libraries(mamba-static PUBLIC - nlohmann_json::nlohmann_json - Threads::Threads) - - list(APPEND mamba_targets mamba-static) -endif () - -if (BUILD_BINDINGS) - find_package(pybind11 REQUIRED) - pybind11_add_module(mamba_api - src/mamba/py_interface.cpp - ) - target_link_libraries(mamba_api PUBLIC pybind11::pybind11 mamba-static) - set_property(TARGET mamba_api PROPERTY CXX_STANDARD 17) - - install(TARGETS mamba_api - LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/mamba/) + add_subdirectory(libmamba) endif() -if (BUILD_EXE) - include(${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/CMakeLists.txt) +# Python bindings of libmamba +if (BUILD_LIBMAMBAPY) + add_subdirectory(libmambapy) endif() -# Tests -# ===== -if (ENABLE_TESTS) - add_subdirectory(test) +# micromamba +if (BUILD_MICROMAMBA) + add_subdirectory(micromamba) endif() - -# Installation -# ============ - -include(GNUInstallDirs) -include(CMakePackageConfigHelpers) - -set(MAMBA_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for mambaConfig.cmake") - -if (NOT (BUILD_EXE AND STATIC_DEPENDENCIES)) - - install(TARGETS ${mamba_targets} - EXPORT ${PROJECT_NAME}-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - - install(DIRECTORY "${MAMBA_INCLUDE_DIR}/" - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - FILES_MATCHING - PATTERN "*.hpp" - PATTERN "*.h") - - # Makes the project importable from the build directory - export(EXPORT ${PROJECT_NAME}-targets - FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake") - - # Configure 'mambaConfig.cmake' for a build tree - set(MAMBA_CONFIG_CODE "####### Expanded from \@MAMBA_CONFIG_CODE\@ #######\n") - set(MAMBA_CONFIG_CODE "${MAMBA_CONFIG_CODE}set(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake;\${CMAKE_MODULE_PATH}\")\n") - set(MAMBA_CONFIG_CODE "${MAMBA_CONFIG_CODE}##################################################") - configure_package_config_file(${PROJECT_NAME}Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${PROJECT_BINARY_DIR}) - - # Configure 'mambaConfig.cmake' for an install tree - set(MAMBA_CONFIG_CODE "") - configure_package_config_file(${PROJECT_NAME}Config.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${MAMBA_CMAKECONFIG_INSTALL_DIR}) - - - write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - VERSION ${MAMBA_VERSION_MAJOR}.${MAMBA_VERSION_MINOR}.${MAMBA_VERSION_PATCH} - COMPATIBILITY AnyNewerVersion) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${MAMBA_CMAKECONFIG_INSTALL_DIR}) - install(EXPORT ${PROJECT_NAME}-targets - FILE ${PROJECT_NAME}Targets.cmake - DESTINATION ${MAMBA_CMAKECONFIG_INSTALL_DIR}) -endif () diff --git a/README.md b/README.md index 54885e4172..3af3f3ed12 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Now you are ready to install packages with ```bash mamba install xtensor-r -c conda-forge ``` + for example. ### Additional features @@ -98,7 +99,6 @@ $ mamba repoquery whoneeds ipython With the `--tree` (or `-t`) flag, you can get the same information in a tree. - ## micromamba `micromamba` is a tiny version of the `mamba` package manager. @@ -140,43 +140,7 @@ For more instructions (including OS X) check out https://gist.github.com/wolfv/f ### Development installation -Make sure you install mamba's requirements in your conda environment: - -`mamba env update --name --file environment-dev.yml` - -If you build mamba in a different environment than base, you must also install conda in -that environment: - -`mamba install conda -c conda-forge` - -For a local (dev) build, run `pip install -e .`. This will build and install mamba -in the conda environment. - -#### cmake based build - -You will additionally need to install cmake and cli11 for micromamba: - -```bash -mamba install -c conda-forge cli11 cmake -``` - -For the C++ tests, you need Google Test and Google Mock installed (e.g. `mamba install gtest gmock`). -To build the program using CMake, the following lines need to be used: - -```bash -mkdir -p build -cd build -cmake .. \ - -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ - -DPYTHON_EXECUTABLE=$CONDA_PREFIX/bin/python3 \ - -DPYTHON_LIBRARIES=$CONDA_PREFIX/lib/libpython3.7m.so \ - -DENABLE_TESTS=ON -cmake --build . -j -``` - -This would generate the test program `./test/test_mamba` under the `build` -directory which you can execute with `make test`. To generate the executable -`micromamba` also include the CMake option `-DBUILD_EXE=ON` in the above step. +Please refer to the instructions given by the [official documentation](https://mamba.readthedocs.io/en/latest/developer_zone/build_locally.html#). ### Support us diff --git a/docs/source/developer_zone/build_locally.rst b/docs/source/developer_zone/build_locally.rst index aee4a6f24a..3dd3b9fb40 100644 --- a/docs/source/developer_zone/build_locally.rst +++ b/docs/source/developer_zone/build_locally.rst @@ -28,154 +28,178 @@ Install dev requirements .. code:: - mamba env update --name --file environment-dev.yml + mamba env update --name --file .//environment-dev.yml .. code:: - micromamba install --name --file environment-dev.yml + micromamba install --name --file .//environment-dev.yml -If you don't have one, refer to the :ref:`installation` page. +Pick the correction environment spec file depending on the project you want to build. -``mamba`` relies on ``python setup.py`` installation while others targets rely on ``cmake`` configuration. +If you don't have an existing env, refer to the :ref:`installation` page. + +The different parts of this repository are sub-projects, all relying (totally or partially) on ``cmake`` configuration. .. note:: All ``cmake`` commands listed below use ``bash`` multi-line syntax. On Windows, replace ``\`` trailing character with ``^``. +.. note:: + Feel free to use your favorite generator: ``make``, ``ninja``, etc. -Build ``mamba`` -=============== - -If you build ``mamba`` in a different environment than *base*, you must also install ``conda`` -in that environment: - -.. code:: - - mamba install conda -c conda-forge +Build ``libmamba`` +================== -For a local (dev) build, run in the environment: +``libmamba`` build is enabled using ``BUILD_LIBMAMBA`` ``cmake`` option. -.. code:: +Shared library +************** - pip install -e . +Also needs ``BUILD_SHARED`` to be activated: -This will build and install ``mamba`` in the current environment. +.. code:: bash -Build ``micromamba`` -==================== + mkdir -p build + cd build + cmake .. \ + -DBUILD_LIBMAMBA=ON \ + -DBUILD_SHARED=ON + make -Dynamically linked -****************** +Static library +************** -To build ``micromamba``, just activate the ``BUILD_EXE`` flag in ``cmake`` command: +Also needs ``BUILD_STATIC`` to be activated: .. code:: bash mkdir -p build cd build cmake .. \ - -BUILD_EXE=ON - cmake --build . -j + -DBUILD_LIBMAMBA=ON \ + -DBUILD_STATIC=ON + make -.. note:: - Feel free to use your favorite generator: ``make``, ``ninja``, etc. +Tests +***** -.. note:: - If you need to install, use to install in your current development environment: +First, compile the ``gtest``-based C++ test suite: - - ``-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX`` [unix] - - ``-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX\\Library`` [win] +.. code:: -| Doing so, you have built the dynamically linked version of ``micromamba``. -| It's well fitted for development but is not the artifact shipped when installing ``micromamba``. + mkdir -p build + cd build + cmake .. \ + -DBUILD_LIBMAMBA_TESTS=ON + make +You should now be able to run: -Statically linked -***************** +.. code:: -``micromamba`` is a fully statically linked executable. To build it, you need to install extra requirements: + ./libmamba/tests/test_libmamba + +Alternatively you can use: .. code:: - micromamba install --name --file environment-static-dev.yml + make test -It will install the development version of dependencies, including static libraries. +.. note:: + The static version of ``libmamba`` is necessary to build the C++ tests, it will be automatically turned-on + + +Build ``libmambapy`` +==================== -Now you can run ``cmake`` with the additional flag ``STATIC_DEPENDENCIES`` turned on: +The Python bindings of ``libmamba``, ``libmambapy`` can be built by using the ``BUILD_LIBMAMBAPY`` ``cmake`` option. .. code:: bash mkdir -p build cd build cmake .. \ - -DBUILD_EXE=ON \ - -DSTATIC_DEPENDENCIES=ON - cmake --build . -j + -DBUILD_LIBMAMBAPY=ON + make -Tests -***** +You'll need to install the target to have the bindings Python sub-module correctly located, then you can use ``pip`` to install that Python package: -You should now be able to run the Python-based test suite: +.. code:: bash -.. code:: + make install + pip install -e ../libmambapy/ --no-deps - pytest ./test/micromamba +.. note:: + The editable mode ``-e`` provided by ``pip`` allows to use the source directory as the Python package instead of copying sources inside the environment + You can then change the code without having to reinstall the package +.. note:: + The ``--no-deps`` tells ``pip`` to skip the dependencies installation, since they are already installed (``libmamba`` installed using ``cmake``) -Build ``libmamba`` -================== -Shared library -************** +Build ``mamba`` +=============== + +You need to build and install ``libmambapy``, which is a dependency of ``mamba``, then install ``mamba``: + +.. code:: + pip install -e ./mamba/ --no-deps -You need to enable the build of ``libmamba`` shared library using ``BUILD_SHARED`` flag in ``cmake`` command: + +Build ``micromamba`` +==================== + +Dynamically linked +****************** + +To build ``micromamba``, just activate the ``BUILD_MICROMAMBA`` flag in ``cmake`` command: .. code:: bash mkdir -p build cd build cmake .. \ - -DBUILD_SHARED=ON - cmake --build . -j + -BUILD_MICROMAMBA=ON + make -Static library -************** +.. note:: + If you need to install the executable, use your current development environment: -| The static build of ``libmamba`` is enabled by default (``BUILD_STATIC=ON``). -| You can run : + - ``-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX`` [unix] + - ``-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX\\Library`` [win] -.. code:: bash +| Doing so, you have built the dynamically linked version of ``micromamba``. +| It's well fitted for development but is not the artifact shipped when installing ``micromamba`` because it still requires the dependencies shared libraries to work. - mkdir -p build - cd build - cmake .. - cmake --build . -j -Tests -***** +Statically linked +***************** -First, compile the ``gtest``-based C++ test suite: +``micromamba`` is a fully statically linked executable. To build it, you need to install extra requirements: .. code:: + micromamba install --name --file ./micromamba/environment-static-dev.yml + +It will install the development version of dependencies, including static libraries. + +Now you can run ``cmake`` with the additional flag ``MICROMAMBA_STATIC_LINK`` turned on: + +.. code:: bash + mkdir -p build cd build cmake .. \ - -DENABLE_TESTS=ON - cmake --build . -j - -You should now be able to run: - -.. code:: + -DBUILD_MICROMAMBA=ON \ + -DMICROMAMBA_STATIC_LINK=ON + make - ./test/test_mamba +Tests +***** -Alternatively you can use: +You should be able to run the Python-based test suite: .. code:: - make test - -.. note:: - The static version of ``libmamba`` is necessary to build the C++ tests, don't disable it! + pytest ./micromamba/tests/ diff --git a/include/mamba/core/version.hpp.in b/include/mamba/core/version.hpp.in deleted file mode 100644 index b8f7ae3e85..0000000000 --- a/include/mamba/core/version.hpp.in +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2019, QuantStack and Mamba Contributors -// -// Distributed under the terms of the BSD 3-Clause License. -// -// The full license is in the file LICENSE, distributed with this software. - -#ifndef MAMBA_CORE_VERSION_HPP -#define MAMBA_CORE_VERSION_HPP - -#include - -#define MAMBA_VERSION_MAJOR @MAMBA_VERSION_MAJOR@ -#define MAMBA_VERSION_MINOR @MAMBA_VERSION_MINOR@ -#define MAMBA_VERSION_PATCH @MAMBA_VERSION_PATCH@ - -// Binary version -#define MAMBA_BINARY_CURRENT 1 -#define MAMBA_BINARY_REVISION 0 -#define MAMBA_BINARY_AGE 0 - -#define MAMBA_VERSION \ - (MAMBA_VERSION_MAJOR * 10000 + MAMBA_VERSION_MINOR * 100 + MAMBA_VERSION_PATCH) -#define MAMBA_VERSION_STRING "@MAMBA_VERSION_MAJOR@.@MAMBA_VERSION_MINOR@.@MAMBA_VERSION_PATCH@" - -extern const char mamba_version[]; -extern int mamba_version_major; -extern int mamba_version_minor; -extern int mamba_version_patch; - -std::string version(); - -#endif diff --git a/libmamba/CHANGELOG.md b/libmamba/CHANGELOG.md new file mode 100644 index 0000000000..bebd2d5d72 --- /dev/null +++ b/libmamba/CHANGELOG.md @@ -0,0 +1,526 @@ +0.17.0 (October 13, 2021) +========================= + +API Breaking changes: + +The Transaction and the Subdir interface have slightly changed (no more explicit setting of the writable +packages dir is necessary, this value is taken directly from the MultiPackagesCache now) + +- improve listing of (RC-) configurable values in `micromamba` #1210 (thanks @adriendelsalle) +- Improve micromamba lockfiles and add many tests #1193 (thanks @adriendelsalle) +- Support multiple package caches in micromamba (thanks @adriendelsalle) #1109 +- Order explicit envs in micromamba (also added some text to the docs about libsolv transactions) #1198 +- Add `micromamba package` subcommand to extract, create and transmute packages #1187 +- Improve micromamba configuration to support multi-stage loading of RC files (thanks @adriendelsalle) #1189 #1190 #1191 #1188 +- Add handling of `CONDA_SAFETY_CHECKS` to micromamba #1143 (thanks @isuruf) +- Improve mamba messaging by adding a space #1186 (thanks @wkusnierczyk) +- Add support for `custom_multichannels` #1142 +- micromamba: expose setting for `add_pip_as_python_dependency` #1203 +- stop displaying banner when running `mamba list` #1184 (thanks @madhur-thandon) + +0.16.0 (September 27, 2021) +=========================== + +- Add a User-Agent header to all requests (mamba/0.16.0) (thanks @shankerwangmiao) +- Add `micromamba env export (--explicit)` to micromamba +- Do not display banner with `mamba list` (thanks @madhur-tandon) +- Use directory of environment.yml as cwd when creating environment (thanks @marscher & @adriendelsalle) +- Improve outputs +- content-trust: Add Python bindings for content-trust API +- content-trust: Load PkgMgr definitions from file +- content-trust: Improve HEAD request fallback handling +- export Transaction.find_python_version to Python +- Continue `shell init` when we can't create the prefix script dir (thanks @maresb) +- Implement support for `fish` shell in `micromamba` (thanks @soraxas) +- Add constraint with pin when updating +- Expose methods for virtual packages to Python (thanks @madhur-tandon) + +0.15.3 (August 18, 2021) +======================== + +- change token regex to work with edge-cases (underscores in user name) (#1122) +- only pin major.minor version of python for update --all (#1101, thanks @mparry!) +- add mamba init to the activate message (#1124, thanks @isuruf) +- hide tokens in logs (#1121) +- add lockfiles for repodata and pkgs download (#1105, thanks @jaimergp) +- log actual SHA256/MD5/file size when failing to avlidate (#1095, thanks @johnhany97) +- Add mamba.bat in front of PATH (#1112, thanks @isuruf) +- Fix mamba not writable cache errors (#1108) + +0.15.2 (July 16, 2021) +====================== + +- micromamba autocomplete now ready for usage (#1091) +- improved file:// urls for windows to properly work (#1090) + +0.15.1 (July 15, 2021) +====================== + +New features: +- add `mamba init` command and add mamba.sh (#1075, thanks @isuruf & #1078) +- add flexible channel priority option in micromamba CLI (#1087) +- improved autocompletion for micromamba (#1079) + +Bug fixes: +- improve "file://" URL handling, fix local channel on Windows (#1085) +- fix CONDA_SUBDIR not being used in mamba (#1084) +- pass in channel_alias and custom_channels from conda to mamba (#1081) + +0.15.0 (July 9, 2021) +===================== + +Big changes: +- improve solutions by inspecting dependency versions as well (libsolv PR: + https://github.com/openSUSE/libsolv/pull/457) @wolfv +- properly implement strict channel priority (libsolv PR: + https://github.com/openSUSE/libsolv/pull/459) @adriendelsalle + + Note that this changes the meaning of strict and flexible priority as the + previous implementation did not follow conda's semantics. Mamba now has + three modes, just like conda: strict, flexible and disabled. Strict will + completely disregard any packages from lower-priority channels if a + package of the same name exists in a higher priority channel. Flexible + will use packages from lower-priority channels if necessary to fulfill + dependencies or explicitly requested (e.g. by version number). Disabled + will use the highest version number, irregardless of the channel order. +- allow subdir selection as part of the channel: users can now specify an + explicit list of subdirs, for example: + + `-c mychannel[linux-static64, linux-64, noarch]` + + to pull in repodata and packages from these three subdirs. + Thanks for the contribution, @afranchuk! #1033 + +New features +- remove orphaned packages such as dependencies of explicitely installed + packages (@adriendelsalle) #1040 +- add a diff character before package name in transaction table to improve + readability without coloration (@adriendelsalle) #1040 +- add capability to freeze installed packages during `install` operation using + `--freeze-installed` flag (@adriendelsalle) #1048 +- Hide tokens and basic http auth secrets in log messages (#1061) +- Parse and use explicit platform specifications (thanks @afranchuk) (#1033) +- add pretty print to repoquery search (thanks @madhur-tandon) (#1018) +- add docs for package resolution + +Bug fixes: +- Fix small output issues (#1060) +- More descriptive incorrect download error (thanks @AntoinePrv) #1066 +- respect channel specific pins when updating (#1045) +- keep track features in PackageInfo class (#1046) + + +0.14.1 (June 25, 2021) +====================== + +New features +- [micromamba] add remove command, to remove keys of vectors (@marimeireles) + #1011 + +Bug fixes +- [micromamba] fixed in config prepend and append sequence (@adriendelsalle) + #1023 +- fix bug when username has @ (@madhur-tandon) #1025 +- fix wrong update spec in history (@madhur-tandon) #1028 +- [mamba] silent pinned packages using JSON output (@adriendelsalle) #1031 + +0.14.0 (June 16, 2021) +====================== + +New features +- [micromamba] add `config set`, `get`, `append` and `prepend`, `remove` + (@marimeireles) #838 +- automatically include `pip` in conda dependencies when having pip packages to + install (@madhur-tandon) #973 +- add experimental support for artifacts verification (@adriendelsalle) + #954,#955,#956,#963,#965,#970,#972,#978 +- [micromamba] shell init will try attempt to enable long paths support on + Windows (@wolfv) #975 +- [micromamba] if `menuinst` json files are present, micromamba will create + shortcuts in the start menu on Windows (@wolfv) #975 +- Improve python auto-pinning and add --no-py-pin flag to micromamba + (@adriendelsalle) #1010 +- [micromamba] Fix constructor invalid repodata_record (@adriendelsalle) #1007 +- Refactor log levels for linking steps (@adriendelsalle) #1009 +- [micromamba] Use a proper requirements.txt file for pip installations #1008 + +Bug fixes +- fix double-print int transaction (@JohanMabille) #952 +- fix strip function (@wolfv) #974 +- [micromamba] expand home directory in `--rc-file` (@adriendelsalle) #979 +- [micromamba] add yes and no as additional ways of answering a prompt + (@ibebrett) #989 +- fix long paths support on Windows (@adriendelsalle) #994 + +General improvement +- remove duplicate snippet (@madhur-tandon) #957 +- add `trace` log level (@adriendelsalle) #988 + +Docs +- concepts, user guide, configuration, update installation and build locally + (@adriendelsalle) #953 +- advance usage section, linking (@adriendelsalle) #998 +- repo, channel, subdir, repodata, tarball (@adriendelsalle) #1004 +- artifacts verification (@adriendelsalle) #1000 + +0.13.1 (May 17, 2021) +===================== + +Bug fixes +- [micromamba] pin only minor python version #948 +- [micromamba] use openssl certs when not linking statically #949 + +0.13.0 (May 12, 2021) +===================== + +New features +- [mamba & micromamba] aggregated progress bar for package downloading and + extraction (thanks @JohanMabille) #928 + +Bug fixes +- [micromamba] fixes for micromamba usage in constructor #935 +- [micromamba] fixes for the usage of lock files #936 +- [micromamba] switched from libsodium to openssl for ed25519 signature + verification #933 + +Docs +- Mention mambaforge in the README (thanks @s-pike) #932 + +0.12.3 (May 10, 2021) +===================== + +New features +- [libmamba] add free-function to use an existing conda root prefix + (@adriendelsalle) #927 + +General improvements +- [micromamba] fix a typo in documentation (@cjber) #926 + +0.12.2 (May 03, 2021) +===================== + +New features +- [micromamba] add initial framework for TUF validation (@adriendelsalle) #916 + #919 +- [micromamba] add channels from specs to download (@wolfv) #918 + +0.12.1 (Apr 30, 2021) +===================== + +New features +- [micromamba] env list subcommand (@wolfv) #913 + +Bug fixes +- [micromamba] fix multiple shell init with cmd.exe (@adriendelsalle) #915 +- [micromamba] fix activate with --stack option (@wolfv) #914 +- [libmamba] only try loading ssl certificates when needed (@adriendelsalle) + #910 +- [micromamba] remove target_prefix checks when activating (@adriendelsalle) + #909 +- [micromamba] allow 'ultra-dry' config checks in final build (@adriendelsalle) + #912 + +0.12.0 (Apr 26, 2021) +===================== + +New features +- [libmamba] add experimental shell autocompletion (@wolfv) #900 +- [libmamba] add token handling (@wolfv) #886 +- [libmamba] add experimental pip support in spec files (@wolfv) #885 + +Bug fixes +- [libmamba] ignore failing pyc compilation for noarch packages (@wolfv) #904 + #905 +- [libmamba] fix string wrapping in error message (@bdice) #902 +- [libmamba] fix cache error during remove operation (@adriendelsalle) #901 +- [libmamba] add constraint with pinning during update operation (@wolfv) #892 +- [libmamba] fix shell activate prefix check (@ashwinvis) #889 +- [libmamba] make prefix mandatory for shell init (@adriendelsalle) #896 +- [mamba] fix `env update` command (@ScottWales) #891 + +General improvements +- [libmamba] use lockfile, fix channel not loaded logic (@wolfv) #903 +- [libmamba] make root_prefix warnings more selective (@adriendelsalle) #899 +- [libmamba] house-keeping in python tests (@adriendelsalle) #898 +- [libmamba] modify mamba/micromamba specific guards (@adriendelsalle) #895 +- [libmamba] add simple lockfile mechanism (@wolfv) #894 +- [libmamba] deactivate ca-certificates search when using offline mode + (@adriendelsalle) #893 + +0.11.3 (Apr 21, 2021) +==================== + +- [libmamba] make platform rc configurable #883 +- [libmamba] expand user home in target and root prefixes #882 +- [libmamba] avoid memory effect between operations on target_prefix #881 +- [libmamba] fix unnecessary throwing target_prefix check in `clean` operation + #880 +- [micromamba] fix `clean` flags handling #880 +- [libmamba] C-API teardown on error #879 + +0.11.2 (Apr 21, 2021) +==================== + +- [libmamba] create "base" env only for install operation #875 +- [libmamba] remove confirmation prompt of root_prefix in shell init #874 +- [libmamba] improve overrides between target_prefix and env_name #873 +- [micromamba] fix use of `-p,--prefix` and spec file env name #873 + +0.11.1 (Apr 20, 2021) +==================== + +- [libmamba] fix channel_priority computation #872 + +0.11.0 (Apr 20, 2021) +==================== + +- [libmamba] add experimental mode that unlock edge features #858 +- [micromamba] add `--experimental` umamba flag to enable experimental mode + #858 +- [libmamba] improve base env creation #860 +- [libmamba] fix computation of weakly canonical target prefix #859 +- update libsolv dependency in env-dev.yml file, update documentation (thanks + @Aratz) #843 +- [libmamba] handle package cache in secondary locations, fix symlink errors + (thanks wenjuno) #856 +- [libmamba] fix CI cURL SSL error on macos with Darwin backend (thanks @wolfv) + #865 +- [libmamba] improve error handling in C-API by catching and returning an error + code #862 +- [libmamba] handle configuration lifetime (single operation configs) #863 +- [libmamba] enable ultra-dry C++ tests #868 +- [libmamba] migrate `config` operation implem from `micromamba` to `libmamba` + API #866 +- [libmamba] add capapbility to set CLI config from C-API #867 + +0.10.0 (Apr 16, 2021) +==================== + +- [micromamba] allow creation of empty env (without specs) #824 #827 +- [micromamba] automatically create empy `base` env at new root prefix #836 +- [micromamba] add remove all CLI flags `-a,--all` #824 +- [micromamba] add dry-run and ultra-dry-run tests to increase coverage and + speed-up CI #813 #845 +- [micromamba] allow CLI to override spec file env name (create, install and + update) #816 +- [libmamba] split low-level and high-level API #821 #824 +- [libmamba] add a C high-level API #826 +- [micromamba] support `__linux` virtual package #829 +- [micromamba] improve the display of solver problems #822 +- [micromamba] improve info sub-command with target prefix status (active, not + found, etc.) #825 +- [mamba] Change pybind11 to a build dependency (thanks @maresb) #846 +- [micromamba] add shell detection for shell sub-command #839 +- [micromamba] expand user in shell prefix sub-command #831 +- [micromamba] refactor explicit specs install #824 +- [libmamba] improve configuration (refactor API, create a loading sequence) + #840 +- [libmamba] support cpp-filesystem breaking changes on Windows fs #849 +- [libmamba] add a simple context debugging (thanks @wolf) #820 +- [libmamba] improve C++ test suite #830 +- fix CI C++ tests (unix/libmamba) and Python tests (win/mamba) wrongly + successful #853 + +0.9.2 (Apr 1, 2021) +==================== + +- [micromamba] fix unc url support (thanks @adament) +- [micromamba] add --channel-alias as cli option to micromamba (thanks + @adriendelsalle) +- [micromamba] fix --no-rc and environment yaml files (thanks @adriendelsalle) +- [micromamba] handle spec files in update and install subcommands (thanks + @adriendelsalle) +- add simple context debugging, dry run tests and other test framework + improvements + +0.9.1 (Mar 26, 2021) +==================== + +- [micromamba] fix remove command target_prefix selection +- [micromamba] improve target_prefix fallback for CLI, add tests (thanks + @adriendelsalle) + +0.9.0 (Mar 25, 2021) +==================== + +- [micromamba] use strict channels priority by default +- [micromamba] change config precedence order: API>CLI>ENV>RC +- [micromamba] `config list` sub command optional display of sources, defaults, + short/long descriptions and groups +- [micromamba] prevent crashes when no bashrc or zshrc file found (thanks + @wolfv) +- add support for UNC file:// urls (thanks @adament) +- add support for use_only_tar_bz2 (thanks @tl-hbk @wolfv) +- add pinned specs for env update (thanks @wolfv) +- properly adhere to run_constrains (thanks @wolfv) + +0.8.2 (Mar 12, 2021) +==================== + +- [micromamba] fix setting network options before explicit spec installation +- [micromamba] fix python based tests for windows + + +0.8.1 (Mar 11, 2021) +==================== + +- use stoull (instead of stoi) to prevent overflow with long package build + numbers (thanks @pbauwens-kbc) +- [micromamba] fixing OS X certificate search path +- [micromamba] refactor default root prefix, make it configurable from CLI + (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible (thanks + @adriendelsalle) +- [micromamba] sort json transaction, and add UNLINK field +- [micromamba] left align log messages +- [micromamba] libsolv log messages to stderr (thanks @mariusvniekerk) +- [micromamba] better curl error messages + + +0.8.0 (Mar 5, 2021) +=================== + +- [micromamba] condarc and mambarc config file reading (and config subcommand) + (thanks @adriendelsalle) +- [micromamba] support for virtual packages (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible +- [micromamba] add python based testing framework for CLI +- [micromamba] refactor CLI and micromamba main file (thanks @adriendelsalle) +- [micromamba] add linking options (--always-copy etc.) (thanks + @adriendelsalle) +- [micromamba] fix multiple prefix replacements in binary files +- [micromamba] fix micromamba clean (thanks @phue) +- [micromamba] change package validation settings to --safety-checks and + --extra-safety-checks +- [micromamba] add update subcommand (thanks @adriendelsalle) +- [micromamba] support pinning packages (including python minor version) + (thanks @adriendelsalle) +- [micromamba] add try/catch to WinReg getStringValue (thanks @SvenAdler) +- [micromamba] add ssl-no-revoke option for more conda-compatibility (thanks + @tl-hbk) +- [micromamba] die when no ssl certificates are found (thanks @wholtz) +- [docs] add explanation for base env install (thanks @ralexx) and rename + changelog to .md (thanks @kevinheavey) +- [micromamba] compare cleaned URLs for cache invalidation +- [micromamba] add regex handling to list command + + +0.7.14 (Feb 12, 2021) +===================== + +- [micromamba] better validation of extracted directories +- [mamba] add additional tests for authentication and simple repodata server +- make LOG_WARN the default log level, and move some logs to INFO +- [micromamba] properly replace long shebangs when linking +- [micromamba] add quote for shell for prefixes with spaces +- [micromamba] add clean functionality +- [micromamba] always make target prefix path absolute + + +0.7.13 (Feb 4, 2021) +==================== + +- [micromamba] Immediately exit after printing version (again) + +0.7.12 (Feb 3, 2021) +==================== + +- [micromamba] Improve CTRL+C signal handling behavior and simplify code +- [micromamba] Revert extraction to temporary directory because of invalid + cross-device links on Linux +- [micromamba] Clean up partially extracted archives when CTRL+C interruption + occured + +0.7.11 (Feb 2, 2021) +==================== + +- [micromamba] use wrapped call when compiling noarch Python code, which + properly calls chcp for Windows +- [micromamba] improve checking the pkgs cache +- [mamba] fix authenticated URLs (thanks @wenjuno) +- first extract to temporary directory, then move to final pkgs cache to + prevent corrupted extracted data + +0.7.10 (Jan 22, 2021) +==================== + +- [micromamba] properly fix PATH when linking, prevents missing + vcruntime140.dll +- [mamba] add virtual packages when creating any environment, not just on + update (thanks @cbalioglu) + +0.7.9 (Jan 19, 2021) +==================== + +- [micromamba] fix PATH when linking + +0.7.8 (Jan 14, 2021) +==================== + +- [micromamba] retry on corrupted repodata +- [mamba & micromamba] fix error handling when writing repodata + +0.7.6 (Dec 22, 2020) +==================== + +- [micromamba] more console flushing for std::cout consumers + +0.7.6 (Dec 14, 2020) +==================== + +- [mamba] more arguments for repodata.create_pool + +0.7.5 (Dec 10, 2020) +==================== + +- [micromamba] better error handling for YAML file reading, allows to pass in + `-n` and `-p` from command line +- [mamba & micromamba] ignore case of HTTP headers +- [mamba] fix channel keys are without tokens (thanks @s22chan) + +0.7.4 (Dec 5, 2020) +==================== + +- [micromamba] fix noarch installation for explicit environments + +0.7.3 (Nov 20, 2020) +==================== + +- [micromamba] fix installation of noarch files with long prefixes +- [micromamba] fix activation on windows with whitespaces in root prefix + (thanks @adriendelsalle) +- [micromamba] add `--json` output to micromamba list + +0.7.2 (Nov 18, 2020) +==================== + +- [micromamba] explicit specs installing should be better now + - empty lines are ignored + - network settings are correctly set to make ssl verification work +- New Python repoquery API for mamba +- Fix symlink packing for mamba package creation and transmute +- Do not keep tempfiles around + +0.7.1 (Nov 16, 2020) +==================== + +- Handle LIBARCHIVE_WARN to not error, instead print warning (thanks @obilaniu) + +0.7.0 (Nov 12, 2020) +==================== + +- Improve activation and deactivation logic for micromamba +- Switching `subprocess` implementation to more tested `reproc++` +- Fixing Windows noarch entrypoints generation with micromamba +- Fix pre-/post-link script running with micromamba to use micromamba + activation logic +- Empty environment creation skips all repodata downloading & solving +- Fix micromamba install when environment is activated (thanks @isuruf) +- Micromamba now respects the $CONDA_SUBDIR environment variable (thanks + @mariusvniekerk) +- Fix compile time warning (thanks @obilaniu) +- Fixed wrong CondaValueError import statement in mamba.py (thanks @saraedum) + +0.6.5 (Oct 2020) +================ + +- Fix code signing for Apple Silicon (osx-arm64) @isuruf diff --git a/libmamba/CMakeLists.txt b/libmamba/CMakeLists.txt new file mode 100644 index 0000000000..8309c8004d --- /dev/null +++ b/libmamba/CMakeLists.txt @@ -0,0 +1,327 @@ +# Copyright (c) 2019, QuantStack and Mamba Contributors +# +# Distributed under the terms of the BSD 3-Clause License. +# +# The full license is in the file LICENSE, distributed with this software. + +cmake_minimum_required (VERSION 3.2) +if(POLICY CMP0025) + cmake_policy(SET CMP0025 NEW) +endif() +cmake_policy(SET CMP0077 NEW) + +project(libmamba) + +set(LIBMAMBA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +set(LIBMAMBA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) + +# Versionning +# =========== +file(STRINGS "${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp" libmamba_version_defines + REGEX "#define LIBMAMBA_VERSION_(MAJOR|MINOR|PATCH)") +foreach(ver ${libmamba_version_defines}) + if(ver MATCHES "#define LIBMAMBA_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$") + set(LIBMAMBA_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") + endif() +endforeach() +set(${PROJECT_NAME}_VERSION + ${LIBMAMBA_VERSION_MAJOR}.${LIBMAMBA_VERSION_MINOR}.${LIBMAMBA_VERSION_PATCH}) +message(STATUS "Building libmamba v${${PROJECT_NAME}_VERSION}") + + +# Binary version +# See the following URL for explanations about the binary versionning +# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html#Updating-version-info +file(STRINGS "${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp" libmamba_version_defines + REGEX "#define LIBMAMBA_BINARY_(CURRENT|REVISION|AGE)") +foreach(ver ${libmamba_version_defines}) + if(ver MATCHES "#define LIBMAMBA_BINARY_(CURRENT|REVISION|AGE) +([^ ]+)$") + set(LIBMAMBA_BINARY_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") + endif() +endforeach() +set(LIBMAMBA_BINARY_VERSION + ${LIBMAMBA_BINARY_CURRENT}.${LIBMAMBA_BINARY_REVISION}.${LIBMAMBA_BINARY_AGE}) +message(STATUS "libmamba binary version: v${LIBMAMBA_BINARY_VERSION}") + + +# Build options +# ============= +option(BUILD_TESTS "Build libmamba C++ tests" OFF) +option(BUILD_SHARED "Build shared libmamba library" OFF) +option(BUILD_STATIC "Build static libmamba library" OFF) + +option(MICROMAMBA_STATIC_LINK "" OFF) + +# Source files +# ============ + +set(LIBMAMBA_SOURCES + ${LIBMAMBA_SOURCE_DIR}/version.cpp + # Core API (low-level) + ${LIBMAMBA_SOURCE_DIR}/core/activation.cpp + ${LIBMAMBA_SOURCE_DIR}/core/channel.cpp + ${LIBMAMBA_SOURCE_DIR}/core/context.cpp + ${LIBMAMBA_SOURCE_DIR}/core/environments_manager.cpp + ${LIBMAMBA_SOURCE_DIR}/core/fetch.cpp + ${LIBMAMBA_SOURCE_DIR}/core/transaction_context.cpp + ${LIBMAMBA_SOURCE_DIR}/core/link.cpp + ${LIBMAMBA_SOURCE_DIR}/core/history.cpp + ${LIBMAMBA_SOURCE_DIR}/core/match_spec.cpp + ${LIBMAMBA_SOURCE_DIR}/core/menuinst.cpp + ${LIBMAMBA_SOURCE_DIR}/core/url.cpp + ${LIBMAMBA_SOURCE_DIR}/core/output.cpp + ${LIBMAMBA_SOURCE_DIR}/core/package_handling.cpp + ${LIBMAMBA_SOURCE_DIR}/core/package_cache.cpp + ${LIBMAMBA_SOURCE_DIR}/core/pool.cpp + ${LIBMAMBA_SOURCE_DIR}/core/prefix_data.cpp + ${LIBMAMBA_SOURCE_DIR}/core/progress_bar.cpp + ${LIBMAMBA_SOURCE_DIR}/core/pinning.cpp + ${LIBMAMBA_SOURCE_DIR}/core/package_info.cpp + ${LIBMAMBA_SOURCE_DIR}/core/package_paths.cpp + ${LIBMAMBA_SOURCE_DIR}/core/query.cpp + ${LIBMAMBA_SOURCE_DIR}/core/repo.cpp + ${LIBMAMBA_SOURCE_DIR}/core/shell_init.cpp + ${LIBMAMBA_SOURCE_DIR}/core/solver.cpp + ${LIBMAMBA_SOURCE_DIR}/core/subdirdata.cpp + ${LIBMAMBA_SOURCE_DIR}/core/thread_utils.cpp + ${LIBMAMBA_SOURCE_DIR}/core/transaction.cpp + ${LIBMAMBA_SOURCE_DIR}/core/util.cpp + ${LIBMAMBA_SOURCE_DIR}/core/util_os.cpp + ${LIBMAMBA_SOURCE_DIR}/core/validate.cpp + ${LIBMAMBA_SOURCE_DIR}/core/virtual_packages.cpp + # API (high-level) + ${LIBMAMBA_SOURCE_DIR}/api/c_api.cpp + ${LIBMAMBA_SOURCE_DIR}/api/clean.cpp + ${LIBMAMBA_SOURCE_DIR}/api/config.cpp + ${LIBMAMBA_SOURCE_DIR}/api/configuration.cpp + ${LIBMAMBA_SOURCE_DIR}/api/create.cpp + ${LIBMAMBA_SOURCE_DIR}/api/info.cpp + ${LIBMAMBA_SOURCE_DIR}/api/install.cpp + ${LIBMAMBA_SOURCE_DIR}/api/list.cpp + ${LIBMAMBA_SOURCE_DIR}/api/remove.cpp + ${LIBMAMBA_SOURCE_DIR}/api/shell.cpp + ${LIBMAMBA_SOURCE_DIR}/api/update.cpp +) + +set(LIBMAMBA_THIRD_PARTIES + ${LIBMAMBA_SOURCE_DIR}/thirdparty/WinReg.hpp +) + +set(LIBMAMBA_HEADERS + ${LIBMAMBA_INCLUDE_DIR}/mamba/version.hpp + # Core API (low-level) + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/activation.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/channel.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/context.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/environment.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/environments_manager.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/fetch.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/fsutil.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/graph_util.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/history.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/link.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/mamba_fs.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/match_spec.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/menuinst.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/output.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/package_cache.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/package_handling.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/package_info.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/package_paths.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/pool.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/prefix_data.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/progress_bar.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/pinning.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/query.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/repo.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/shell_init.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/solver.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/subdirdata.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/thread_utils.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/transaction.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/transaction_context.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/url.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/util.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/util_os.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/validate.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/core/virtual_packages.hpp + # API (high-level) + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/c_api.h + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/clean.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/config.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/configuration.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/constants.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/create.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/info.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/install.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/list.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/remove.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/shell.hpp + ${LIBMAMBA_INCLUDE_DIR}/mamba/api/update.hpp +) + +# Targets and link +# ================ + +macro(libmamba_create_target target_name linkage output_name) + string(TOUPPER "${linkage}" linkage_upper) + + if (NOT ${linkage_upper} MATCHES "^(SHARED|STATIC)$") + message(FATAL_ERROR "Invalid library linkage: ${linkage}") + endif () + + # Output + # ====== + + add_library(${target_name} ${linkage_upper} ${LIBMAMBA_SOURCES} ${LIBMAMBA_HEADERS} ${LIBMAMBA_THIRD_PARTIES}) + if (NOT MICROMAMBA_STATIC_LINK) + find_library(LIBSOLV_LIBRARIES NAMES solv) + find_library(LIBSOLVEXT_LIBRARIES NAMES solvext) + find_package(CURL REQUIRED) + find_package(LibArchive REQUIRED) + find_package(OpenSSL REQUIRED) + find_package(yaml-cpp CONFIG REQUIRED) + find_package(reproc++ CONFIG REQUIRED) + + set(LIBMAMBA_LIBRARIES_DEPS + ${LIBSOLV_LIBRARIES} + ${LIBSOLVEXT_LIBRARIES} + ${LibArchive_LIBRARIES} + ${CURL_LIBRARIES} + ${OPENSSL_LIBRARIES} + ${YAML_CPP_LIBRARIES} + reproc++ + ) + + target_link_libraries(${target_name} PUBLIC + ${LIBMAMBA_LIBRARIES_DEPS} + ${MAMBA_FORCE_DYNAMIC_LIBS}) + endif() + set_property(TARGET ${target_name} PROPERTY CXX_STANDARD 17) + + target_include_directories( + ${target_name} + PUBLIC + $ + $ + ) + + # TODO: package WinReg header + target_include_directories( + ${target_name} + PRIVATE ${LIBMAMBA_SOURCE_DIR} + ) + + if (UNIX) + math(EXPR LIBMAMBA_BINARY_COMPATIBLE "${LIBMAMBA_BINARY_CURRENT} - ${LIBMAMBA_BINARY_AGE}") + set_target_properties( + ${target_name} + PROPERTIES + PUBLIC_HEADER "${LIBMAMBA_HEADERS}" + COMPILE_DEFINITIONS "LIBMAMBA_EXPORTS" + PREFIX "" + VERSION "${LIBMAMBA_BINARY_COMPATIBLE}.${LIBMAMBA_BINARY_REVISION}.${LIBMAMBA_BINARY_AGE}" + SOVERSION ${LIBMAMBA_BINARY_COMPATIBLE} + OUTPUT_NAME "${output_name}" + ) + else() + set_target_properties( + ${target_name} + PROPERTIES + PUBLIC_HEADER "${LIBMAMBA_HEADERS}" + COMPILE_DEFINITIONS "LIBMAMBA_EXPORTS" + PREFIX "" + VERSION ${LIBMAMBA_BINARY_VERSION} + SOVERSION ${LIBMAMBA_BINARY_CURRENT} + OUTPUT_NAME "${output_name}" + ) + target_compile_definitions(${target_name} PUBLIC GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE) + endif() +endmacro() + + +set(libmamba_targets "") + +if (BUILD_SHARED) + message(STATUS "Building shared library libmamba") + libmamba_create_target(libmamba SHARED libmamba) + list(APPEND libmamba_targets libmamba) +endif () + +if (BUILD_STATIC) + message(STATUS "Building static library libmamba") + # On Windows, a static library should use a different output name + # to avoid the conflict with the import library of a shared one. + if (CMAKE_HOST_WIN32) + libmamba_create_target(libmamba-static STATIC libmamba_static) + else () + libmamba_create_target(libmamba-static STATIC libmamba) + endif () + + find_package(nlohmann_json CONFIG REQUIRED) + find_package(Threads REQUIRED) + + target_link_libraries(libmamba-static PUBLIC + nlohmann_json::nlohmann_json + Threads::Threads) + + list(APPEND libmamba_targets libmamba-static) +endif () + +if (NOT (BUILD_SHARED OR BUILD_STATIC)) + message(FATAL_ERROR "Select at least a build variant (shared/static) for libmamba") +endif () + +# Tests +if (BUILD_TESTS) + add_subdirectory(tests) +endif() + +# Installation +# ============ + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +set(LIBMAMBA_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for libmambaConfig.cmake") + +install(TARGETS ${libmamba_targets} + EXPORT ${PROJECT_NAME}-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + +install(DIRECTORY "${LIBMAMBA_INCLUDE_DIR}/" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING + PATTERN "*.hpp" + PATTERN "*.h") + +# Makes the project importable from the build directory +export(EXPORT ${PROJECT_NAME}-targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake") + +# Configure 'mambaConfig.cmake' for a build tree +set(MAMBA_CONFIG_CODE "####### Expanded from \@MAMBA_CONFIG_CODE\@ #######\n") +set(MAMBA_CONFIG_CODE "${MAMBA_CONFIG_CODE}set(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake;\${CMAKE_MODULE_PATH}\")\n") +set(MAMBA_CONFIG_CODE "${MAMBA_CONFIG_CODE}##################################################") +configure_package_config_file(${PROJECT_NAME}Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${PROJECT_BINARY_DIR}) + +# Configure 'mambaConfig.cmake' for an install tree +set(MAMBA_CONFIG_CODE "") +configure_package_config_file(${PROJECT_NAME}Config.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR}) + + +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${MAMBA_VERSION_MAJOR}.${MAMBA_VERSION_MINOR}.${MAMBA_VERSION_PATCH} + COMPATIBILITY AnyNewerVersion) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR}) +install(EXPORT ${PROJECT_NAME}-targets + FILE ${PROJECT_NAME}Targets.cmake + DESTINATION ${LIBMAMBA_CMAKECONFIG_INSTALL_DIR}) diff --git a/libmamba/LICENSE b/libmamba/LICENSE new file mode 100644 index 0000000000..8ae98f9375 --- /dev/null +++ b/libmamba/LICENSE @@ -0,0 +1,11 @@ +Copyright 2019 QuantStack and the Mamba contributors. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/data/Mamba.psm1 b/libmamba/data/Mamba.psm1 similarity index 100% rename from data/Mamba.psm1 rename to libmamba/data/Mamba.psm1 diff --git a/data/_mamba_activate.bat b/libmamba/data/_mamba_activate.bat similarity index 100% rename from data/_mamba_activate.bat rename to libmamba/data/_mamba_activate.bat diff --git a/data/activate.bat b/libmamba/data/activate.bat similarity index 100% rename from data/activate.bat rename to libmamba/data/activate.bat diff --git a/data/bin2header.py b/libmamba/data/bin2header.py similarity index 100% rename from data/bin2header.py rename to libmamba/data/bin2header.py diff --git a/data/conda_exe.hpp b/libmamba/data/conda_exe.hpp similarity index 100% rename from data/conda_exe.hpp rename to libmamba/data/conda_exe.hpp diff --git a/data/mamba.fish b/libmamba/data/mamba.fish similarity index 100% rename from data/mamba.fish rename to libmamba/data/mamba.fish diff --git a/data/mamba.sh b/libmamba/data/mamba.sh similarity index 100% rename from data/mamba.sh rename to libmamba/data/mamba.sh diff --git a/data/mamba.xsh b/libmamba/data/mamba.xsh similarity index 100% rename from data/mamba.xsh rename to libmamba/data/mamba.xsh diff --git a/data/mamba_hook.bat b/libmamba/data/mamba_hook.bat similarity index 100% rename from data/mamba_hook.bat rename to libmamba/data/mamba_hook.bat diff --git a/data/mamba_hook.ps1 b/libmamba/data/mamba_hook.ps1 similarity index 100% rename from data/mamba_hook.ps1 rename to libmamba/data/mamba_hook.ps1 diff --git a/data/micromamba.bat b/libmamba/data/micromamba.bat similarity index 100% rename from data/micromamba.bat rename to libmamba/data/micromamba.bat diff --git a/libmamba/environment-dev.yml b/libmamba/environment-dev.yml new file mode 100644 index 0000000000..e59d252522 --- /dev/null +++ b/libmamba/environment-dev.yml @@ -0,0 +1,20 @@ +name: mamba-dev +channels: + - conda-forge +dependencies: + - cxx-compiler + - cmake + - ninja + - ccache + - nlohmann_json + - libsolv >=0.7.18 + - libarchive + - libsodium + - libcurl 7.76.1 *_0 + - gtest + - gmock + - cpp-filesystem >=1.5.8 + - reproc-cpp + - yaml-cpp + - termcolor-cpp + - cli11 diff --git a/environment-static-dev.yml b/libmamba/environment-static-dev.yml similarity index 100% rename from environment-static-dev.yml rename to libmamba/environment-static-dev.yml diff --git a/include/mamba/api/c_api.h b/libmamba/include/mamba/api/c_api.h similarity index 100% rename from include/mamba/api/c_api.h rename to libmamba/include/mamba/api/c_api.h diff --git a/include/mamba/api/clean.hpp b/libmamba/include/mamba/api/clean.hpp similarity index 100% rename from include/mamba/api/clean.hpp rename to libmamba/include/mamba/api/clean.hpp diff --git a/include/mamba/api/config.hpp b/libmamba/include/mamba/api/config.hpp similarity index 100% rename from include/mamba/api/config.hpp rename to libmamba/include/mamba/api/config.hpp diff --git a/include/mamba/api/configuration.hpp b/libmamba/include/mamba/api/configuration.hpp similarity index 100% rename from include/mamba/api/configuration.hpp rename to libmamba/include/mamba/api/configuration.hpp diff --git a/include/mamba/api/constants.hpp b/libmamba/include/mamba/api/constants.hpp similarity index 100% rename from include/mamba/api/constants.hpp rename to libmamba/include/mamba/api/constants.hpp diff --git a/include/mamba/api/create.hpp b/libmamba/include/mamba/api/create.hpp similarity index 100% rename from include/mamba/api/create.hpp rename to libmamba/include/mamba/api/create.hpp diff --git a/include/mamba/api/info.hpp b/libmamba/include/mamba/api/info.hpp similarity index 100% rename from include/mamba/api/info.hpp rename to libmamba/include/mamba/api/info.hpp diff --git a/include/mamba/api/install.hpp b/libmamba/include/mamba/api/install.hpp similarity index 100% rename from include/mamba/api/install.hpp rename to libmamba/include/mamba/api/install.hpp diff --git a/include/mamba/api/list.hpp b/libmamba/include/mamba/api/list.hpp similarity index 100% rename from include/mamba/api/list.hpp rename to libmamba/include/mamba/api/list.hpp diff --git a/include/mamba/api/remove.hpp b/libmamba/include/mamba/api/remove.hpp similarity index 100% rename from include/mamba/api/remove.hpp rename to libmamba/include/mamba/api/remove.hpp diff --git a/include/mamba/api/shell.hpp b/libmamba/include/mamba/api/shell.hpp similarity index 100% rename from include/mamba/api/shell.hpp rename to libmamba/include/mamba/api/shell.hpp diff --git a/include/mamba/api/update.hpp b/libmamba/include/mamba/api/update.hpp similarity index 100% rename from include/mamba/api/update.hpp rename to libmamba/include/mamba/api/update.hpp diff --git a/include/mamba/core/activation.hpp b/libmamba/include/mamba/core/activation.hpp similarity index 100% rename from include/mamba/core/activation.hpp rename to libmamba/include/mamba/core/activation.hpp diff --git a/include/mamba/core/channel.hpp b/libmamba/include/mamba/core/channel.hpp similarity index 100% rename from include/mamba/core/channel.hpp rename to libmamba/include/mamba/core/channel.hpp diff --git a/include/mamba/core/channel_internal.hpp b/libmamba/include/mamba/core/channel_internal.hpp similarity index 100% rename from include/mamba/core/channel_internal.hpp rename to libmamba/include/mamba/core/channel_internal.hpp diff --git a/include/mamba/core/context.hpp b/libmamba/include/mamba/core/context.hpp similarity index 100% rename from include/mamba/core/context.hpp rename to libmamba/include/mamba/core/context.hpp diff --git a/include/mamba/core/environment.hpp b/libmamba/include/mamba/core/environment.hpp similarity index 100% rename from include/mamba/core/environment.hpp rename to libmamba/include/mamba/core/environment.hpp diff --git a/include/mamba/core/environments_manager.hpp b/libmamba/include/mamba/core/environments_manager.hpp similarity index 100% rename from include/mamba/core/environments_manager.hpp rename to libmamba/include/mamba/core/environments_manager.hpp diff --git a/include/mamba/core/fetch.hpp b/libmamba/include/mamba/core/fetch.hpp similarity index 100% rename from include/mamba/core/fetch.hpp rename to libmamba/include/mamba/core/fetch.hpp diff --git a/include/mamba/core/fsutil.hpp b/libmamba/include/mamba/core/fsutil.hpp similarity index 100% rename from include/mamba/core/fsutil.hpp rename to libmamba/include/mamba/core/fsutil.hpp diff --git a/include/mamba/core/graph_util.hpp b/libmamba/include/mamba/core/graph_util.hpp similarity index 100% rename from include/mamba/core/graph_util.hpp rename to libmamba/include/mamba/core/graph_util.hpp diff --git a/include/mamba/core/history.hpp b/libmamba/include/mamba/core/history.hpp similarity index 100% rename from include/mamba/core/history.hpp rename to libmamba/include/mamba/core/history.hpp diff --git a/include/mamba/core/link.hpp b/libmamba/include/mamba/core/link.hpp similarity index 100% rename from include/mamba/core/link.hpp rename to libmamba/include/mamba/core/link.hpp diff --git a/include/mamba/core/mamba_fs.hpp b/libmamba/include/mamba/core/mamba_fs.hpp similarity index 100% rename from include/mamba/core/mamba_fs.hpp rename to libmamba/include/mamba/core/mamba_fs.hpp diff --git a/include/mamba/core/match_spec.hpp b/libmamba/include/mamba/core/match_spec.hpp similarity index 100% rename from include/mamba/core/match_spec.hpp rename to libmamba/include/mamba/core/match_spec.hpp diff --git a/include/mamba/core/menuinst.hpp b/libmamba/include/mamba/core/menuinst.hpp similarity index 100% rename from include/mamba/core/menuinst.hpp rename to libmamba/include/mamba/core/menuinst.hpp diff --git a/include/mamba/core/output.hpp b/libmamba/include/mamba/core/output.hpp similarity index 100% rename from include/mamba/core/output.hpp rename to libmamba/include/mamba/core/output.hpp diff --git a/include/mamba/core/package_cache.hpp b/libmamba/include/mamba/core/package_cache.hpp similarity index 100% rename from include/mamba/core/package_cache.hpp rename to libmamba/include/mamba/core/package_cache.hpp diff --git a/include/mamba/core/package_handling.hpp b/libmamba/include/mamba/core/package_handling.hpp similarity index 100% rename from include/mamba/core/package_handling.hpp rename to libmamba/include/mamba/core/package_handling.hpp diff --git a/include/mamba/core/package_info.hpp b/libmamba/include/mamba/core/package_info.hpp similarity index 100% rename from include/mamba/core/package_info.hpp rename to libmamba/include/mamba/core/package_info.hpp diff --git a/include/mamba/core/package_paths.hpp b/libmamba/include/mamba/core/package_paths.hpp similarity index 100% rename from include/mamba/core/package_paths.hpp rename to libmamba/include/mamba/core/package_paths.hpp diff --git a/include/mamba/core/pinning.hpp b/libmamba/include/mamba/core/pinning.hpp similarity index 100% rename from include/mamba/core/pinning.hpp rename to libmamba/include/mamba/core/pinning.hpp diff --git a/include/mamba/core/pool.hpp b/libmamba/include/mamba/core/pool.hpp similarity index 100% rename from include/mamba/core/pool.hpp rename to libmamba/include/mamba/core/pool.hpp diff --git a/include/mamba/core/prefix_data.hpp b/libmamba/include/mamba/core/prefix_data.hpp similarity index 100% rename from include/mamba/core/prefix_data.hpp rename to libmamba/include/mamba/core/prefix_data.hpp diff --git a/include/mamba/core/progress_bar.hpp b/libmamba/include/mamba/core/progress_bar.hpp similarity index 100% rename from include/mamba/core/progress_bar.hpp rename to libmamba/include/mamba/core/progress_bar.hpp diff --git a/include/mamba/core/query.hpp b/libmamba/include/mamba/core/query.hpp similarity index 100% rename from include/mamba/core/query.hpp rename to libmamba/include/mamba/core/query.hpp diff --git a/include/mamba/core/repo.hpp b/libmamba/include/mamba/core/repo.hpp similarity index 100% rename from include/mamba/core/repo.hpp rename to libmamba/include/mamba/core/repo.hpp diff --git a/include/mamba/core/shell_init.hpp b/libmamba/include/mamba/core/shell_init.hpp similarity index 100% rename from include/mamba/core/shell_init.hpp rename to libmamba/include/mamba/core/shell_init.hpp diff --git a/include/mamba/core/solver.hpp b/libmamba/include/mamba/core/solver.hpp similarity index 100% rename from include/mamba/core/solver.hpp rename to libmamba/include/mamba/core/solver.hpp diff --git a/include/mamba/core/subdirdata.hpp b/libmamba/include/mamba/core/subdirdata.hpp similarity index 100% rename from include/mamba/core/subdirdata.hpp rename to libmamba/include/mamba/core/subdirdata.hpp diff --git a/include/mamba/core/thread_utils.hpp b/libmamba/include/mamba/core/thread_utils.hpp similarity index 100% rename from include/mamba/core/thread_utils.hpp rename to libmamba/include/mamba/core/thread_utils.hpp diff --git a/include/mamba/core/transaction.hpp b/libmamba/include/mamba/core/transaction.hpp similarity index 100% rename from include/mamba/core/transaction.hpp rename to libmamba/include/mamba/core/transaction.hpp diff --git a/include/mamba/core/transaction_context.hpp b/libmamba/include/mamba/core/transaction_context.hpp similarity index 100% rename from include/mamba/core/transaction_context.hpp rename to libmamba/include/mamba/core/transaction_context.hpp diff --git a/include/mamba/core/url.hpp b/libmamba/include/mamba/core/url.hpp similarity index 100% rename from include/mamba/core/url.hpp rename to libmamba/include/mamba/core/url.hpp diff --git a/include/mamba/core/util.hpp b/libmamba/include/mamba/core/util.hpp similarity index 100% rename from include/mamba/core/util.hpp rename to libmamba/include/mamba/core/util.hpp diff --git a/include/mamba/core/util_os.hpp b/libmamba/include/mamba/core/util_os.hpp similarity index 100% rename from include/mamba/core/util_os.hpp rename to libmamba/include/mamba/core/util_os.hpp diff --git a/include/mamba/core/validate.hpp b/libmamba/include/mamba/core/validate.hpp similarity index 100% rename from include/mamba/core/validate.hpp rename to libmamba/include/mamba/core/validate.hpp diff --git a/include/mamba/core/virtual_packages.hpp b/libmamba/include/mamba/core/virtual_packages.hpp similarity index 100% rename from include/mamba/core/virtual_packages.hpp rename to libmamba/include/mamba/core/virtual_packages.hpp diff --git a/libmamba/include/mamba/version.hpp b/libmamba/include/mamba/version.hpp new file mode 100644 index 0000000000..0d2db4b47b --- /dev/null +++ b/libmamba/include/mamba/version.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2019, QuantStack and Mamba Contributors +// +// Distributed under the terms of the BSD 3-Clause License. +// +// The full license is in the file LICENSE, distributed with this software. + +#ifndef LIBMAMBA_VERSION_HPP +#define LIBMAMBA_VERSION_HPP + +#include +#include + +#define LIBMAMBA_VERSION_MAJOR 0 +#define LIBMAMBA_VERSION_MINOR 17 +#define LIBMAMBA_VERSION_PATCH 0 + +// Binary version +#define LIBMAMBA_BINARY_CURRENT 1 +#define LIBMAMBA_BINARY_REVISION 0 +#define LIBMAMBA_BINARY_AGE 0 + +#define LIBMAMBA_VERSION \ + (LIBMAMBA_VERSION_MAJOR * 10000 + LIBMAMBA_VERSION_MINOR * 100 + LIBMAMBA_VERSION_PATCH) +#define LIBMAMBA_VERSION_STRING "0.17.0" + +namespace mamba +{ + std::string version(); + + std::array version_arr(); +} + +#endif diff --git a/libmamba/libmambaConfig.cmake.in b/libmamba/libmambaConfig.cmake.in new file mode 100644 index 0000000000..d12c758a3a --- /dev/null +++ b/libmamba/libmambaConfig.cmake.in @@ -0,0 +1,42 @@ +############################################################################ +# Copyright (c) 2019, QuantStack and Mamba Contributors # +# # +# Distributed under the terms of the BSD 3-Clause License. # +# # +# The full license is in the file LICENSE, distributed with this software. # +############################################################################ + +# libmamba cmake module +# This module sets the following variables in your project:: +# +# libmamba_FOUND - true if libmamba found on the system +# libmamba_INCLUDE_DIRS - the directory containing libmamba headers +# libmamba_LIBRARY - the library for dynamic linking +# libmamba_STATIC_LIBRARY - the library for static linking + +@PACKAGE_INIT@ + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR};${CMAKE_MODULE_PATH}") + +@LIBMAMBA_CONFIG_CODE@ + +include(CMakeFindDependencyMacro) +find_dependency(nlohmann_json) +find_dependency(Threads) + +if(NOT TARGET libmamba AND NOT TARGET libmamba-static) + include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + + if (TARGET libmamba AND TARGET libmamba-static) + get_target_property(@PROJECT_NAME@_INCLUDE_DIR libmamba INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(@PROJECT_NAME@_LIBRARY libmamba LOCATION) + get_target_property(@PROJECT_NAME@_STATIC_LIBRARY libmamba-static LOCATION) + elseif (TARGET libmamba) + get_target_property(@PROJECT_NAME@_INCLUDE_DIR libmamba INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(@PROJECT_NAME@_LIBRARY libmamba LOCATION) + elseif (TARGET libmamba-static) + get_target_property(@PROJECT_NAME@_INCLUDE_DIR libmamba-static INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(@PROJECT_NAME@_STATIC_LIBRARY libmamba-static LOCATION) + set(@PROJECT_NAME@_LIBRARY ${@PROJECT_NAME@_STATIC_LIBRARY}) + endif () +endif() diff --git a/src/api/c_api.cpp b/libmamba/src/api/c_api.cpp similarity index 100% rename from src/api/c_api.cpp rename to libmamba/src/api/c_api.cpp diff --git a/src/api/clean.cpp b/libmamba/src/api/clean.cpp similarity index 100% rename from src/api/clean.cpp rename to libmamba/src/api/clean.cpp diff --git a/src/api/config.cpp b/libmamba/src/api/config.cpp similarity index 100% rename from src/api/config.cpp rename to libmamba/src/api/config.cpp diff --git a/src/api/configuration.cpp b/libmamba/src/api/configuration.cpp similarity index 99% rename from src/api/configuration.cpp rename to libmamba/src/api/configuration.cpp index 8b45fea3f7..2fde06446b 100644 --- a/src/api/configuration.cpp +++ b/libmamba/src/api/configuration.cpp @@ -20,7 +20,7 @@ #include #include -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" namespace mamba diff --git a/src/api/create.cpp b/libmamba/src/api/create.cpp similarity index 100% rename from src/api/create.cpp rename to libmamba/src/api/create.cpp diff --git a/src/api/info.cpp b/libmamba/src/api/info.cpp similarity index 97% rename from src/api/info.cpp rename to libmamba/src/api/info.cpp index 6c9bcba5a0..d8adeff1b5 100644 --- a/src/api/info.cpp +++ b/libmamba/src/api/info.cpp @@ -4,6 +4,8 @@ // // The full license is in the file LICENSE, distributed with this software. +#include "mamba/version.hpp" + #include "mamba/api/configuration.hpp" #include "mamba/api/info.hpp" #include "mamba/api/install.hpp" @@ -11,7 +13,6 @@ #include "mamba/core/context.hpp" #include "mamba/core/environment.hpp" #include "mamba/core/util.hpp" -#include "mamba/core/version.hpp" #include "mamba/core/virtual_packages.hpp" @@ -32,11 +33,6 @@ namespace mamba config.operation_teardown(); } - std::string version() - { - return mamba_version; - } - std::string banner() { auto& ctx = Context::instance(); diff --git a/src/api/install.cpp b/libmamba/src/api/install.cpp similarity index 99% rename from src/api/install.cpp rename to libmamba/src/api/install.cpp index 2a9c7a899b..cbf61bcc32 100644 --- a/src/api/install.cpp +++ b/libmamba/src/api/install.cpp @@ -23,7 +23,7 @@ #include "mamba/core/util.hpp" #include "mamba/core/virtual_packages.hpp" -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" namespace mamba { diff --git a/src/api/list.cpp b/libmamba/src/api/list.cpp similarity index 100% rename from src/api/list.cpp rename to libmamba/src/api/list.cpp diff --git a/src/api/remove.cpp b/libmamba/src/api/remove.cpp similarity index 100% rename from src/api/remove.cpp rename to libmamba/src/api/remove.cpp diff --git a/src/api/shell.cpp b/libmamba/src/api/shell.cpp similarity index 100% rename from src/api/shell.cpp rename to libmamba/src/api/shell.cpp diff --git a/src/api/update.cpp b/libmamba/src/api/update.cpp similarity index 100% rename from src/api/update.cpp rename to libmamba/src/api/update.cpp diff --git a/src/core/activation.cpp b/libmamba/src/core/activation.cpp similarity index 100% rename from src/core/activation.cpp rename to libmamba/src/core/activation.cpp diff --git a/src/core/channel.cpp b/libmamba/src/core/channel.cpp similarity index 100% rename from src/core/channel.cpp rename to libmamba/src/core/channel.cpp diff --git a/src/core/context.cpp b/libmamba/src/core/context.cpp similarity index 99% rename from src/core/context.cpp rename to libmamba/src/core/context.cpp index 04f4b61b0a..3851be47c4 100644 --- a/src/core/context.cpp +++ b/libmamba/src/core/context.cpp @@ -12,7 +12,7 @@ #include "mamba/core/thread_utils.hpp" #include "mamba/core/util.hpp" -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" namespace mamba { diff --git a/src/core/environments_manager.cpp b/libmamba/src/core/environments_manager.cpp similarity index 100% rename from src/core/environments_manager.cpp rename to libmamba/src/core/environments_manager.cpp diff --git a/src/core/fetch.cpp b/libmamba/src/core/fetch.cpp similarity index 99% rename from src/core/fetch.cpp rename to libmamba/src/core/fetch.cpp index 499e0e34d0..58226a238d 100644 --- a/src/core/fetch.cpp +++ b/libmamba/src/core/fetch.cpp @@ -4,16 +4,17 @@ // // The full license is in the file LICENSE, distributed with this software. -#include -#include -#include - +#include "mamba/version.hpp" #include "mamba/core/fetch.hpp" #include "mamba/core/context.hpp" #include "mamba/core/thread_utils.hpp" #include "mamba/core/util.hpp" #include "mamba/core/url.hpp" -#include "mamba/core/version.hpp" + +#include +#include +#include + namespace mamba { @@ -30,7 +31,7 @@ namespace mamba return; } -#ifdef UMAMBA_STATIC +#ifdef MICROMAMBA_STATIC_LINK CURLsslset sslset_res; const curl_ssl_backend** available_backends; @@ -190,7 +191,7 @@ namespace mamba } else if (ssl_verify == "") { -#ifdef UMAMBA_STATIC +#ifdef MICROMAMBA_STATIC_LINK curl_easy_setopt(handle, CURLOPT_CAINFO, nullptr); #endif } @@ -229,7 +230,7 @@ namespace mamba } static std::string user_agent - = std::string("User-Agent: mamba/" MAMBA_VERSION_STRING " ") + curl_version(); + = std::string("User-Agent: mamba/" LIBMAMBA_VERSION_STRING " ") + curl_version(); m_headers = curl_slist_append(m_headers, user_agent.c_str()); curl_easy_setopt(m_handle, CURLOPT_HTTPHEADER, m_headers); diff --git a/src/core/history.cpp b/libmamba/src/core/history.cpp similarity index 100% rename from src/core/history.cpp rename to libmamba/src/core/history.cpp diff --git a/src/core/link.cpp b/libmamba/src/core/link.cpp similarity index 99% rename from src/core/link.cpp rename to libmamba/src/core/link.cpp index 15528cc67c..71b8173095 100644 --- a/src/core/link.cpp +++ b/libmamba/src/core/link.cpp @@ -9,7 +9,7 @@ #include #include -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" #include #include "mamba/core/environment.hpp" diff --git a/src/core/match_spec.cpp b/libmamba/src/core/match_spec.cpp similarity index 100% rename from src/core/match_spec.cpp rename to libmamba/src/core/match_spec.cpp diff --git a/src/core/menuinst.cpp b/libmamba/src/core/menuinst.cpp similarity index 100% rename from src/core/menuinst.cpp rename to libmamba/src/core/menuinst.cpp diff --git a/src/core/output.cpp b/libmamba/src/core/output.cpp similarity index 99% rename from src/core/output.cpp rename to libmamba/src/core/output.cpp index eb1758caef..9942ec3303 100644 --- a/src/core/output.cpp +++ b/libmamba/src/core/output.cpp @@ -15,7 +15,7 @@ #include "mamba/core/url.hpp" #include "mamba/core/util.hpp" -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" #include #include diff --git a/src/core/package_cache.cpp b/libmamba/src/core/package_cache.cpp similarity index 100% rename from src/core/package_cache.cpp rename to libmamba/src/core/package_cache.cpp diff --git a/src/core/package_handling.cpp b/libmamba/src/core/package_handling.cpp similarity index 100% rename from src/core/package_handling.cpp rename to libmamba/src/core/package_handling.cpp diff --git a/src/core/package_info.cpp b/libmamba/src/core/package_info.cpp similarity index 100% rename from src/core/package_info.cpp rename to libmamba/src/core/package_info.cpp diff --git a/src/core/package_paths.cpp b/libmamba/src/core/package_paths.cpp similarity index 100% rename from src/core/package_paths.cpp rename to libmamba/src/core/package_paths.cpp diff --git a/src/core/pinning.cpp b/libmamba/src/core/pinning.cpp similarity index 100% rename from src/core/pinning.cpp rename to libmamba/src/core/pinning.cpp diff --git a/src/core/pool.cpp b/libmamba/src/core/pool.cpp similarity index 100% rename from src/core/pool.cpp rename to libmamba/src/core/pool.cpp diff --git a/src/core/prefix_data.cpp b/libmamba/src/core/prefix_data.cpp similarity index 100% rename from src/core/prefix_data.cpp rename to libmamba/src/core/prefix_data.cpp diff --git a/src/core/progress_bar.cpp b/libmamba/src/core/progress_bar.cpp similarity index 100% rename from src/core/progress_bar.cpp rename to libmamba/src/core/progress_bar.cpp diff --git a/src/core/query.cpp b/libmamba/src/core/query.cpp similarity index 100% rename from src/core/query.cpp rename to libmamba/src/core/query.cpp diff --git a/src/core/repo.cpp b/libmamba/src/core/repo.cpp similarity index 100% rename from src/core/repo.cpp rename to libmamba/src/core/repo.cpp diff --git a/src/core/shell_init.cpp b/libmamba/src/core/shell_init.cpp similarity index 99% rename from src/core/shell_init.cpp rename to libmamba/src/core/shell_init.cpp index 980a9080ed..7250a2578e 100644 --- a/src/core/shell_init.cpp +++ b/libmamba/src/core/shell_init.cpp @@ -14,7 +14,7 @@ #include "mamba/core/environment.hpp" #include "mamba/core/virtual_packages.hpp" -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" #include diff --git a/src/core/solver.cpp b/libmamba/src/core/solver.cpp similarity index 100% rename from src/core/solver.cpp rename to libmamba/src/core/solver.cpp diff --git a/src/core/subdirdata.cpp b/libmamba/src/core/subdirdata.cpp similarity index 100% rename from src/core/subdirdata.cpp rename to libmamba/src/core/subdirdata.cpp diff --git a/src/core/thread_utils.cpp b/libmamba/src/core/thread_utils.cpp similarity index 100% rename from src/core/thread_utils.cpp rename to libmamba/src/core/thread_utils.cpp diff --git a/src/core/transaction.cpp b/libmamba/src/core/transaction.cpp similarity index 99% rename from src/core/transaction.cpp rename to libmamba/src/core/transaction.cpp index 224e13f1e7..b8ced00be9 100644 --- a/src/core/transaction.cpp +++ b/libmamba/src/core/transaction.cpp @@ -15,7 +15,7 @@ #include "mamba/core/match_spec.hpp" #include "mamba/core/thread_utils.hpp" -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" extern "C" { diff --git a/src/core/transaction_context.cpp b/libmamba/src/core/transaction_context.cpp similarity index 100% rename from src/core/transaction_context.cpp rename to libmamba/src/core/transaction_context.cpp diff --git a/src/core/url.cpp b/libmamba/src/core/url.cpp similarity index 100% rename from src/core/url.cpp rename to libmamba/src/core/url.cpp diff --git a/src/core/util.cpp b/libmamba/src/core/util.cpp similarity index 100% rename from src/core/util.cpp rename to libmamba/src/core/util.cpp diff --git a/src/core/util_os.cpp b/libmamba/src/core/util_os.cpp similarity index 99% rename from src/core/util_os.cpp rename to libmamba/src/core/util_os.cpp index 489b24206b..c762212bdc 100644 --- a/src/core/util_os.cpp +++ b/libmamba/src/core/util_os.cpp @@ -1,6 +1,6 @@ #include -#include "thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" #include "mamba/core/environment.hpp" #include "mamba/core/util_os.hpp" diff --git a/src/core/validate.cpp b/libmamba/src/core/validate.cpp similarity index 100% rename from src/core/validate.cpp rename to libmamba/src/core/validate.cpp diff --git a/src/core/virtual_packages.cpp b/libmamba/src/core/virtual_packages.cpp similarity index 100% rename from src/core/virtual_packages.cpp rename to libmamba/src/core/virtual_packages.cpp diff --git a/src/thirdparty/WinReg.hpp b/libmamba/src/thirdparty/WinReg.hpp similarity index 100% rename from src/thirdparty/WinReg.hpp rename to libmamba/src/thirdparty/WinReg.hpp diff --git a/libmamba/src/version.cpp b/libmamba/src/version.cpp new file mode 100644 index 0000000000..0693e9e352 --- /dev/null +++ b/libmamba/src/version.cpp @@ -0,0 +1,21 @@ +// Copyright (c) 2019, QuantStack and Mamba Contributors +// +// Distributed under the terms of the BSD 3-Clause License. +// +// The full license is in the file LICENSE, distributed with this software. + +#include "mamba/version.hpp" + + +namespace mamba +{ + std::string version() + { + return LIBMAMBA_VERSION_STRING; + } + + std::array version_arr() + { + return { LIBMAMBA_VERSION_MAJOR, LIBMAMBA_VERSION_MINOR, LIBMAMBA_VERSION_PATCH }; + } +} diff --git a/test/CMakeLists.txt b/libmamba/tests/CMakeLists.txt similarity index 68% rename from test/CMakeLists.txt rename to libmamba/tests/CMakeLists.txt index 63306320d0..286972f792 100644 --- a/test/CMakeLists.txt +++ b/libmamba/tests/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.1) find_package(GTest) +find_package(Threads REQUIRED) include_directories(${GTEST_INCLUDE_DIRS} SYSTEM) @@ -24,7 +25,8 @@ set(TEST_SRCS test_lockfile.cpp ) -add_executable(test_mamba ${TEST_SRCS}) +message(STATUS "Building libmamba C++ tests") +add_executable(test_libmamba ${TEST_SRCS}) file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/history_test/conda-meta/history DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/history_test/conda-meta/) @@ -39,13 +41,12 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/env_file_test file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/validation_data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) -target_link_libraries(test_mamba PRIVATE GTest::GTest GTest::Main ${CMAKE_THREAD_LIBS_INIT}) -target_link_libraries(test_mamba PUBLIC mamba-static) -set_property(TARGET test_mamba PROPERTY CXX_STANDARD 17) +target_link_libraries(test_libmamba PRIVATE GTest::GTest GTest::Main Threads::Threads) +target_link_libraries(test_libmamba PUBLIC libmamba-static) +set_property(TARGET test_libmamba PROPERTY CXX_STANDARD 17) -add_custom_target(test COMMAND test_mamba DEPENDS test_mamba) +add_custom_target(test COMMAND test_libmamba DEPENDS test_libmamba) -add_executable(test_mamba_lock testing/lock.cpp) -target_link_libraries(test_mamba_lock PRIVATE GTest::GTest GTest::Main ${CMAKE_THREAD_LIBS_INIT}) -target_link_libraries(test_mamba_lock PUBLIC mamba-static) -set_property(TARGET test_mamba_lock PROPERTY CXX_STANDARD 17) +add_executable(testing_libmamba_lock testing/lock.cpp) +target_link_libraries(testing_libmamba_lock PUBLIC libmamba-static) +set_property(TARGET testing_libmamba_lock PROPERTY CXX_STANDARD 17) diff --git a/test/config_test/.condarc b/libmamba/tests/config_test/.condarc similarity index 100% rename from test/config_test/.condarc rename to libmamba/tests/config_test/.condarc diff --git a/test/env_file_test/env_1.yaml b/libmamba/tests/env_file_test/env_1.yaml similarity index 100% rename from test/env_file_test/env_1.yaml rename to libmamba/tests/env_file_test/env_1.yaml diff --git a/test/env_file_test/env_2.yaml b/libmamba/tests/env_file_test/env_2.yaml similarity index 100% rename from test/env_file_test/env_2.yaml rename to libmamba/tests/env_file_test/env_2.yaml diff --git a/test/env_file_test/env_3.yaml b/libmamba/tests/env_file_test/env_3.yaml similarity index 100% rename from test/env_file_test/env_3.yaml rename to libmamba/tests/env_file_test/env_3.yaml diff --git a/test/history_test/conda-meta/aux_file b/libmamba/tests/history_test/conda-meta/aux_file similarity index 100% rename from test/history_test/conda-meta/aux_file rename to libmamba/tests/history_test/conda-meta/aux_file diff --git a/test/history_test/conda-meta/history b/libmamba/tests/history_test/conda-meta/history similarity index 100% rename from test/history_test/conda-meta/history rename to libmamba/tests/history_test/conda-meta/history diff --git a/test/history_test/test_history.cpp b/libmamba/tests/history_test/test_history.cpp similarity index 100% rename from test/history_test/test_history.cpp rename to libmamba/tests/history_test/test_history.cpp diff --git a/test/test_activation.cpp b/libmamba/tests/test_activation.cpp similarity index 100% rename from test/test_activation.cpp rename to libmamba/tests/test_activation.cpp diff --git a/test/test_channel.cpp b/libmamba/tests/test_channel.cpp similarity index 100% rename from test/test_channel.cpp rename to libmamba/tests/test_channel.cpp diff --git a/test/test_configuration.cpp b/libmamba/tests/test_configuration.cpp similarity index 100% rename from test/test_configuration.cpp rename to libmamba/tests/test_configuration.cpp diff --git a/test/test_cpp.cpp b/libmamba/tests/test_cpp.cpp similarity index 100% rename from test/test_cpp.cpp rename to libmamba/tests/test_cpp.cpp diff --git a/test/test_env_file_reading.cpp b/libmamba/tests/test_env_file_reading.cpp similarity index 100% rename from test/test_env_file_reading.cpp rename to libmamba/tests/test_env_file_reading.cpp diff --git a/test/test_environments_manager.cpp b/libmamba/tests/test_environments_manager.cpp similarity index 100% rename from test/test_environments_manager.cpp rename to libmamba/tests/test_environments_manager.cpp diff --git a/test/test_graph.cpp b/libmamba/tests/test_graph.cpp similarity index 100% rename from test/test_graph.cpp rename to libmamba/tests/test_graph.cpp diff --git a/test/test_lockfile.cpp b/libmamba/tests/test_lockfile.cpp similarity index 97% rename from test/test_lockfile.cpp rename to libmamba/tests/test_lockfile.cpp index 0a218f2cce..1d62180996 100644 --- a/test/test_lockfile.cpp +++ b/libmamba/tests/test_lockfile.cpp @@ -72,9 +72,9 @@ namespace mamba std::vector args; #ifdef _WIN32 - lock_cli = "test_mamba_lock"; + lock_cli = "testing_libmamba_lock"; #else - lock_cli = "./test_mamba_lock"; + lock_cli = "./testing_libmamba_lock"; #endif { @@ -189,9 +189,9 @@ namespace mamba std::vector args; #ifdef _WIN32 - lock_cli = "test_mamba_lock"; + lock_cli = "testing_libmamba_lock"; #else - lock_cli = "./test_mamba_lock"; + lock_cli = "./testing_libmamba_lock"; #endif { // Create a lock diff --git a/test/test_pinning.cpp b/libmamba/tests/test_pinning.cpp similarity index 100% rename from test/test_pinning.cpp rename to libmamba/tests/test_pinning.cpp diff --git a/test/test_repoquery.py b/libmamba/tests/test_repoquery.py similarity index 100% rename from test/test_repoquery.py rename to libmamba/tests/test_repoquery.py diff --git a/test/test_shell_init.cpp b/libmamba/tests/test_shell_init.cpp similarity index 100% rename from test/test_shell_init.cpp rename to libmamba/tests/test_shell_init.cpp diff --git a/test/test_string_methods.cpp b/libmamba/tests/test_string_methods.cpp similarity index 100% rename from test/test_string_methods.cpp rename to libmamba/tests/test_string_methods.cpp diff --git a/test/test_thread_utils.cpp b/libmamba/tests/test_thread_utils.cpp similarity index 100% rename from test/test_thread_utils.cpp rename to libmamba/tests/test_thread_utils.cpp diff --git a/test/test_transfer.cpp b/libmamba/tests/test_transfer.cpp similarity index 100% rename from test/test_transfer.cpp rename to libmamba/tests/test_transfer.cpp diff --git a/test/test_url.cpp b/libmamba/tests/test_url.cpp similarity index 100% rename from test/test_url.cpp rename to libmamba/tests/test_url.cpp diff --git a/test/test_validate.cpp b/libmamba/tests/test_validate.cpp similarity index 100% rename from test/test_validate.cpp rename to libmamba/tests/test_validate.cpp diff --git a/test/test_virtual_packages.cpp b/libmamba/tests/test_virtual_packages.cpp similarity index 100% rename from test/test_virtual_packages.cpp rename to libmamba/tests/test_virtual_packages.cpp diff --git a/test/testing/lock.cpp b/libmamba/tests/testing/lock.cpp similarity index 100% rename from test/testing/lock.cpp rename to libmamba/tests/testing/lock.cpp diff --git a/test/validation_data/1.sv0.6.root.json b/libmamba/tests/validation_data/1.sv0.6.root.json similarity index 100% rename from test/validation_data/1.sv0.6.root.json rename to libmamba/tests/validation_data/1.sv0.6.root.json diff --git a/libmamba/tests/validation_data/root copy.json b/libmamba/tests/validation_data/root copy.json new file mode 100644 index 0000000000..dba2e03df2 --- /dev/null +++ b/libmamba/tests/validation_data/root copy.json @@ -0,0 +1,19 @@ +{ + "signatures": [ + { + "keyid": "foo", + "sig": "..." + } + ], + "signed": { + "_type": "root", + "roles": { + "root": { + "keyids": [ + "foo" + ], + "threshold": 1 + } + } + } +} diff --git a/test/validation_data/root.json b/libmamba/tests/validation_data/root.json similarity index 100% rename from test/validation_data/root.json rename to libmamba/tests/validation_data/root.json diff --git a/libmambapy/.gitignore b/libmambapy/.gitignore new file mode 100644 index 0000000000..635f00a072 --- /dev/null +++ b/libmambapy/.gitignore @@ -0,0 +1,2 @@ +libmambapy/bindings* +libmambapy.egg-info/ diff --git a/libmambapy/CHANGELOG.md b/libmambapy/CHANGELOG.md new file mode 100644 index 0000000000..bebd2d5d72 --- /dev/null +++ b/libmambapy/CHANGELOG.md @@ -0,0 +1,526 @@ +0.17.0 (October 13, 2021) +========================= + +API Breaking changes: + +The Transaction and the Subdir interface have slightly changed (no more explicit setting of the writable +packages dir is necessary, this value is taken directly from the MultiPackagesCache now) + +- improve listing of (RC-) configurable values in `micromamba` #1210 (thanks @adriendelsalle) +- Improve micromamba lockfiles and add many tests #1193 (thanks @adriendelsalle) +- Support multiple package caches in micromamba (thanks @adriendelsalle) #1109 +- Order explicit envs in micromamba (also added some text to the docs about libsolv transactions) #1198 +- Add `micromamba package` subcommand to extract, create and transmute packages #1187 +- Improve micromamba configuration to support multi-stage loading of RC files (thanks @adriendelsalle) #1189 #1190 #1191 #1188 +- Add handling of `CONDA_SAFETY_CHECKS` to micromamba #1143 (thanks @isuruf) +- Improve mamba messaging by adding a space #1186 (thanks @wkusnierczyk) +- Add support for `custom_multichannels` #1142 +- micromamba: expose setting for `add_pip_as_python_dependency` #1203 +- stop displaying banner when running `mamba list` #1184 (thanks @madhur-thandon) + +0.16.0 (September 27, 2021) +=========================== + +- Add a User-Agent header to all requests (mamba/0.16.0) (thanks @shankerwangmiao) +- Add `micromamba env export (--explicit)` to micromamba +- Do not display banner with `mamba list` (thanks @madhur-tandon) +- Use directory of environment.yml as cwd when creating environment (thanks @marscher & @adriendelsalle) +- Improve outputs +- content-trust: Add Python bindings for content-trust API +- content-trust: Load PkgMgr definitions from file +- content-trust: Improve HEAD request fallback handling +- export Transaction.find_python_version to Python +- Continue `shell init` when we can't create the prefix script dir (thanks @maresb) +- Implement support for `fish` shell in `micromamba` (thanks @soraxas) +- Add constraint with pin when updating +- Expose methods for virtual packages to Python (thanks @madhur-tandon) + +0.15.3 (August 18, 2021) +======================== + +- change token regex to work with edge-cases (underscores in user name) (#1122) +- only pin major.minor version of python for update --all (#1101, thanks @mparry!) +- add mamba init to the activate message (#1124, thanks @isuruf) +- hide tokens in logs (#1121) +- add lockfiles for repodata and pkgs download (#1105, thanks @jaimergp) +- log actual SHA256/MD5/file size when failing to avlidate (#1095, thanks @johnhany97) +- Add mamba.bat in front of PATH (#1112, thanks @isuruf) +- Fix mamba not writable cache errors (#1108) + +0.15.2 (July 16, 2021) +====================== + +- micromamba autocomplete now ready for usage (#1091) +- improved file:// urls for windows to properly work (#1090) + +0.15.1 (July 15, 2021) +====================== + +New features: +- add `mamba init` command and add mamba.sh (#1075, thanks @isuruf & #1078) +- add flexible channel priority option in micromamba CLI (#1087) +- improved autocompletion for micromamba (#1079) + +Bug fixes: +- improve "file://" URL handling, fix local channel on Windows (#1085) +- fix CONDA_SUBDIR not being used in mamba (#1084) +- pass in channel_alias and custom_channels from conda to mamba (#1081) + +0.15.0 (July 9, 2021) +===================== + +Big changes: +- improve solutions by inspecting dependency versions as well (libsolv PR: + https://github.com/openSUSE/libsolv/pull/457) @wolfv +- properly implement strict channel priority (libsolv PR: + https://github.com/openSUSE/libsolv/pull/459) @adriendelsalle + + Note that this changes the meaning of strict and flexible priority as the + previous implementation did not follow conda's semantics. Mamba now has + three modes, just like conda: strict, flexible and disabled. Strict will + completely disregard any packages from lower-priority channels if a + package of the same name exists in a higher priority channel. Flexible + will use packages from lower-priority channels if necessary to fulfill + dependencies or explicitly requested (e.g. by version number). Disabled + will use the highest version number, irregardless of the channel order. +- allow subdir selection as part of the channel: users can now specify an + explicit list of subdirs, for example: + + `-c mychannel[linux-static64, linux-64, noarch]` + + to pull in repodata and packages from these three subdirs. + Thanks for the contribution, @afranchuk! #1033 + +New features +- remove orphaned packages such as dependencies of explicitely installed + packages (@adriendelsalle) #1040 +- add a diff character before package name in transaction table to improve + readability without coloration (@adriendelsalle) #1040 +- add capability to freeze installed packages during `install` operation using + `--freeze-installed` flag (@adriendelsalle) #1048 +- Hide tokens and basic http auth secrets in log messages (#1061) +- Parse and use explicit platform specifications (thanks @afranchuk) (#1033) +- add pretty print to repoquery search (thanks @madhur-tandon) (#1018) +- add docs for package resolution + +Bug fixes: +- Fix small output issues (#1060) +- More descriptive incorrect download error (thanks @AntoinePrv) #1066 +- respect channel specific pins when updating (#1045) +- keep track features in PackageInfo class (#1046) + + +0.14.1 (June 25, 2021) +====================== + +New features +- [micromamba] add remove command, to remove keys of vectors (@marimeireles) + #1011 + +Bug fixes +- [micromamba] fixed in config prepend and append sequence (@adriendelsalle) + #1023 +- fix bug when username has @ (@madhur-tandon) #1025 +- fix wrong update spec in history (@madhur-tandon) #1028 +- [mamba] silent pinned packages using JSON output (@adriendelsalle) #1031 + +0.14.0 (June 16, 2021) +====================== + +New features +- [micromamba] add `config set`, `get`, `append` and `prepend`, `remove` + (@marimeireles) #838 +- automatically include `pip` in conda dependencies when having pip packages to + install (@madhur-tandon) #973 +- add experimental support for artifacts verification (@adriendelsalle) + #954,#955,#956,#963,#965,#970,#972,#978 +- [micromamba] shell init will try attempt to enable long paths support on + Windows (@wolfv) #975 +- [micromamba] if `menuinst` json files are present, micromamba will create + shortcuts in the start menu on Windows (@wolfv) #975 +- Improve python auto-pinning and add --no-py-pin flag to micromamba + (@adriendelsalle) #1010 +- [micromamba] Fix constructor invalid repodata_record (@adriendelsalle) #1007 +- Refactor log levels for linking steps (@adriendelsalle) #1009 +- [micromamba] Use a proper requirements.txt file for pip installations #1008 + +Bug fixes +- fix double-print int transaction (@JohanMabille) #952 +- fix strip function (@wolfv) #974 +- [micromamba] expand home directory in `--rc-file` (@adriendelsalle) #979 +- [micromamba] add yes and no as additional ways of answering a prompt + (@ibebrett) #989 +- fix long paths support on Windows (@adriendelsalle) #994 + +General improvement +- remove duplicate snippet (@madhur-tandon) #957 +- add `trace` log level (@adriendelsalle) #988 + +Docs +- concepts, user guide, configuration, update installation and build locally + (@adriendelsalle) #953 +- advance usage section, linking (@adriendelsalle) #998 +- repo, channel, subdir, repodata, tarball (@adriendelsalle) #1004 +- artifacts verification (@adriendelsalle) #1000 + +0.13.1 (May 17, 2021) +===================== + +Bug fixes +- [micromamba] pin only minor python version #948 +- [micromamba] use openssl certs when not linking statically #949 + +0.13.0 (May 12, 2021) +===================== + +New features +- [mamba & micromamba] aggregated progress bar for package downloading and + extraction (thanks @JohanMabille) #928 + +Bug fixes +- [micromamba] fixes for micromamba usage in constructor #935 +- [micromamba] fixes for the usage of lock files #936 +- [micromamba] switched from libsodium to openssl for ed25519 signature + verification #933 + +Docs +- Mention mambaforge in the README (thanks @s-pike) #932 + +0.12.3 (May 10, 2021) +===================== + +New features +- [libmamba] add free-function to use an existing conda root prefix + (@adriendelsalle) #927 + +General improvements +- [micromamba] fix a typo in documentation (@cjber) #926 + +0.12.2 (May 03, 2021) +===================== + +New features +- [micromamba] add initial framework for TUF validation (@adriendelsalle) #916 + #919 +- [micromamba] add channels from specs to download (@wolfv) #918 + +0.12.1 (Apr 30, 2021) +===================== + +New features +- [micromamba] env list subcommand (@wolfv) #913 + +Bug fixes +- [micromamba] fix multiple shell init with cmd.exe (@adriendelsalle) #915 +- [micromamba] fix activate with --stack option (@wolfv) #914 +- [libmamba] only try loading ssl certificates when needed (@adriendelsalle) + #910 +- [micromamba] remove target_prefix checks when activating (@adriendelsalle) + #909 +- [micromamba] allow 'ultra-dry' config checks in final build (@adriendelsalle) + #912 + +0.12.0 (Apr 26, 2021) +===================== + +New features +- [libmamba] add experimental shell autocompletion (@wolfv) #900 +- [libmamba] add token handling (@wolfv) #886 +- [libmamba] add experimental pip support in spec files (@wolfv) #885 + +Bug fixes +- [libmamba] ignore failing pyc compilation for noarch packages (@wolfv) #904 + #905 +- [libmamba] fix string wrapping in error message (@bdice) #902 +- [libmamba] fix cache error during remove operation (@adriendelsalle) #901 +- [libmamba] add constraint with pinning during update operation (@wolfv) #892 +- [libmamba] fix shell activate prefix check (@ashwinvis) #889 +- [libmamba] make prefix mandatory for shell init (@adriendelsalle) #896 +- [mamba] fix `env update` command (@ScottWales) #891 + +General improvements +- [libmamba] use lockfile, fix channel not loaded logic (@wolfv) #903 +- [libmamba] make root_prefix warnings more selective (@adriendelsalle) #899 +- [libmamba] house-keeping in python tests (@adriendelsalle) #898 +- [libmamba] modify mamba/micromamba specific guards (@adriendelsalle) #895 +- [libmamba] add simple lockfile mechanism (@wolfv) #894 +- [libmamba] deactivate ca-certificates search when using offline mode + (@adriendelsalle) #893 + +0.11.3 (Apr 21, 2021) +==================== + +- [libmamba] make platform rc configurable #883 +- [libmamba] expand user home in target and root prefixes #882 +- [libmamba] avoid memory effect between operations on target_prefix #881 +- [libmamba] fix unnecessary throwing target_prefix check in `clean` operation + #880 +- [micromamba] fix `clean` flags handling #880 +- [libmamba] C-API teardown on error #879 + +0.11.2 (Apr 21, 2021) +==================== + +- [libmamba] create "base" env only for install operation #875 +- [libmamba] remove confirmation prompt of root_prefix in shell init #874 +- [libmamba] improve overrides between target_prefix and env_name #873 +- [micromamba] fix use of `-p,--prefix` and spec file env name #873 + +0.11.1 (Apr 20, 2021) +==================== + +- [libmamba] fix channel_priority computation #872 + +0.11.0 (Apr 20, 2021) +==================== + +- [libmamba] add experimental mode that unlock edge features #858 +- [micromamba] add `--experimental` umamba flag to enable experimental mode + #858 +- [libmamba] improve base env creation #860 +- [libmamba] fix computation of weakly canonical target prefix #859 +- update libsolv dependency in env-dev.yml file, update documentation (thanks + @Aratz) #843 +- [libmamba] handle package cache in secondary locations, fix symlink errors + (thanks wenjuno) #856 +- [libmamba] fix CI cURL SSL error on macos with Darwin backend (thanks @wolfv) + #865 +- [libmamba] improve error handling in C-API by catching and returning an error + code #862 +- [libmamba] handle configuration lifetime (single operation configs) #863 +- [libmamba] enable ultra-dry C++ tests #868 +- [libmamba] migrate `config` operation implem from `micromamba` to `libmamba` + API #866 +- [libmamba] add capapbility to set CLI config from C-API #867 + +0.10.0 (Apr 16, 2021) +==================== + +- [micromamba] allow creation of empty env (without specs) #824 #827 +- [micromamba] automatically create empy `base` env at new root prefix #836 +- [micromamba] add remove all CLI flags `-a,--all` #824 +- [micromamba] add dry-run and ultra-dry-run tests to increase coverage and + speed-up CI #813 #845 +- [micromamba] allow CLI to override spec file env name (create, install and + update) #816 +- [libmamba] split low-level and high-level API #821 #824 +- [libmamba] add a C high-level API #826 +- [micromamba] support `__linux` virtual package #829 +- [micromamba] improve the display of solver problems #822 +- [micromamba] improve info sub-command with target prefix status (active, not + found, etc.) #825 +- [mamba] Change pybind11 to a build dependency (thanks @maresb) #846 +- [micromamba] add shell detection for shell sub-command #839 +- [micromamba] expand user in shell prefix sub-command #831 +- [micromamba] refactor explicit specs install #824 +- [libmamba] improve configuration (refactor API, create a loading sequence) + #840 +- [libmamba] support cpp-filesystem breaking changes on Windows fs #849 +- [libmamba] add a simple context debugging (thanks @wolf) #820 +- [libmamba] improve C++ test suite #830 +- fix CI C++ tests (unix/libmamba) and Python tests (win/mamba) wrongly + successful #853 + +0.9.2 (Apr 1, 2021) +==================== + +- [micromamba] fix unc url support (thanks @adament) +- [micromamba] add --channel-alias as cli option to micromamba (thanks + @adriendelsalle) +- [micromamba] fix --no-rc and environment yaml files (thanks @adriendelsalle) +- [micromamba] handle spec files in update and install subcommands (thanks + @adriendelsalle) +- add simple context debugging, dry run tests and other test framework + improvements + +0.9.1 (Mar 26, 2021) +==================== + +- [micromamba] fix remove command target_prefix selection +- [micromamba] improve target_prefix fallback for CLI, add tests (thanks + @adriendelsalle) + +0.9.0 (Mar 25, 2021) +==================== + +- [micromamba] use strict channels priority by default +- [micromamba] change config precedence order: API>CLI>ENV>RC +- [micromamba] `config list` sub command optional display of sources, defaults, + short/long descriptions and groups +- [micromamba] prevent crashes when no bashrc or zshrc file found (thanks + @wolfv) +- add support for UNC file:// urls (thanks @adament) +- add support for use_only_tar_bz2 (thanks @tl-hbk @wolfv) +- add pinned specs for env update (thanks @wolfv) +- properly adhere to run_constrains (thanks @wolfv) + +0.8.2 (Mar 12, 2021) +==================== + +- [micromamba] fix setting network options before explicit spec installation +- [micromamba] fix python based tests for windows + + +0.8.1 (Mar 11, 2021) +==================== + +- use stoull (instead of stoi) to prevent overflow with long package build + numbers (thanks @pbauwens-kbc) +- [micromamba] fixing OS X certificate search path +- [micromamba] refactor default root prefix, make it configurable from CLI + (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible (thanks + @adriendelsalle) +- [micromamba] sort json transaction, and add UNLINK field +- [micromamba] left align log messages +- [micromamba] libsolv log messages to stderr (thanks @mariusvniekerk) +- [micromamba] better curl error messages + + +0.8.0 (Mar 5, 2021) +=================== + +- [micromamba] condarc and mambarc config file reading (and config subcommand) + (thanks @adriendelsalle) +- [micromamba] support for virtual packages (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible +- [micromamba] add python based testing framework for CLI +- [micromamba] refactor CLI and micromamba main file (thanks @adriendelsalle) +- [micromamba] add linking options (--always-copy etc.) (thanks + @adriendelsalle) +- [micromamba] fix multiple prefix replacements in binary files +- [micromamba] fix micromamba clean (thanks @phue) +- [micromamba] change package validation settings to --safety-checks and + --extra-safety-checks +- [micromamba] add update subcommand (thanks @adriendelsalle) +- [micromamba] support pinning packages (including python minor version) + (thanks @adriendelsalle) +- [micromamba] add try/catch to WinReg getStringValue (thanks @SvenAdler) +- [micromamba] add ssl-no-revoke option for more conda-compatibility (thanks + @tl-hbk) +- [micromamba] die when no ssl certificates are found (thanks @wholtz) +- [docs] add explanation for base env install (thanks @ralexx) and rename + changelog to .md (thanks @kevinheavey) +- [micromamba] compare cleaned URLs for cache invalidation +- [micromamba] add regex handling to list command + + +0.7.14 (Feb 12, 2021) +===================== + +- [micromamba] better validation of extracted directories +- [mamba] add additional tests for authentication and simple repodata server +- make LOG_WARN the default log level, and move some logs to INFO +- [micromamba] properly replace long shebangs when linking +- [micromamba] add quote for shell for prefixes with spaces +- [micromamba] add clean functionality +- [micromamba] always make target prefix path absolute + + +0.7.13 (Feb 4, 2021) +==================== + +- [micromamba] Immediately exit after printing version (again) + +0.7.12 (Feb 3, 2021) +==================== + +- [micromamba] Improve CTRL+C signal handling behavior and simplify code +- [micromamba] Revert extraction to temporary directory because of invalid + cross-device links on Linux +- [micromamba] Clean up partially extracted archives when CTRL+C interruption + occured + +0.7.11 (Feb 2, 2021) +==================== + +- [micromamba] use wrapped call when compiling noarch Python code, which + properly calls chcp for Windows +- [micromamba] improve checking the pkgs cache +- [mamba] fix authenticated URLs (thanks @wenjuno) +- first extract to temporary directory, then move to final pkgs cache to + prevent corrupted extracted data + +0.7.10 (Jan 22, 2021) +==================== + +- [micromamba] properly fix PATH when linking, prevents missing + vcruntime140.dll +- [mamba] add virtual packages when creating any environment, not just on + update (thanks @cbalioglu) + +0.7.9 (Jan 19, 2021) +==================== + +- [micromamba] fix PATH when linking + +0.7.8 (Jan 14, 2021) +==================== + +- [micromamba] retry on corrupted repodata +- [mamba & micromamba] fix error handling when writing repodata + +0.7.6 (Dec 22, 2020) +==================== + +- [micromamba] more console flushing for std::cout consumers + +0.7.6 (Dec 14, 2020) +==================== + +- [mamba] more arguments for repodata.create_pool + +0.7.5 (Dec 10, 2020) +==================== + +- [micromamba] better error handling for YAML file reading, allows to pass in + `-n` and `-p` from command line +- [mamba & micromamba] ignore case of HTTP headers +- [mamba] fix channel keys are without tokens (thanks @s22chan) + +0.7.4 (Dec 5, 2020) +==================== + +- [micromamba] fix noarch installation for explicit environments + +0.7.3 (Nov 20, 2020) +==================== + +- [micromamba] fix installation of noarch files with long prefixes +- [micromamba] fix activation on windows with whitespaces in root prefix + (thanks @adriendelsalle) +- [micromamba] add `--json` output to micromamba list + +0.7.2 (Nov 18, 2020) +==================== + +- [micromamba] explicit specs installing should be better now + - empty lines are ignored + - network settings are correctly set to make ssl verification work +- New Python repoquery API for mamba +- Fix symlink packing for mamba package creation and transmute +- Do not keep tempfiles around + +0.7.1 (Nov 16, 2020) +==================== + +- Handle LIBARCHIVE_WARN to not error, instead print warning (thanks @obilaniu) + +0.7.0 (Nov 12, 2020) +==================== + +- Improve activation and deactivation logic for micromamba +- Switching `subprocess` implementation to more tested `reproc++` +- Fixing Windows noarch entrypoints generation with micromamba +- Fix pre-/post-link script running with micromamba to use micromamba + activation logic +- Empty environment creation skips all repodata downloading & solving +- Fix micromamba install when environment is activated (thanks @isuruf) +- Micromamba now respects the $CONDA_SUBDIR environment variable (thanks + @mariusvniekerk) +- Fix compile time warning (thanks @obilaniu) +- Fixed wrong CondaValueError import statement in mamba.py (thanks @saraedum) + +0.6.5 (Oct 2020) +================ + +- Fix code signing for Apple Silicon (osx-arm64) @isuruf diff --git a/libmambapy/CMakeLists.txt b/libmambapy/CMakeLists.txt new file mode 100644 index 0000000000..333a1ba5cb --- /dev/null +++ b/libmambapy/CMakeLists.txt @@ -0,0 +1,12 @@ +find_package(pybind11 REQUIRED) + +include(GNUInstallDirs) + +pybind11_add_module(bindings + src/main.cpp +) +target_link_libraries(bindings PUBLIC pybind11::pybind11 libmamba-static) +set_property(TARGET bindings PROPERTY CXX_STANDARD 17) + +install(TARGETS bindings + LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/libmambapy/) diff --git a/libmambapy/LICENSE b/libmambapy/LICENSE new file mode 100644 index 0000000000..8ae98f9375 --- /dev/null +++ b/libmambapy/LICENSE @@ -0,0 +1,11 @@ +Copyright 2019 QuantStack and the Mamba contributors. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libmambapy/MANIFEST.in b/libmambapy/MANIFEST.in new file mode 100644 index 0000000000..6cf71aa0a0 --- /dev/null +++ b/libmambapy/MANIFEST.in @@ -0,0 +1,2 @@ +include libmambapy/bindings* +exclude src/ diff --git a/libmambapy/environment-dev.yml b/libmambapy/environment-dev.yml new file mode 100644 index 0000000000..8937524a81 --- /dev/null +++ b/libmambapy/environment-dev.yml @@ -0,0 +1,22 @@ +name: mamba-dev +channels: + - conda-forge +dependencies: + - cxx-compiler + - cmake + - ninja + - ccache + - nlohmann_json + - libsolv >=0.7.18 + - libarchive + - libsodium + - libcurl 7.76.1 *_0 + - gtest + - gmock + - cpp-filesystem >=1.5.8 + - reproc-cpp + - yaml-cpp + - termcolor-cpp + - cli11 + - pybind11 + - pytest diff --git a/libmambapy/libmambapy/__init__.py b/libmambapy/libmambapy/__init__.py new file mode 100644 index 0000000000..7a1b17e35c --- /dev/null +++ b/libmambapy/libmambapy/__init__.py @@ -0,0 +1 @@ +from libmambapy.bindings import * # noqa: F401,F403 diff --git a/mamba/_version.py b/libmambapy/libmambapy/_version.py similarity index 100% rename from mamba/_version.py rename to libmambapy/libmambapy/_version.py diff --git a/libmambapy/setup.cfg b/libmambapy/setup.cfg new file mode 100644 index 0000000000..e01d68411c --- /dev/null +++ b/libmambapy/setup.cfg @@ -0,0 +1,23 @@ +[metadata] +name = libmambapy +version = attr: libmambapy._version.__version__ +description = Python bindings of libmamba +long_description = Python bindings of libmamba, C++ reimplementation of conda +long_description_content_type = text/markdown +license_file = LICENSE +author = QuantStack +author_email = info@quantstack.net +url = https://github.com/mamba-org/mamba +platforms = Windows, Linux, Mac OS X +keywords = mamba, libmamba, conda + +[bdist_wheel] +universal = 1 + +[options] +include_package_data = True +packages = find: +python_requires = >=3.7 + +install_requires = + libmamba diff --git a/libmambapy/setup.py b/libmambapy/setup.py new file mode 100644 index 0000000000..b908cbe55c --- /dev/null +++ b/libmambapy/setup.py @@ -0,0 +1,3 @@ +import setuptools + +setuptools.setup() diff --git a/src/mamba/py_interface.cpp b/libmambapy/src/main.cpp similarity index 99% rename from src/mamba/py_interface.cpp rename to libmambapy/src/main.cpp index e94f137c2b..7c25ee213c 100644 --- a/src/mamba/py_interface.cpp +++ b/libmambapy/src/main.cpp @@ -40,7 +40,7 @@ namespace query }; } -PYBIND11_MODULE(mamba_api, m) +PYBIND11_MODULE(bindings, m) { using namespace mamba; diff --git a/mamba/CHANGELOG.md b/mamba/CHANGELOG.md new file mode 100644 index 0000000000..bebd2d5d72 --- /dev/null +++ b/mamba/CHANGELOG.md @@ -0,0 +1,526 @@ +0.17.0 (October 13, 2021) +========================= + +API Breaking changes: + +The Transaction and the Subdir interface have slightly changed (no more explicit setting of the writable +packages dir is necessary, this value is taken directly from the MultiPackagesCache now) + +- improve listing of (RC-) configurable values in `micromamba` #1210 (thanks @adriendelsalle) +- Improve micromamba lockfiles and add many tests #1193 (thanks @adriendelsalle) +- Support multiple package caches in micromamba (thanks @adriendelsalle) #1109 +- Order explicit envs in micromamba (also added some text to the docs about libsolv transactions) #1198 +- Add `micromamba package` subcommand to extract, create and transmute packages #1187 +- Improve micromamba configuration to support multi-stage loading of RC files (thanks @adriendelsalle) #1189 #1190 #1191 #1188 +- Add handling of `CONDA_SAFETY_CHECKS` to micromamba #1143 (thanks @isuruf) +- Improve mamba messaging by adding a space #1186 (thanks @wkusnierczyk) +- Add support for `custom_multichannels` #1142 +- micromamba: expose setting for `add_pip_as_python_dependency` #1203 +- stop displaying banner when running `mamba list` #1184 (thanks @madhur-thandon) + +0.16.0 (September 27, 2021) +=========================== + +- Add a User-Agent header to all requests (mamba/0.16.0) (thanks @shankerwangmiao) +- Add `micromamba env export (--explicit)` to micromamba +- Do not display banner with `mamba list` (thanks @madhur-tandon) +- Use directory of environment.yml as cwd when creating environment (thanks @marscher & @adriendelsalle) +- Improve outputs +- content-trust: Add Python bindings for content-trust API +- content-trust: Load PkgMgr definitions from file +- content-trust: Improve HEAD request fallback handling +- export Transaction.find_python_version to Python +- Continue `shell init` when we can't create the prefix script dir (thanks @maresb) +- Implement support for `fish` shell in `micromamba` (thanks @soraxas) +- Add constraint with pin when updating +- Expose methods for virtual packages to Python (thanks @madhur-tandon) + +0.15.3 (August 18, 2021) +======================== + +- change token regex to work with edge-cases (underscores in user name) (#1122) +- only pin major.minor version of python for update --all (#1101, thanks @mparry!) +- add mamba init to the activate message (#1124, thanks @isuruf) +- hide tokens in logs (#1121) +- add lockfiles for repodata and pkgs download (#1105, thanks @jaimergp) +- log actual SHA256/MD5/file size when failing to avlidate (#1095, thanks @johnhany97) +- Add mamba.bat in front of PATH (#1112, thanks @isuruf) +- Fix mamba not writable cache errors (#1108) + +0.15.2 (July 16, 2021) +====================== + +- micromamba autocomplete now ready for usage (#1091) +- improved file:// urls for windows to properly work (#1090) + +0.15.1 (July 15, 2021) +====================== + +New features: +- add `mamba init` command and add mamba.sh (#1075, thanks @isuruf & #1078) +- add flexible channel priority option in micromamba CLI (#1087) +- improved autocompletion for micromamba (#1079) + +Bug fixes: +- improve "file://" URL handling, fix local channel on Windows (#1085) +- fix CONDA_SUBDIR not being used in mamba (#1084) +- pass in channel_alias and custom_channels from conda to mamba (#1081) + +0.15.0 (July 9, 2021) +===================== + +Big changes: +- improve solutions by inspecting dependency versions as well (libsolv PR: + https://github.com/openSUSE/libsolv/pull/457) @wolfv +- properly implement strict channel priority (libsolv PR: + https://github.com/openSUSE/libsolv/pull/459) @adriendelsalle + + Note that this changes the meaning of strict and flexible priority as the + previous implementation did not follow conda's semantics. Mamba now has + three modes, just like conda: strict, flexible and disabled. Strict will + completely disregard any packages from lower-priority channels if a + package of the same name exists in a higher priority channel. Flexible + will use packages from lower-priority channels if necessary to fulfill + dependencies or explicitly requested (e.g. by version number). Disabled + will use the highest version number, irregardless of the channel order. +- allow subdir selection as part of the channel: users can now specify an + explicit list of subdirs, for example: + + `-c mychannel[linux-static64, linux-64, noarch]` + + to pull in repodata and packages from these three subdirs. + Thanks for the contribution, @afranchuk! #1033 + +New features +- remove orphaned packages such as dependencies of explicitely installed + packages (@adriendelsalle) #1040 +- add a diff character before package name in transaction table to improve + readability without coloration (@adriendelsalle) #1040 +- add capability to freeze installed packages during `install` operation using + `--freeze-installed` flag (@adriendelsalle) #1048 +- Hide tokens and basic http auth secrets in log messages (#1061) +- Parse and use explicit platform specifications (thanks @afranchuk) (#1033) +- add pretty print to repoquery search (thanks @madhur-tandon) (#1018) +- add docs for package resolution + +Bug fixes: +- Fix small output issues (#1060) +- More descriptive incorrect download error (thanks @AntoinePrv) #1066 +- respect channel specific pins when updating (#1045) +- keep track features in PackageInfo class (#1046) + + +0.14.1 (June 25, 2021) +====================== + +New features +- [micromamba] add remove command, to remove keys of vectors (@marimeireles) + #1011 + +Bug fixes +- [micromamba] fixed in config prepend and append sequence (@adriendelsalle) + #1023 +- fix bug when username has @ (@madhur-tandon) #1025 +- fix wrong update spec in history (@madhur-tandon) #1028 +- [mamba] silent pinned packages using JSON output (@adriendelsalle) #1031 + +0.14.0 (June 16, 2021) +====================== + +New features +- [micromamba] add `config set`, `get`, `append` and `prepend`, `remove` + (@marimeireles) #838 +- automatically include `pip` in conda dependencies when having pip packages to + install (@madhur-tandon) #973 +- add experimental support for artifacts verification (@adriendelsalle) + #954,#955,#956,#963,#965,#970,#972,#978 +- [micromamba] shell init will try attempt to enable long paths support on + Windows (@wolfv) #975 +- [micromamba] if `menuinst` json files are present, micromamba will create + shortcuts in the start menu on Windows (@wolfv) #975 +- Improve python auto-pinning and add --no-py-pin flag to micromamba + (@adriendelsalle) #1010 +- [micromamba] Fix constructor invalid repodata_record (@adriendelsalle) #1007 +- Refactor log levels for linking steps (@adriendelsalle) #1009 +- [micromamba] Use a proper requirements.txt file for pip installations #1008 + +Bug fixes +- fix double-print int transaction (@JohanMabille) #952 +- fix strip function (@wolfv) #974 +- [micromamba] expand home directory in `--rc-file` (@adriendelsalle) #979 +- [micromamba] add yes and no as additional ways of answering a prompt + (@ibebrett) #989 +- fix long paths support on Windows (@adriendelsalle) #994 + +General improvement +- remove duplicate snippet (@madhur-tandon) #957 +- add `trace` log level (@adriendelsalle) #988 + +Docs +- concepts, user guide, configuration, update installation and build locally + (@adriendelsalle) #953 +- advance usage section, linking (@adriendelsalle) #998 +- repo, channel, subdir, repodata, tarball (@adriendelsalle) #1004 +- artifacts verification (@adriendelsalle) #1000 + +0.13.1 (May 17, 2021) +===================== + +Bug fixes +- [micromamba] pin only minor python version #948 +- [micromamba] use openssl certs when not linking statically #949 + +0.13.0 (May 12, 2021) +===================== + +New features +- [mamba & micromamba] aggregated progress bar for package downloading and + extraction (thanks @JohanMabille) #928 + +Bug fixes +- [micromamba] fixes for micromamba usage in constructor #935 +- [micromamba] fixes for the usage of lock files #936 +- [micromamba] switched from libsodium to openssl for ed25519 signature + verification #933 + +Docs +- Mention mambaforge in the README (thanks @s-pike) #932 + +0.12.3 (May 10, 2021) +===================== + +New features +- [libmamba] add free-function to use an existing conda root prefix + (@adriendelsalle) #927 + +General improvements +- [micromamba] fix a typo in documentation (@cjber) #926 + +0.12.2 (May 03, 2021) +===================== + +New features +- [micromamba] add initial framework for TUF validation (@adriendelsalle) #916 + #919 +- [micromamba] add channels from specs to download (@wolfv) #918 + +0.12.1 (Apr 30, 2021) +===================== + +New features +- [micromamba] env list subcommand (@wolfv) #913 + +Bug fixes +- [micromamba] fix multiple shell init with cmd.exe (@adriendelsalle) #915 +- [micromamba] fix activate with --stack option (@wolfv) #914 +- [libmamba] only try loading ssl certificates when needed (@adriendelsalle) + #910 +- [micromamba] remove target_prefix checks when activating (@adriendelsalle) + #909 +- [micromamba] allow 'ultra-dry' config checks in final build (@adriendelsalle) + #912 + +0.12.0 (Apr 26, 2021) +===================== + +New features +- [libmamba] add experimental shell autocompletion (@wolfv) #900 +- [libmamba] add token handling (@wolfv) #886 +- [libmamba] add experimental pip support in spec files (@wolfv) #885 + +Bug fixes +- [libmamba] ignore failing pyc compilation for noarch packages (@wolfv) #904 + #905 +- [libmamba] fix string wrapping in error message (@bdice) #902 +- [libmamba] fix cache error during remove operation (@adriendelsalle) #901 +- [libmamba] add constraint with pinning during update operation (@wolfv) #892 +- [libmamba] fix shell activate prefix check (@ashwinvis) #889 +- [libmamba] make prefix mandatory for shell init (@adriendelsalle) #896 +- [mamba] fix `env update` command (@ScottWales) #891 + +General improvements +- [libmamba] use lockfile, fix channel not loaded logic (@wolfv) #903 +- [libmamba] make root_prefix warnings more selective (@adriendelsalle) #899 +- [libmamba] house-keeping in python tests (@adriendelsalle) #898 +- [libmamba] modify mamba/micromamba specific guards (@adriendelsalle) #895 +- [libmamba] add simple lockfile mechanism (@wolfv) #894 +- [libmamba] deactivate ca-certificates search when using offline mode + (@adriendelsalle) #893 + +0.11.3 (Apr 21, 2021) +==================== + +- [libmamba] make platform rc configurable #883 +- [libmamba] expand user home in target and root prefixes #882 +- [libmamba] avoid memory effect between operations on target_prefix #881 +- [libmamba] fix unnecessary throwing target_prefix check in `clean` operation + #880 +- [micromamba] fix `clean` flags handling #880 +- [libmamba] C-API teardown on error #879 + +0.11.2 (Apr 21, 2021) +==================== + +- [libmamba] create "base" env only for install operation #875 +- [libmamba] remove confirmation prompt of root_prefix in shell init #874 +- [libmamba] improve overrides between target_prefix and env_name #873 +- [micromamba] fix use of `-p,--prefix` and spec file env name #873 + +0.11.1 (Apr 20, 2021) +==================== + +- [libmamba] fix channel_priority computation #872 + +0.11.0 (Apr 20, 2021) +==================== + +- [libmamba] add experimental mode that unlock edge features #858 +- [micromamba] add `--experimental` umamba flag to enable experimental mode + #858 +- [libmamba] improve base env creation #860 +- [libmamba] fix computation of weakly canonical target prefix #859 +- update libsolv dependency in env-dev.yml file, update documentation (thanks + @Aratz) #843 +- [libmamba] handle package cache in secondary locations, fix symlink errors + (thanks wenjuno) #856 +- [libmamba] fix CI cURL SSL error on macos with Darwin backend (thanks @wolfv) + #865 +- [libmamba] improve error handling in C-API by catching and returning an error + code #862 +- [libmamba] handle configuration lifetime (single operation configs) #863 +- [libmamba] enable ultra-dry C++ tests #868 +- [libmamba] migrate `config` operation implem from `micromamba` to `libmamba` + API #866 +- [libmamba] add capapbility to set CLI config from C-API #867 + +0.10.0 (Apr 16, 2021) +==================== + +- [micromamba] allow creation of empty env (without specs) #824 #827 +- [micromamba] automatically create empy `base` env at new root prefix #836 +- [micromamba] add remove all CLI flags `-a,--all` #824 +- [micromamba] add dry-run and ultra-dry-run tests to increase coverage and + speed-up CI #813 #845 +- [micromamba] allow CLI to override spec file env name (create, install and + update) #816 +- [libmamba] split low-level and high-level API #821 #824 +- [libmamba] add a C high-level API #826 +- [micromamba] support `__linux` virtual package #829 +- [micromamba] improve the display of solver problems #822 +- [micromamba] improve info sub-command with target prefix status (active, not + found, etc.) #825 +- [mamba] Change pybind11 to a build dependency (thanks @maresb) #846 +- [micromamba] add shell detection for shell sub-command #839 +- [micromamba] expand user in shell prefix sub-command #831 +- [micromamba] refactor explicit specs install #824 +- [libmamba] improve configuration (refactor API, create a loading sequence) + #840 +- [libmamba] support cpp-filesystem breaking changes on Windows fs #849 +- [libmamba] add a simple context debugging (thanks @wolf) #820 +- [libmamba] improve C++ test suite #830 +- fix CI C++ tests (unix/libmamba) and Python tests (win/mamba) wrongly + successful #853 + +0.9.2 (Apr 1, 2021) +==================== + +- [micromamba] fix unc url support (thanks @adament) +- [micromamba] add --channel-alias as cli option to micromamba (thanks + @adriendelsalle) +- [micromamba] fix --no-rc and environment yaml files (thanks @adriendelsalle) +- [micromamba] handle spec files in update and install subcommands (thanks + @adriendelsalle) +- add simple context debugging, dry run tests and other test framework + improvements + +0.9.1 (Mar 26, 2021) +==================== + +- [micromamba] fix remove command target_prefix selection +- [micromamba] improve target_prefix fallback for CLI, add tests (thanks + @adriendelsalle) + +0.9.0 (Mar 25, 2021) +==================== + +- [micromamba] use strict channels priority by default +- [micromamba] change config precedence order: API>CLI>ENV>RC +- [micromamba] `config list` sub command optional display of sources, defaults, + short/long descriptions and groups +- [micromamba] prevent crashes when no bashrc or zshrc file found (thanks + @wolfv) +- add support for UNC file:// urls (thanks @adament) +- add support for use_only_tar_bz2 (thanks @tl-hbk @wolfv) +- add pinned specs for env update (thanks @wolfv) +- properly adhere to run_constrains (thanks @wolfv) + +0.8.2 (Mar 12, 2021) +==================== + +- [micromamba] fix setting network options before explicit spec installation +- [micromamba] fix python based tests for windows + + +0.8.1 (Mar 11, 2021) +==================== + +- use stoull (instead of stoi) to prevent overflow with long package build + numbers (thanks @pbauwens-kbc) +- [micromamba] fixing OS X certificate search path +- [micromamba] refactor default root prefix, make it configurable from CLI + (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible (thanks + @adriendelsalle) +- [micromamba] sort json transaction, and add UNLINK field +- [micromamba] left align log messages +- [micromamba] libsolv log messages to stderr (thanks @mariusvniekerk) +- [micromamba] better curl error messages + + +0.8.0 (Mar 5, 2021) +=================== + +- [micromamba] condarc and mambarc config file reading (and config subcommand) + (thanks @adriendelsalle) +- [micromamba] support for virtual packages (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible +- [micromamba] add python based testing framework for CLI +- [micromamba] refactor CLI and micromamba main file (thanks @adriendelsalle) +- [micromamba] add linking options (--always-copy etc.) (thanks + @adriendelsalle) +- [micromamba] fix multiple prefix replacements in binary files +- [micromamba] fix micromamba clean (thanks @phue) +- [micromamba] change package validation settings to --safety-checks and + --extra-safety-checks +- [micromamba] add update subcommand (thanks @adriendelsalle) +- [micromamba] support pinning packages (including python minor version) + (thanks @adriendelsalle) +- [micromamba] add try/catch to WinReg getStringValue (thanks @SvenAdler) +- [micromamba] add ssl-no-revoke option for more conda-compatibility (thanks + @tl-hbk) +- [micromamba] die when no ssl certificates are found (thanks @wholtz) +- [docs] add explanation for base env install (thanks @ralexx) and rename + changelog to .md (thanks @kevinheavey) +- [micromamba] compare cleaned URLs for cache invalidation +- [micromamba] add regex handling to list command + + +0.7.14 (Feb 12, 2021) +===================== + +- [micromamba] better validation of extracted directories +- [mamba] add additional tests for authentication and simple repodata server +- make LOG_WARN the default log level, and move some logs to INFO +- [micromamba] properly replace long shebangs when linking +- [micromamba] add quote for shell for prefixes with spaces +- [micromamba] add clean functionality +- [micromamba] always make target prefix path absolute + + +0.7.13 (Feb 4, 2021) +==================== + +- [micromamba] Immediately exit after printing version (again) + +0.7.12 (Feb 3, 2021) +==================== + +- [micromamba] Improve CTRL+C signal handling behavior and simplify code +- [micromamba] Revert extraction to temporary directory because of invalid + cross-device links on Linux +- [micromamba] Clean up partially extracted archives when CTRL+C interruption + occured + +0.7.11 (Feb 2, 2021) +==================== + +- [micromamba] use wrapped call when compiling noarch Python code, which + properly calls chcp for Windows +- [micromamba] improve checking the pkgs cache +- [mamba] fix authenticated URLs (thanks @wenjuno) +- first extract to temporary directory, then move to final pkgs cache to + prevent corrupted extracted data + +0.7.10 (Jan 22, 2021) +==================== + +- [micromamba] properly fix PATH when linking, prevents missing + vcruntime140.dll +- [mamba] add virtual packages when creating any environment, not just on + update (thanks @cbalioglu) + +0.7.9 (Jan 19, 2021) +==================== + +- [micromamba] fix PATH when linking + +0.7.8 (Jan 14, 2021) +==================== + +- [micromamba] retry on corrupted repodata +- [mamba & micromamba] fix error handling when writing repodata + +0.7.6 (Dec 22, 2020) +==================== + +- [micromamba] more console flushing for std::cout consumers + +0.7.6 (Dec 14, 2020) +==================== + +- [mamba] more arguments for repodata.create_pool + +0.7.5 (Dec 10, 2020) +==================== + +- [micromamba] better error handling for YAML file reading, allows to pass in + `-n` and `-p` from command line +- [mamba & micromamba] ignore case of HTTP headers +- [mamba] fix channel keys are without tokens (thanks @s22chan) + +0.7.4 (Dec 5, 2020) +==================== + +- [micromamba] fix noarch installation for explicit environments + +0.7.3 (Nov 20, 2020) +==================== + +- [micromamba] fix installation of noarch files with long prefixes +- [micromamba] fix activation on windows with whitespaces in root prefix + (thanks @adriendelsalle) +- [micromamba] add `--json` output to micromamba list + +0.7.2 (Nov 18, 2020) +==================== + +- [micromamba] explicit specs installing should be better now + - empty lines are ignored + - network settings are correctly set to make ssl verification work +- New Python repoquery API for mamba +- Fix symlink packing for mamba package creation and transmute +- Do not keep tempfiles around + +0.7.1 (Nov 16, 2020) +==================== + +- Handle LIBARCHIVE_WARN to not error, instead print warning (thanks @obilaniu) + +0.7.0 (Nov 12, 2020) +==================== + +- Improve activation and deactivation logic for micromamba +- Switching `subprocess` implementation to more tested `reproc++` +- Fixing Windows noarch entrypoints generation with micromamba +- Fix pre-/post-link script running with micromamba to use micromamba + activation logic +- Empty environment creation skips all repodata downloading & solving +- Fix micromamba install when environment is activated (thanks @isuruf) +- Micromamba now respects the $CONDA_SUBDIR environment variable (thanks + @mariusvniekerk) +- Fix compile time warning (thanks @obilaniu) +- Fixed wrong CondaValueError import statement in mamba.py (thanks @saraedum) + +0.6.5 (Oct 2020) +================ + +- Fix code signing for Apple Silicon (osx-arm64) @isuruf diff --git a/mamba/LICENSE b/mamba/LICENSE new file mode 100644 index 0000000000..8ae98f9375 --- /dev/null +++ b/mamba/LICENSE @@ -0,0 +1,11 @@ +Copyright 2019 QuantStack and the Mamba contributors. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/mamba/MANIFEST.in similarity index 100% rename from MANIFEST.in rename to mamba/MANIFEST.in diff --git a/mamba/environment-dev.yml b/mamba/environment-dev.yml new file mode 100644 index 0000000000..d67da9dd1a --- /dev/null +++ b/mamba/environment-dev.yml @@ -0,0 +1,23 @@ +name: mamba-dev +channels: + - conda-forge +dependencies: + - cxx-compiler + - cmake + - ccache + - ninja + - nlohmann_json + - libsolv >=0.7.18 + - libarchive + - libsodium + - libcurl 7.76.1 *_0 + - gtest + - gmock + - cpp-filesystem >=1.5.8 + - reproc-cpp + - yaml-cpp + - termcolor-cpp + - cli11 + - pybind11 + - pytest + - conda diff --git a/mamba/__init__.py b/mamba/mamba/__init__.py similarity index 100% rename from mamba/__init__.py rename to mamba/mamba/__init__.py diff --git a/mamba/mamba/_version.py b/mamba/mamba/_version.py new file mode 100644 index 0000000000..8214285f87 --- /dev/null +++ b/mamba/mamba/_version.py @@ -0,0 +1,2 @@ +version_info = (0, 17, 0) +__version__ = ".".join(map(str, version_info)) diff --git a/mamba/mamba.py b/mamba/mamba/mamba.py similarity index 99% rename from mamba/mamba.py rename to mamba/mamba/mamba.py index 98fe07b267..82ae1b7198 100644 --- a/mamba/mamba.py +++ b/mamba/mamba/mamba.py @@ -49,8 +49,8 @@ from conda.misc import explicit, touch_nonadmin from conda.models.match_spec import MatchSpec +import libmambapy as api import mamba -import mamba.mamba_api as api from mamba import repoquery as repoquery_api from mamba.mamba_shell_init import shell_init from mamba.utils import get_installed_jsonfile, init_api_context, load_channels, to_txn diff --git a/mamba/mamba_env.py b/mamba/mamba/mamba_env.py similarity index 99% rename from mamba/mamba_env.py rename to mamba/mamba/mamba_env.py index 32f163d9f1..58f1c2cd37 100644 --- a/mamba/mamba_env.py +++ b/mamba/mamba/mamba_env.py @@ -13,7 +13,7 @@ from conda.models.match_spec import MatchSpec from conda_env.installers import conda -import mamba.mamba_api as api +import libmambapy as api from mamba.utils import get_installed_jsonfile, init_api_context, load_channels, to_txn diff --git a/mamba/mamba_shell_init.py b/mamba/mamba/mamba_shell_init.py similarity index 100% rename from mamba/mamba_shell_init.py rename to mamba/mamba/mamba_shell_init.py diff --git a/mamba/repoquery.py b/mamba/mamba/repoquery.py similarity index 98% rename from mamba/repoquery.py rename to mamba/mamba/repoquery.py index da347f3ac5..c5ebb56532 100644 --- a/mamba/repoquery.py +++ b/mamba/mamba/repoquery.py @@ -5,7 +5,7 @@ from conda.base.context import context -import mamba.mamba_api as api +import libmambapy as api from mamba.utils import init_api_context, load_channels diff --git a/mamba/shell_templates/mamba.bat b/mamba/mamba/shell_templates/mamba.bat similarity index 100% rename from mamba/shell_templates/mamba.bat rename to mamba/mamba/shell_templates/mamba.bat diff --git a/mamba/shell_templates/mamba.sh b/mamba/mamba/shell_templates/mamba.sh similarity index 100% rename from mamba/shell_templates/mamba.sh rename to mamba/mamba/shell_templates/mamba.sh diff --git a/mamba/shell_templates/win_redirect/mamba.bat b/mamba/mamba/shell_templates/win_redirect/mamba.bat similarity index 100% rename from mamba/shell_templates/win_redirect/mamba.bat rename to mamba/mamba/shell_templates/win_redirect/mamba.bat diff --git a/mamba/utils.py b/mamba/mamba/utils.py similarity index 99% rename from mamba/utils.py rename to mamba/mamba/utils.py index 82ef0e25a6..cb0f845370 100644 --- a/mamba/utils.py +++ b/mamba/mamba/utils.py @@ -24,7 +24,7 @@ from conda.models.prefix_graph import PrefixGraph from conda.models.records import PackageRecord -import mamba.mamba_api as api +import libmambapy as api def load_channel(subdir_data, result_container): diff --git a/mamba/setup.py b/mamba/setup.py new file mode 100644 index 0000000000..ad7c26631c --- /dev/null +++ b/mamba/setup.py @@ -0,0 +1,46 @@ +# Copyright (c) 2019, QuantStack and Mamba Contributors +# +# Distributed under the terms of the BSD 3-Clause License. +# +# The full license is in the file LICENSE, distributed with this software. + +# -*- coding: utf-8 -*- + +import os +import sys + +from setuptools import setup + +here = os.path.dirname(os.path.abspath(__file__)) + +version_ns = {} +with open(os.path.join(here, "mamba", "_version.py")) as f: + exec(f.read(), {}, version_ns) + +__version__ = version_ns["__version__"] + +data_files = [ + ("etc/profile.d", ["mamba/shell_templates/mamba.sh"]), +] +if sys.platform == "win32": + data_files.append(("condabin", ["mamba/shell_templates/mamba.bat"]),) + data_files.append( + ("Library/bin", ["mamba/shell_templates/win_redirect/mamba.bat"]), + ) + +setup( + name="mamba", + version=__version__, + author="Wolf Vollprecht", + author_email="wolf.vollprecht@quantstack.net", + url="https://github.com/mamba-org/mamba", + description="A fast, libsolv based solver and installer for conda packages.", + packages=["mamba"], + entry_points={"console_scripts": ["mamba = mamba.mamba:main"]}, + long_description="A (hopefully faster) reimplementation of the slow bits of conda.", + install_requires=["conda", "libmambapy"], + extras_require={"test": ["pytest", "pytest-lazy-fixture"]}, + data_files=data_files, + include_package_data=True, + zip_safe=False, +) diff --git a/test/channel_a/linux-64/repodata.json b/mamba/tests/channel_a/linux-64/repodata.json similarity index 100% rename from test/channel_a/linux-64/repodata.json rename to mamba/tests/channel_a/linux-64/repodata.json diff --git a/test/channel_a/linux-64/repodata.tar.bz2 b/mamba/tests/channel_a/linux-64/repodata.tar.bz2 similarity index 100% rename from test/channel_a/linux-64/repodata.tar.bz2 rename to mamba/tests/channel_a/linux-64/repodata.tar.bz2 diff --git a/test/channel_a/linux-64/repodata.tpl b/mamba/tests/channel_a/linux-64/repodata.tpl similarity index 100% rename from test/channel_a/linux-64/repodata.tpl rename to mamba/tests/channel_a/linux-64/repodata.tpl diff --git a/test/channel_a/noarch/repodata.json b/mamba/tests/channel_a/noarch/repodata.json similarity index 100% rename from test/channel_a/noarch/repodata.json rename to mamba/tests/channel_a/noarch/repodata.json diff --git a/test/channel_a/win-64/repodata.json b/mamba/tests/channel_a/win-64/repodata.json similarity index 100% rename from test/channel_a/win-64/repodata.json rename to mamba/tests/channel_a/win-64/repodata.json diff --git a/test/channel_a/win-64/repodata.tar.bz2 b/mamba/tests/channel_a/win-64/repodata.tar.bz2 similarity index 100% rename from test/channel_a/win-64/repodata.tar.bz2 rename to mamba/tests/channel_a/win-64/repodata.tar.bz2 diff --git a/test/channel_a/win-64/repodata.tpl b/mamba/tests/channel_a/win-64/repodata.tpl similarity index 100% rename from test/channel_a/win-64/repodata.tpl rename to mamba/tests/channel_a/win-64/repodata.tpl diff --git a/test/channel_b/linux-64/repodata.json b/mamba/tests/channel_b/linux-64/repodata.json similarity index 100% rename from test/channel_b/linux-64/repodata.json rename to mamba/tests/channel_b/linux-64/repodata.json diff --git a/test/channel_b/noarch/repodata.json b/mamba/tests/channel_b/noarch/repodata.json similarity index 100% rename from test/channel_b/noarch/repodata.json rename to mamba/tests/channel_b/noarch/repodata.json diff --git a/test/channel_b/win-64/repodata.json b/mamba/tests/channel_b/win-64/repodata.json similarity index 100% rename from test/channel_b/win-64/repodata.json rename to mamba/tests/channel_b/win-64/repodata.json diff --git a/test/generate_gpg_keys.sh b/mamba/tests/generate_gpg_keys.sh similarity index 100% rename from test/generate_gpg_keys.sh rename to mamba/tests/generate_gpg_keys.sh diff --git a/test/repo/channeldata.json b/mamba/tests/repo/channeldata.json similarity index 100% rename from test/repo/channeldata.json rename to mamba/tests/repo/channeldata.json diff --git a/test/repo/index.html b/mamba/tests/repo/index.html similarity index 100% rename from test/repo/index.html rename to mamba/tests/repo/index.html diff --git a/test/repo/noarch/current_repodata.json b/mamba/tests/repo/noarch/current_repodata.json similarity index 100% rename from test/repo/noarch/current_repodata.json rename to mamba/tests/repo/noarch/current_repodata.json diff --git a/test/repo/noarch/current_repodata.json.bz2 b/mamba/tests/repo/noarch/current_repodata.json.bz2 similarity index 100% rename from test/repo/noarch/current_repodata.json.bz2 rename to mamba/tests/repo/noarch/current_repodata.json.bz2 diff --git a/test/repo/noarch/index.html b/mamba/tests/repo/noarch/index.html similarity index 100% rename from test/repo/noarch/index.html rename to mamba/tests/repo/noarch/index.html diff --git a/test/repo/noarch/repodata.json b/mamba/tests/repo/noarch/repodata.json similarity index 100% rename from test/repo/noarch/repodata.json rename to mamba/tests/repo/noarch/repodata.json diff --git a/test/repo/noarch/repodata.json.bz2 b/mamba/tests/repo/noarch/repodata.json.bz2 similarity index 100% rename from test/repo/noarch/repodata.json.bz2 rename to mamba/tests/repo/noarch/repodata.json.bz2 diff --git a/test/repo/noarch/repodata_from_packages.json b/mamba/tests/repo/noarch/repodata_from_packages.json similarity index 100% rename from test/repo/noarch/repodata_from_packages.json rename to mamba/tests/repo/noarch/repodata_from_packages.json diff --git a/test/repo/noarch/repodata_from_packages.json.bz2 b/mamba/tests/repo/noarch/repodata_from_packages.json.bz2 similarity index 100% rename from test/repo/noarch/repodata_from_packages.json.bz2 rename to mamba/tests/repo/noarch/repodata_from_packages.json.bz2 diff --git a/test/repo/noarch/test-package-0.1-0.tar.bz2 b/mamba/tests/repo/noarch/test-package-0.1-0.tar.bz2 similarity index 100% rename from test/repo/noarch/test-package-0.1-0.tar.bz2 rename to mamba/tests/repo/noarch/test-package-0.1-0.tar.bz2 diff --git a/test/repo/recipes/test-package/meta.yaml b/mamba/tests/repo/recipes/test-package/meta.yaml similarity index 100% rename from test/repo/recipes/test-package/meta.yaml rename to mamba/tests/repo/recipes/test-package/meta.yaml diff --git a/test/repodata_a.json b/mamba/tests/repodata_a.json similarity index 100% rename from test/repodata_a.json rename to mamba/tests/repodata_a.json diff --git a/test/repodata_b.json b/mamba/tests/repodata_b.json similarity index 100% rename from test/repodata_b.json rename to mamba/tests/repodata_b.json diff --git a/test/reposerver.py b/mamba/tests/reposerver.py similarity index 97% rename from test/reposerver.py rename to mamba/tests/reposerver.py index 6e556cfd86..b39f339599 100644 --- a/test/reposerver.py +++ b/mamba/tests/reposerver.py @@ -1,11 +1,9 @@ import argparse import base64 import glob -import json import os import re import shutil -import socketserver from http.server import HTTPServer, SimpleHTTPRequestHandler from pathlib import Path @@ -217,7 +215,7 @@ def __init__(self, in_folder=args.directory): class BasicAuthHandler(SimpleHTTPRequestHandler): - """ Main class to present webpages and authentication. """ + """Main class to present webpages and authentication.""" def do_HEAD(self): self.send_response(200) @@ -250,12 +248,12 @@ def do_GET(self): class CondaTokenHandler(SimpleHTTPRequestHandler): - """ Main class to present webpages and authentication. """ + """Main class to present webpages and authentication.""" token_pattern = re.compile("^/t/([^/]+?)/") def do_GET(self): - """ Present frontpage with user authentication. """ + """Present frontpage with user authentication.""" global api_key match = self.token_pattern.search(self.path) if match: diff --git a/test/test_all.py b/mamba/tests/test_all.py similarity index 96% rename from test/test_all.py rename to mamba/tests/test_all.py index 2ee2796307..48d791c0e0 100644 --- a/test/test_all.py +++ b/mamba/tests/test_all.py @@ -19,7 +19,10 @@ def test_install(): add_glibc_virtual_package() copy_channels_osx() - channels = [(".", "test", "channel_b"), (".", "test", "channel_a")] + channels = [ + (".", "mamba", "tests", "channel_b"), + (".", "mamba", "tests", "channel_a"), + ] package = "a" run_mamba_conda(channels, package) @@ -154,9 +157,9 @@ def test_create_files(tmpdir): "--strict-channel-priority", "--dry-run", "-c", - "./test/channel_b", + "./mamba/tests/channel_b", "-c", - "./test/channel_a", + "./mamba/tests/channel_a", "--file", str(tmpdir / "1.txt"), "--file", diff --git a/test/test_env.yml b/mamba/tests/test_env.yml similarity index 100% rename from test/test_env.yml rename to mamba/tests/test_env.yml diff --git a/test/testserver.sh b/mamba/tests/testserver.sh similarity index 100% rename from test/testserver.sh rename to mamba/tests/testserver.sh diff --git a/test/update_env.yml b/mamba/tests/update_env.yml similarity index 100% rename from test/update_env.yml rename to mamba/tests/update_env.yml diff --git a/test/utils.py b/mamba/tests/utils.py similarity index 84% rename from test/utils.py rename to mamba/tests/utils.py index fde5af0e1c..4fc3441b9d 100644 --- a/test/utils.py +++ b/mamba/tests/utils.py @@ -90,7 +90,7 @@ def __enter__(self): return self.shell def __exit__(self, exc_type, exc_val, exc_tb): - self.shell.conda(f"deactivate") + self.shell.conda("deactivate") self.shell.conda(f"remove -q -y --name {self.name} --all") self.shell.exit() @@ -135,9 +135,10 @@ def run_mamba_conda(channels, package): def add_glibc_virtual_package(): version = get_glibc_version() - with open("test/channel_a/linux-64/repodata.tpl") as f: + here = os.path.dirname(os.path.abspath(__file__)) + with open(os.path.join(here, "channel_a/linux-64/repodata.tpl")) as f: repodata = f.read() - with open("test/channel_a/linux-64/repodata.json", "w") as f: + with open(os.path.join(here, "channel_a/linux-64/repodata.json"), "w") as f: if version is not None: glibc_placeholder = ', "__glibc=' + version + '"' else: @@ -147,13 +148,19 @@ def add_glibc_virtual_package(): def copy_channels_osx(): + here = os.path.dirname(os.path.abspath(__file__)) for channel in ["a", "b"]: - if not os.path.exists(f"test/channel_{channel}/osx-64"): + if not os.path.exists(os.path.join(here, f"channel_{channel}/osx-64")): shutil.copytree( - f"test/channel_{channel}/linux-64", f"test/channel_{channel}/osx-64" + os.path.join(here, f"channel_{channel}/linux-64"), + os.path.join(here, f"channel_{channel}/osx-64"), ) - with open(f"test/channel_{channel}/osx-64/repodata.json") as f: + with open( + os.path.join(here, f"channel_{channel}/osx-64/repodata.json") + ) as f: repodata = f.read() - with open(f"test/channel_{channel}/osx-64/repodata.json", "w") as f: + with open( + os.path.join(here, f"channel_{channel}/osx-64/repodata.json"), "w" + ) as f: repodata = repodata.replace("linux", "osx") f.write(repodata) diff --git a/mambaConfig.cmake.in b/mambaConfig.cmake.in deleted file mode 100644 index cfdf08fbba..0000000000 --- a/mambaConfig.cmake.in +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################ -# Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Martin Renou # -# Copyright (c) 2016, QuantStack # -# # -# Distributed under the terms of the BSD 3-Clause License. # -# # -# The full license is in the file LICENSE, distributed with this software. # -############################################################################ - -# mamba cmake module -# This module sets the following variables in your project:: -# -# mamba_FOUND - true if mamba found on the system -# mamba_INCLUDE_DIRS - the directory containing mamba headers -# mamba_LIBRARY - the library for dynamic linking -# mamba_STATIC_LIBRARY - the library for static linking - -@PACKAGE_INIT@ - -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR};${CMAKE_MODULE_PATH}") - -@MAMBA_CONFIG_CODE@ - -include(CMakeFindDependencyMacro) -find_dependency(nlohmann_json) -find_dependency(pybind11) -find_dependency(Threads) - -if(NOT TARGET mamba AND NOT TARGET mamba_lib) - include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") - - if (TARGET mamba AND TARGET mamba_lib) - get_target_property(@PROJECT_NAME@_INCLUDE_DIR mamba INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(@PROJECT_NAME@_LIBRARY mamba LOCATION) - get_target_property(@PROJECT_NAME@_STATIC_LIBRARY mamba_lib LOCATION) - elseif (TARGET mamba) - get_target_property(@PROJECT_NAME@_INCLUDE_DIR mamba INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(@PROJECT_NAME@_LIBRARY mamba LOCATION) - elseif (TARGET mamba_lib) - get_target_property(@PROJECT_NAME@_INCLUDE_DIR mamba_lib INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(@PROJECT_NAME@_STATIC_LIBRARY mamba_lib LOCATION) - set(@PROJECT_NAME@_LIBRARY ${@PROJECT_NAME@_STATIC_LIBRARY}) - endif () -endif() diff --git a/micromamba/CHANGELOG.md b/micromamba/CHANGELOG.md new file mode 100644 index 0000000000..bebd2d5d72 --- /dev/null +++ b/micromamba/CHANGELOG.md @@ -0,0 +1,526 @@ +0.17.0 (October 13, 2021) +========================= + +API Breaking changes: + +The Transaction and the Subdir interface have slightly changed (no more explicit setting of the writable +packages dir is necessary, this value is taken directly from the MultiPackagesCache now) + +- improve listing of (RC-) configurable values in `micromamba` #1210 (thanks @adriendelsalle) +- Improve micromamba lockfiles and add many tests #1193 (thanks @adriendelsalle) +- Support multiple package caches in micromamba (thanks @adriendelsalle) #1109 +- Order explicit envs in micromamba (also added some text to the docs about libsolv transactions) #1198 +- Add `micromamba package` subcommand to extract, create and transmute packages #1187 +- Improve micromamba configuration to support multi-stage loading of RC files (thanks @adriendelsalle) #1189 #1190 #1191 #1188 +- Add handling of `CONDA_SAFETY_CHECKS` to micromamba #1143 (thanks @isuruf) +- Improve mamba messaging by adding a space #1186 (thanks @wkusnierczyk) +- Add support for `custom_multichannels` #1142 +- micromamba: expose setting for `add_pip_as_python_dependency` #1203 +- stop displaying banner when running `mamba list` #1184 (thanks @madhur-thandon) + +0.16.0 (September 27, 2021) +=========================== + +- Add a User-Agent header to all requests (mamba/0.16.0) (thanks @shankerwangmiao) +- Add `micromamba env export (--explicit)` to micromamba +- Do not display banner with `mamba list` (thanks @madhur-tandon) +- Use directory of environment.yml as cwd when creating environment (thanks @marscher & @adriendelsalle) +- Improve outputs +- content-trust: Add Python bindings for content-trust API +- content-trust: Load PkgMgr definitions from file +- content-trust: Improve HEAD request fallback handling +- export Transaction.find_python_version to Python +- Continue `shell init` when we can't create the prefix script dir (thanks @maresb) +- Implement support for `fish` shell in `micromamba` (thanks @soraxas) +- Add constraint with pin when updating +- Expose methods for virtual packages to Python (thanks @madhur-tandon) + +0.15.3 (August 18, 2021) +======================== + +- change token regex to work with edge-cases (underscores in user name) (#1122) +- only pin major.minor version of python for update --all (#1101, thanks @mparry!) +- add mamba init to the activate message (#1124, thanks @isuruf) +- hide tokens in logs (#1121) +- add lockfiles for repodata and pkgs download (#1105, thanks @jaimergp) +- log actual SHA256/MD5/file size when failing to avlidate (#1095, thanks @johnhany97) +- Add mamba.bat in front of PATH (#1112, thanks @isuruf) +- Fix mamba not writable cache errors (#1108) + +0.15.2 (July 16, 2021) +====================== + +- micromamba autocomplete now ready for usage (#1091) +- improved file:// urls for windows to properly work (#1090) + +0.15.1 (July 15, 2021) +====================== + +New features: +- add `mamba init` command and add mamba.sh (#1075, thanks @isuruf & #1078) +- add flexible channel priority option in micromamba CLI (#1087) +- improved autocompletion for micromamba (#1079) + +Bug fixes: +- improve "file://" URL handling, fix local channel on Windows (#1085) +- fix CONDA_SUBDIR not being used in mamba (#1084) +- pass in channel_alias and custom_channels from conda to mamba (#1081) + +0.15.0 (July 9, 2021) +===================== + +Big changes: +- improve solutions by inspecting dependency versions as well (libsolv PR: + https://github.com/openSUSE/libsolv/pull/457) @wolfv +- properly implement strict channel priority (libsolv PR: + https://github.com/openSUSE/libsolv/pull/459) @adriendelsalle + + Note that this changes the meaning of strict and flexible priority as the + previous implementation did not follow conda's semantics. Mamba now has + three modes, just like conda: strict, flexible and disabled. Strict will + completely disregard any packages from lower-priority channels if a + package of the same name exists in a higher priority channel. Flexible + will use packages from lower-priority channels if necessary to fulfill + dependencies or explicitly requested (e.g. by version number). Disabled + will use the highest version number, irregardless of the channel order. +- allow subdir selection as part of the channel: users can now specify an + explicit list of subdirs, for example: + + `-c mychannel[linux-static64, linux-64, noarch]` + + to pull in repodata and packages from these three subdirs. + Thanks for the contribution, @afranchuk! #1033 + +New features +- remove orphaned packages such as dependencies of explicitely installed + packages (@adriendelsalle) #1040 +- add a diff character before package name in transaction table to improve + readability without coloration (@adriendelsalle) #1040 +- add capability to freeze installed packages during `install` operation using + `--freeze-installed` flag (@adriendelsalle) #1048 +- Hide tokens and basic http auth secrets in log messages (#1061) +- Parse and use explicit platform specifications (thanks @afranchuk) (#1033) +- add pretty print to repoquery search (thanks @madhur-tandon) (#1018) +- add docs for package resolution + +Bug fixes: +- Fix small output issues (#1060) +- More descriptive incorrect download error (thanks @AntoinePrv) #1066 +- respect channel specific pins when updating (#1045) +- keep track features in PackageInfo class (#1046) + + +0.14.1 (June 25, 2021) +====================== + +New features +- [micromamba] add remove command, to remove keys of vectors (@marimeireles) + #1011 + +Bug fixes +- [micromamba] fixed in config prepend and append sequence (@adriendelsalle) + #1023 +- fix bug when username has @ (@madhur-tandon) #1025 +- fix wrong update spec in history (@madhur-tandon) #1028 +- [mamba] silent pinned packages using JSON output (@adriendelsalle) #1031 + +0.14.0 (June 16, 2021) +====================== + +New features +- [micromamba] add `config set`, `get`, `append` and `prepend`, `remove` + (@marimeireles) #838 +- automatically include `pip` in conda dependencies when having pip packages to + install (@madhur-tandon) #973 +- add experimental support for artifacts verification (@adriendelsalle) + #954,#955,#956,#963,#965,#970,#972,#978 +- [micromamba] shell init will try attempt to enable long paths support on + Windows (@wolfv) #975 +- [micromamba] if `menuinst` json files are present, micromamba will create + shortcuts in the start menu on Windows (@wolfv) #975 +- Improve python auto-pinning and add --no-py-pin flag to micromamba + (@adriendelsalle) #1010 +- [micromamba] Fix constructor invalid repodata_record (@adriendelsalle) #1007 +- Refactor log levels for linking steps (@adriendelsalle) #1009 +- [micromamba] Use a proper requirements.txt file for pip installations #1008 + +Bug fixes +- fix double-print int transaction (@JohanMabille) #952 +- fix strip function (@wolfv) #974 +- [micromamba] expand home directory in `--rc-file` (@adriendelsalle) #979 +- [micromamba] add yes and no as additional ways of answering a prompt + (@ibebrett) #989 +- fix long paths support on Windows (@adriendelsalle) #994 + +General improvement +- remove duplicate snippet (@madhur-tandon) #957 +- add `trace` log level (@adriendelsalle) #988 + +Docs +- concepts, user guide, configuration, update installation and build locally + (@adriendelsalle) #953 +- advance usage section, linking (@adriendelsalle) #998 +- repo, channel, subdir, repodata, tarball (@adriendelsalle) #1004 +- artifacts verification (@adriendelsalle) #1000 + +0.13.1 (May 17, 2021) +===================== + +Bug fixes +- [micromamba] pin only minor python version #948 +- [micromamba] use openssl certs when not linking statically #949 + +0.13.0 (May 12, 2021) +===================== + +New features +- [mamba & micromamba] aggregated progress bar for package downloading and + extraction (thanks @JohanMabille) #928 + +Bug fixes +- [micromamba] fixes for micromamba usage in constructor #935 +- [micromamba] fixes for the usage of lock files #936 +- [micromamba] switched from libsodium to openssl for ed25519 signature + verification #933 + +Docs +- Mention mambaforge in the README (thanks @s-pike) #932 + +0.12.3 (May 10, 2021) +===================== + +New features +- [libmamba] add free-function to use an existing conda root prefix + (@adriendelsalle) #927 + +General improvements +- [micromamba] fix a typo in documentation (@cjber) #926 + +0.12.2 (May 03, 2021) +===================== + +New features +- [micromamba] add initial framework for TUF validation (@adriendelsalle) #916 + #919 +- [micromamba] add channels from specs to download (@wolfv) #918 + +0.12.1 (Apr 30, 2021) +===================== + +New features +- [micromamba] env list subcommand (@wolfv) #913 + +Bug fixes +- [micromamba] fix multiple shell init with cmd.exe (@adriendelsalle) #915 +- [micromamba] fix activate with --stack option (@wolfv) #914 +- [libmamba] only try loading ssl certificates when needed (@adriendelsalle) + #910 +- [micromamba] remove target_prefix checks when activating (@adriendelsalle) + #909 +- [micromamba] allow 'ultra-dry' config checks in final build (@adriendelsalle) + #912 + +0.12.0 (Apr 26, 2021) +===================== + +New features +- [libmamba] add experimental shell autocompletion (@wolfv) #900 +- [libmamba] add token handling (@wolfv) #886 +- [libmamba] add experimental pip support in spec files (@wolfv) #885 + +Bug fixes +- [libmamba] ignore failing pyc compilation for noarch packages (@wolfv) #904 + #905 +- [libmamba] fix string wrapping in error message (@bdice) #902 +- [libmamba] fix cache error during remove operation (@adriendelsalle) #901 +- [libmamba] add constraint with pinning during update operation (@wolfv) #892 +- [libmamba] fix shell activate prefix check (@ashwinvis) #889 +- [libmamba] make prefix mandatory for shell init (@adriendelsalle) #896 +- [mamba] fix `env update` command (@ScottWales) #891 + +General improvements +- [libmamba] use lockfile, fix channel not loaded logic (@wolfv) #903 +- [libmamba] make root_prefix warnings more selective (@adriendelsalle) #899 +- [libmamba] house-keeping in python tests (@adriendelsalle) #898 +- [libmamba] modify mamba/micromamba specific guards (@adriendelsalle) #895 +- [libmamba] add simple lockfile mechanism (@wolfv) #894 +- [libmamba] deactivate ca-certificates search when using offline mode + (@adriendelsalle) #893 + +0.11.3 (Apr 21, 2021) +==================== + +- [libmamba] make platform rc configurable #883 +- [libmamba] expand user home in target and root prefixes #882 +- [libmamba] avoid memory effect between operations on target_prefix #881 +- [libmamba] fix unnecessary throwing target_prefix check in `clean` operation + #880 +- [micromamba] fix `clean` flags handling #880 +- [libmamba] C-API teardown on error #879 + +0.11.2 (Apr 21, 2021) +==================== + +- [libmamba] create "base" env only for install operation #875 +- [libmamba] remove confirmation prompt of root_prefix in shell init #874 +- [libmamba] improve overrides between target_prefix and env_name #873 +- [micromamba] fix use of `-p,--prefix` and spec file env name #873 + +0.11.1 (Apr 20, 2021) +==================== + +- [libmamba] fix channel_priority computation #872 + +0.11.0 (Apr 20, 2021) +==================== + +- [libmamba] add experimental mode that unlock edge features #858 +- [micromamba] add `--experimental` umamba flag to enable experimental mode + #858 +- [libmamba] improve base env creation #860 +- [libmamba] fix computation of weakly canonical target prefix #859 +- update libsolv dependency in env-dev.yml file, update documentation (thanks + @Aratz) #843 +- [libmamba] handle package cache in secondary locations, fix symlink errors + (thanks wenjuno) #856 +- [libmamba] fix CI cURL SSL error on macos with Darwin backend (thanks @wolfv) + #865 +- [libmamba] improve error handling in C-API by catching and returning an error + code #862 +- [libmamba] handle configuration lifetime (single operation configs) #863 +- [libmamba] enable ultra-dry C++ tests #868 +- [libmamba] migrate `config` operation implem from `micromamba` to `libmamba` + API #866 +- [libmamba] add capapbility to set CLI config from C-API #867 + +0.10.0 (Apr 16, 2021) +==================== + +- [micromamba] allow creation of empty env (without specs) #824 #827 +- [micromamba] automatically create empy `base` env at new root prefix #836 +- [micromamba] add remove all CLI flags `-a,--all` #824 +- [micromamba] add dry-run and ultra-dry-run tests to increase coverage and + speed-up CI #813 #845 +- [micromamba] allow CLI to override spec file env name (create, install and + update) #816 +- [libmamba] split low-level and high-level API #821 #824 +- [libmamba] add a C high-level API #826 +- [micromamba] support `__linux` virtual package #829 +- [micromamba] improve the display of solver problems #822 +- [micromamba] improve info sub-command with target prefix status (active, not + found, etc.) #825 +- [mamba] Change pybind11 to a build dependency (thanks @maresb) #846 +- [micromamba] add shell detection for shell sub-command #839 +- [micromamba] expand user in shell prefix sub-command #831 +- [micromamba] refactor explicit specs install #824 +- [libmamba] improve configuration (refactor API, create a loading sequence) + #840 +- [libmamba] support cpp-filesystem breaking changes on Windows fs #849 +- [libmamba] add a simple context debugging (thanks @wolf) #820 +- [libmamba] improve C++ test suite #830 +- fix CI C++ tests (unix/libmamba) and Python tests (win/mamba) wrongly + successful #853 + +0.9.2 (Apr 1, 2021) +==================== + +- [micromamba] fix unc url support (thanks @adament) +- [micromamba] add --channel-alias as cli option to micromamba (thanks + @adriendelsalle) +- [micromamba] fix --no-rc and environment yaml files (thanks @adriendelsalle) +- [micromamba] handle spec files in update and install subcommands (thanks + @adriendelsalle) +- add simple context debugging, dry run tests and other test framework + improvements + +0.9.1 (Mar 26, 2021) +==================== + +- [micromamba] fix remove command target_prefix selection +- [micromamba] improve target_prefix fallback for CLI, add tests (thanks + @adriendelsalle) + +0.9.0 (Mar 25, 2021) +==================== + +- [micromamba] use strict channels priority by default +- [micromamba] change config precedence order: API>CLI>ENV>RC +- [micromamba] `config list` sub command optional display of sources, defaults, + short/long descriptions and groups +- [micromamba] prevent crashes when no bashrc or zshrc file found (thanks + @wolfv) +- add support for UNC file:// urls (thanks @adament) +- add support for use_only_tar_bz2 (thanks @tl-hbk @wolfv) +- add pinned specs for env update (thanks @wolfv) +- properly adhere to run_constrains (thanks @wolfv) + +0.8.2 (Mar 12, 2021) +==================== + +- [micromamba] fix setting network options before explicit spec installation +- [micromamba] fix python based tests for windows + + +0.8.1 (Mar 11, 2021) +==================== + +- use stoull (instead of stoi) to prevent overflow with long package build + numbers (thanks @pbauwens-kbc) +- [micromamba] fixing OS X certificate search path +- [micromamba] refactor default root prefix, make it configurable from CLI + (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible (thanks + @adriendelsalle) +- [micromamba] sort json transaction, and add UNLINK field +- [micromamba] left align log messages +- [micromamba] libsolv log messages to stderr (thanks @mariusvniekerk) +- [micromamba] better curl error messages + + +0.8.0 (Mar 5, 2021) +=================== + +- [micromamba] condarc and mambarc config file reading (and config subcommand) + (thanks @adriendelsalle) +- [micromamba] support for virtual packages (thanks @adriendelsalle) +- [micromamba] set ssl backend, use native SSL if possible +- [micromamba] add python based testing framework for CLI +- [micromamba] refactor CLI and micromamba main file (thanks @adriendelsalle) +- [micromamba] add linking options (--always-copy etc.) (thanks + @adriendelsalle) +- [micromamba] fix multiple prefix replacements in binary files +- [micromamba] fix micromamba clean (thanks @phue) +- [micromamba] change package validation settings to --safety-checks and + --extra-safety-checks +- [micromamba] add update subcommand (thanks @adriendelsalle) +- [micromamba] support pinning packages (including python minor version) + (thanks @adriendelsalle) +- [micromamba] add try/catch to WinReg getStringValue (thanks @SvenAdler) +- [micromamba] add ssl-no-revoke option for more conda-compatibility (thanks + @tl-hbk) +- [micromamba] die when no ssl certificates are found (thanks @wholtz) +- [docs] add explanation for base env install (thanks @ralexx) and rename + changelog to .md (thanks @kevinheavey) +- [micromamba] compare cleaned URLs for cache invalidation +- [micromamba] add regex handling to list command + + +0.7.14 (Feb 12, 2021) +===================== + +- [micromamba] better validation of extracted directories +- [mamba] add additional tests for authentication and simple repodata server +- make LOG_WARN the default log level, and move some logs to INFO +- [micromamba] properly replace long shebangs when linking +- [micromamba] add quote for shell for prefixes with spaces +- [micromamba] add clean functionality +- [micromamba] always make target prefix path absolute + + +0.7.13 (Feb 4, 2021) +==================== + +- [micromamba] Immediately exit after printing version (again) + +0.7.12 (Feb 3, 2021) +==================== + +- [micromamba] Improve CTRL+C signal handling behavior and simplify code +- [micromamba] Revert extraction to temporary directory because of invalid + cross-device links on Linux +- [micromamba] Clean up partially extracted archives when CTRL+C interruption + occured + +0.7.11 (Feb 2, 2021) +==================== + +- [micromamba] use wrapped call when compiling noarch Python code, which + properly calls chcp for Windows +- [micromamba] improve checking the pkgs cache +- [mamba] fix authenticated URLs (thanks @wenjuno) +- first extract to temporary directory, then move to final pkgs cache to + prevent corrupted extracted data + +0.7.10 (Jan 22, 2021) +==================== + +- [micromamba] properly fix PATH when linking, prevents missing + vcruntime140.dll +- [mamba] add virtual packages when creating any environment, not just on + update (thanks @cbalioglu) + +0.7.9 (Jan 19, 2021) +==================== + +- [micromamba] fix PATH when linking + +0.7.8 (Jan 14, 2021) +==================== + +- [micromamba] retry on corrupted repodata +- [mamba & micromamba] fix error handling when writing repodata + +0.7.6 (Dec 22, 2020) +==================== + +- [micromamba] more console flushing for std::cout consumers + +0.7.6 (Dec 14, 2020) +==================== + +- [mamba] more arguments for repodata.create_pool + +0.7.5 (Dec 10, 2020) +==================== + +- [micromamba] better error handling for YAML file reading, allows to pass in + `-n` and `-p` from command line +- [mamba & micromamba] ignore case of HTTP headers +- [mamba] fix channel keys are without tokens (thanks @s22chan) + +0.7.4 (Dec 5, 2020) +==================== + +- [micromamba] fix noarch installation for explicit environments + +0.7.3 (Nov 20, 2020) +==================== + +- [micromamba] fix installation of noarch files with long prefixes +- [micromamba] fix activation on windows with whitespaces in root prefix + (thanks @adriendelsalle) +- [micromamba] add `--json` output to micromamba list + +0.7.2 (Nov 18, 2020) +==================== + +- [micromamba] explicit specs installing should be better now + - empty lines are ignored + - network settings are correctly set to make ssl verification work +- New Python repoquery API for mamba +- Fix symlink packing for mamba package creation and transmute +- Do not keep tempfiles around + +0.7.1 (Nov 16, 2020) +==================== + +- Handle LIBARCHIVE_WARN to not error, instead print warning (thanks @obilaniu) + +0.7.0 (Nov 12, 2020) +==================== + +- Improve activation and deactivation logic for micromamba +- Switching `subprocess` implementation to more tested `reproc++` +- Fixing Windows noarch entrypoints generation with micromamba +- Fix pre-/post-link script running with micromamba to use micromamba + activation logic +- Empty environment creation skips all repodata downloading & solving +- Fix micromamba install when environment is activated (thanks @isuruf) +- Micromamba now respects the $CONDA_SUBDIR environment variable (thanks + @mariusvniekerk) +- Fix compile time warning (thanks @obilaniu) +- Fixed wrong CondaValueError import statement in mamba.py (thanks @saraedum) + +0.6.5 (Oct 2020) +================ + +- Fix code signing for Apple Silicon (osx-arm64) @isuruf diff --git a/src/micromamba/CMakeLists.txt b/micromamba/CMakeLists.txt similarity index 62% rename from src/micromamba/CMakeLists.txt rename to micromamba/CMakeLists.txt index 5a0fe5cf60..0de73dc9df 100644 --- a/src/micromamba/CMakeLists.txt +++ b/micromamba/CMakeLists.txt @@ -1,41 +1,41 @@ -set(MAMBA_EXE - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/clean.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/config.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/completer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/constructor.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/create.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/info.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/install.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/list.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/common_options.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/remove.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/shell.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/umamba.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/update.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/env.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/package.cpp +set(MICROMAMBA_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/src/clean.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/config.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/completer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/constructor.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/create.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/info.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/install.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/list.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/common_options.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/remove.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/shell.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/umamba.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/update.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/env.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/package.cpp ) -set(MAMBA_EXE_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/common_options.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/micromamba/umamba.hpp +set(MICROMAMBA_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/src/common_options.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/umamba.hpp ) -add_executable(micromamba ${MAMBA_EXE} ${MAMBA_EXE_HEADERS}) +add_executable(micromamba ${MICROMAMBA_SRCS} ${MICROMAMBA_HEADERS}) target_include_directories( micromamba - PRIVATE $ + PRIVATE $ ) -target_link_libraries(micromamba PRIVATE mamba-static) +target_link_libraries(micromamba PRIVATE libmamba-static) -message("Using static dependencies for micromamba: ${STATIC_DEPENDENCIES}") +message("Using static dependencies for micromamba: ${MICROMAMBA_STATIC_LINK}") -if (STATIC_DEPENDENCIES AND UNIX) +if (MICROMAMBA_STATIC_LINK AND UNIX) - set(MAMBA_DEPENDENCIES_LIBS + set(UMAMBA_LIB_DEPS libcurl.a libssh2.a @@ -69,12 +69,8 @@ if (STATIC_DEPENDENCIES AND UNIX) libreproc.a ) - if (BUILD_CRYPTO_PACKAGE_VALIDATION) - list(APPEND MAMBA_DEPENDENCIES_LIBS "libsodium.a") - endif() - set(FINAL_LIBS "") - foreach(LIB ${MAMBA_DEPENDENCIES_LIBS}) + foreach(LIB ${UMAMBA_LIB_DEPS}) set(TMP_LIB "TMP_LIB-NOTFOUND") find_library(TMP_LIB NAMES "${LIB}" @@ -104,7 +100,7 @@ if (STATIC_DEPENDENCIES AND UNIX) target_link_libraries(micromamba PRIVATE ${FINAL_LIBS} ${MAMBA_FORCE_DYNAMIC_LIBS}) -elseif (STATIC_DEPENDENCIES AND WIN32) +elseif (MICROMAMBA_STATIC_LINK AND WIN32) set(CMAKE_PREFIX_PATH "$ENV{VCPKG_ROOT}/installed/x64-windows-static/") @@ -120,14 +116,10 @@ elseif (STATIC_DEPENDENCIES AND WIN32) find_library(BZIP2_LIBRARIES NAMES bz2) find_library(CRYPTO_LIBRARIES NAMES libcrypto) - find_library(LIBSOLV_STATIC_LIBRARIES NAMES solv_static) - find_library(LIBSOLVEXT_STATIC_LIBRARIES NAMES solvext_static) + find_library(LIBSOLV_BUILD_STATICRARIES NAMES solv_static) + find_library(LIBSOLVEXT_BUILD_STATICRARIES NAMES solvext_static) find_package(reproc++ CONFIG REQUIRED) - if (BUILD_CRYPTO_PACKAGE_VALIDATION) - find_package(Sodium REQUIRED) - endif() - find_library(LIBXML2_LIBRARY NAMES libxml2) find_library(ICONV_LIBRARY NAMES libiconv) find_library(CHARSET_LIBRARY NAMES libcharset) @@ -147,13 +139,13 @@ elseif (STATIC_DEPENDENCIES AND WIN32) CURL::libcurl nlohmann_json::nlohmann_json ${YAML_CPP_LIBRARIES} - ${LIBSOLV_STATIC_LIBRARIES} - ${LIBSOLVEXT_STATIC_LIBRARIES} + ${LIBSOLV_BUILD_STATICRARIES} + ${LIBSOLVEXT_BUILD_STATICRARIES} ${sodium_LIBRARY_RELEASE} reproc++ ) - add_definitions("-DLIBARCHIVE_STATIC -DCURL_STATICLIB -DSOLV_STATIC_LIB") + add_definitions("-DLIBARCHIVE_STATIC -DCURL_STATICLIB -DSOLV_BUILD_STATIC") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") include_directories($ENV{CONDA_PREFIX}/Library/include/) include_directories($ENV{VCPKG_ROOT}/installed/x64-windows-static/include/) diff --git a/micromamba/LICENSE b/micromamba/LICENSE new file mode 100644 index 0000000000..8ae98f9375 --- /dev/null +++ b/micromamba/LICENSE @@ -0,0 +1,11 @@ +Copyright 2019 QuantStack and the Mamba contributors. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/environment-dev.yml b/micromamba/environment-dev.yml similarity index 90% rename from environment-dev.yml rename to micromamba/environment-dev.yml index 0331f935c5..d825e166a9 100644 --- a/environment-dev.yml +++ b/micromamba/environment-dev.yml @@ -1,25 +1,23 @@ name: mamba-dev channels: - conda-forge - - defaults dependencies: + - cxx-compiler - cmake - - make - ninja + - ccache - nlohmann_json - - pybind11 - libsolv >=0.7.18 - libarchive - libsodium - libcurl 7.76.1 *_0 - - cxx-compiler - gtest - gmock - cpp-filesystem >=1.5.8 - reproc-cpp - yaml-cpp - - pyyaml + - termcolor-cpp - cli11 - - ccache - pytest - pytest-lazy-fixture + - pyyaml diff --git a/src/micromamba/clean.cpp b/micromamba/src/clean.cpp similarity index 100% rename from src/micromamba/clean.cpp rename to micromamba/src/clean.cpp diff --git a/src/micromamba/common_options.cpp b/micromamba/src/common_options.cpp similarity index 100% rename from src/micromamba/common_options.cpp rename to micromamba/src/common_options.cpp diff --git a/src/micromamba/common_options.hpp b/micromamba/src/common_options.hpp similarity index 100% rename from src/micromamba/common_options.hpp rename to micromamba/src/common_options.hpp diff --git a/src/micromamba/completer.bash b/micromamba/src/completer.bash similarity index 100% rename from src/micromamba/completer.bash rename to micromamba/src/completer.bash diff --git a/src/micromamba/completer.cpp b/micromamba/src/completer.cpp similarity index 100% rename from src/micromamba/completer.cpp rename to micromamba/src/completer.cpp diff --git a/src/micromamba/config.cpp b/micromamba/src/config.cpp similarity index 100% rename from src/micromamba/config.cpp rename to micromamba/src/config.cpp diff --git a/src/micromamba/constructor.cpp b/micromamba/src/constructor.cpp similarity index 100% rename from src/micromamba/constructor.cpp rename to micromamba/src/constructor.cpp diff --git a/src/micromamba/constructor.hpp b/micromamba/src/constructor.hpp similarity index 100% rename from src/micromamba/constructor.hpp rename to micromamba/src/constructor.hpp diff --git a/src/micromamba/create.cpp b/micromamba/src/create.cpp similarity index 100% rename from src/micromamba/create.cpp rename to micromamba/src/create.cpp diff --git a/src/micromamba/env.cpp b/micromamba/src/env.cpp similarity index 100% rename from src/micromamba/env.cpp rename to micromamba/src/env.cpp diff --git a/src/micromamba/info.cpp b/micromamba/src/info.cpp similarity index 100% rename from src/micromamba/info.cpp rename to micromamba/src/info.cpp diff --git a/src/micromamba/install.cpp b/micromamba/src/install.cpp similarity index 100% rename from src/micromamba/install.cpp rename to micromamba/src/install.cpp diff --git a/src/micromamba/list.cpp b/micromamba/src/list.cpp similarity index 100% rename from src/micromamba/list.cpp rename to micromamba/src/list.cpp diff --git a/src/micromamba/main.cpp b/micromamba/src/main.cpp similarity index 97% rename from src/micromamba/main.cpp rename to micromamba/src/main.cpp index 81e763476e..8dd0d5f1e3 100644 --- a/src/micromamba/main.cpp +++ b/micromamba/src/main.cpp @@ -6,12 +6,13 @@ #include "umamba.hpp" +#include "mamba/version.hpp" + +#include "mamba/api/configuration.hpp" + #include "mamba/core/context.hpp" #include "mamba/core/output.hpp" #include "mamba/core/thread_utils.hpp" -#include "mamba/core/version.hpp" - -#include "mamba/api/configuration.hpp" #include diff --git a/src/micromamba/package.cpp b/micromamba/src/package.cpp similarity index 100% rename from src/micromamba/package.cpp rename to micromamba/src/package.cpp diff --git a/src/micromamba/remove.cpp b/micromamba/src/remove.cpp similarity index 100% rename from src/micromamba/remove.cpp rename to micromamba/src/remove.cpp diff --git a/src/micromamba/shell.cpp b/micromamba/src/shell.cpp similarity index 100% rename from src/micromamba/shell.cpp rename to micromamba/src/shell.cpp diff --git a/src/micromamba/umamba.cpp b/micromamba/src/umamba.cpp similarity index 97% rename from src/micromamba/umamba.cpp rename to micromamba/src/umamba.cpp index df10969193..6a2c2d10ef 100644 --- a/src/micromamba/umamba.cpp +++ b/micromamba/src/umamba.cpp @@ -4,13 +4,14 @@ // // The full license is in the file LICENSE, distributed with this software. +#include "mamba/version.hpp" + #include "common_options.hpp" #include "umamba.hpp" #include "mamba/core/context.hpp" -#include "mamba/core/version.hpp" -#include "../thirdparty/termcolor.hpp" +#include "termcolor/termcolor.hpp" using namespace mamba; // NOLINT(build/namespaces) diff --git a/src/micromamba/umamba.hpp b/micromamba/src/umamba.hpp similarity index 100% rename from src/micromamba/umamba.hpp rename to micromamba/src/umamba.hpp diff --git a/src/micromamba/update.cpp b/micromamba/src/update.cpp similarity index 100% rename from src/micromamba/update.cpp rename to micromamba/src/update.cpp diff --git a/test/micromamba/__init__.py b/micromamba/tests/__init__.py similarity index 100% rename from test/micromamba/__init__.py rename to micromamba/tests/__init__.py diff --git a/test/explicit_env_linux.txt b/micromamba/tests/explicit_env_linux.txt similarity index 100% rename from test/explicit_env_linux.txt rename to micromamba/tests/explicit_env_linux.txt diff --git a/test/explicit_env_osx.txt b/micromamba/tests/explicit_env_osx.txt similarity index 100% rename from test/explicit_env_osx.txt rename to micromamba/tests/explicit_env_osx.txt diff --git a/test/micromamba/helpers.py b/micromamba/tests/helpers.py similarity index 99% rename from test/micromamba/helpers.py rename to micromamba/tests/helpers.py index dc830b3d72..63da8a7649 100644 --- a/test/micromamba/helpers.py +++ b/micromamba/tests/helpers.py @@ -54,7 +54,7 @@ def get_umamba(cwd=os.getcwd()): umamba_bin = "micromamba.exe" else: umamba_bin = "micromamba" - umamba = os.path.join(cwd, "build", umamba_bin) + umamba = os.path.join(cwd, "build", "micromamba", umamba_bin) if not Path(umamba).exists(): print("MICROMAMBA NOT FOUND!") return umamba @@ -236,7 +236,6 @@ def umamba_list(*args): def get_concrete_pkg(t, needle): pkgs = t["actions"]["LINK"] - pkg_name = None for p in pkgs: if p["name"] == needle: return f"{p['name']}-{p['version']}-{p['build_string']}" diff --git a/test/spec_file_1.txt b/micromamba/tests/spec_file_1.txt similarity index 100% rename from test/spec_file_1.txt rename to micromamba/tests/spec_file_1.txt diff --git a/test/spec_file_2.txt b/micromamba/tests/spec_file_2.txt similarity index 100% rename from test/spec_file_2.txt rename to micromamba/tests/spec_file_2.txt diff --git a/test/micromamba/test_activation.py b/micromamba/tests/test_activation.py similarity index 100% rename from test/micromamba/test_activation.py rename to micromamba/tests/test_activation.py diff --git a/test/micromamba/test_config.py b/micromamba/tests/test_config.py similarity index 100% rename from test/micromamba/test_config.py rename to micromamba/tests/test_config.py diff --git a/test/micromamba/test_constructor.py b/micromamba/tests/test_constructor.py similarity index 99% rename from test/micromamba/test_constructor.py rename to micromamba/tests/test_constructor.py index 29c7d30ddd..790e1487aa 100644 --- a/test/micromamba/test_constructor.py +++ b/micromamba/tests/test_constructor.py @@ -4,8 +4,6 @@ import shutil import subprocess -import pytest - from .helpers import * diff --git a/test/micromamba/test_create.py b/micromamba/tests/test_create.py similarity index 100% rename from test/micromamba/test_create.py rename to micromamba/tests/test_create.py diff --git a/test/micromamba/test_env.py b/micromamba/tests/test_env.py similarity index 100% rename from test/micromamba/test_env.py rename to micromamba/tests/test_env.py diff --git a/test/micromamba/test_info.py b/micromamba/tests/test_info.py similarity index 100% rename from test/micromamba/test_info.py rename to micromamba/tests/test_info.py diff --git a/test/micromamba/test_install.py b/micromamba/tests/test_install.py similarity index 96% rename from test/micromamba/test_install.py rename to micromamba/tests/test_install.py index 38606b4478..b193daf2a6 100644 --- a/test/micromamba/test_install.py +++ b/micromamba/tests/test_install.py @@ -1,9 +1,5 @@ -import json import os -import platform -import random import shutil -import string import subprocess from pathlib import Path @@ -88,9 +84,12 @@ def test_specs(self, source, file_type, existing_cache): file_content = ["xtensor >0.20", "xsimd"] specs += file_content elif file_type == "explicit": + channel = "https://conda.anaconda.org/conda-forge/linux-64/" explicit_specs = [ - "https://conda.anaconda.org/conda-forge/linux-64/xtensor-0.21.5-hc9558a2_0.tar.bz2#d330e02e5ed58330638a24601b7e4887", - "https://conda.anaconda.org/conda-forge/linux-64/xsimd-7.4.8-hc9558a2_0.tar.bz2#32d5b7ad7d6511f1faacf87e53a63e5f", + channel + + "xtensor-0.21.5-hc9558a2_0.tar.bz2#d330e02e5ed58330638a24601b7e4887", + channel + + "xsimd-7.4.8-hc9558a2_0.tar.bz2#32d5b7ad7d6511f1faacf87e53a63e5f", ] file_content = ["@EXPLICIT"] + explicit_specs specs = explicit_specs @@ -248,9 +247,12 @@ def test_channels(self, cli, yaml, env_var, rc_file, existing_cache): def test_multiple_spec_files(self, type, existing_cache): cmd = [] specs = ["xtensor", "xsimd"] + channel = "https://conda.anaconda.org/conda-forge/linux-64/" explicit_specs = [ - "https://conda.anaconda.org/conda-forge/linux-64/xtensor-0.21.5-hc9558a2_0.tar.bz2#d330e02e5ed58330638a24601b7e4887", - "https://conda.anaconda.org/conda-forge/linux-64/xsimd-7.4.8-hc9558a2_0.tar.bz2#32d5b7ad7d6511f1faacf87e53a63e5f", + channel + + "xtensor-0.21.5-hc9558a2_0.tar.bz2#d330e02e5ed58330638a24601b7e4887", + channel + + "linux-64/xsimd-7.4.8-hc9558a2_0.tar.bz2#32d5b7ad7d6511f1faacf87e53a63e5f", ] for i in range(2): diff --git a/test/micromamba/test_linking.py b/micromamba/tests/test_linking.py similarity index 100% rename from test/micromamba/test_linking.py rename to micromamba/tests/test_linking.py diff --git a/test/micromamba/test_list.py b/micromamba/tests/test_list.py similarity index 100% rename from test/micromamba/test_list.py rename to micromamba/tests/test_list.py diff --git a/test/micromamba/test_menuinst.py b/micromamba/tests/test_menuinst.py similarity index 100% rename from test/micromamba/test_menuinst.py rename to micromamba/tests/test_menuinst.py diff --git a/test/micromamba/test_pkg_cache.py b/micromamba/tests/test_pkg_cache.py similarity index 100% rename from test/micromamba/test_pkg_cache.py rename to micromamba/tests/test_pkg_cache.py diff --git a/test/micromamba/test_remove.py b/micromamba/tests/test_remove.py similarity index 100% rename from test/micromamba/test_remove.py rename to micromamba/tests/test_remove.py diff --git a/test/micromamba/test_shell.py b/micromamba/tests/test_shell.py similarity index 97% rename from test/micromamba/test_shell.py rename to micromamba/tests/test_shell.py index 8817c0e318..8619bdb724 100644 --- a/test/micromamba/test_shell.py +++ b/micromamba/tests/test_shell.py @@ -7,15 +7,7 @@ import pytest -from .helpers import ( - MAMBA_NO_PREFIX_CHECK, - create, - get_env, - get_umamba, - info, - random_string, - shell, -) +from .helpers import MAMBA_NO_PREFIX_CHECK, create, get_umamba, random_string, shell def skip_if_shell_incompat(shell_type): @@ -70,7 +62,6 @@ def test_hook(self, shell_type): # mamba_exe = f"\\\\?\\{mamba_exe}" if shell_type == "powershell": - umamba = get_umamba() assert f"$Env:MAMBA_EXE='{mamba_exe}'" in res elif shell_type in ("zsh", "bash", "posix"): assert res.count(mamba_exe) == 5 @@ -125,7 +116,7 @@ def custom_shell(shell): cmd = [shell, f_name] if platform.system() == "Windows": # bash on Windows with open(f_name, "w") as f: - f.write("build/micromamba.exe shell hook --json") + f.write("build/micromamba/micromamba.exe shell hook --json") else: with open(f_name, "w") as f: f.write(f"{umamba} shell hook --json") diff --git a/test/micromamba/test_update.py b/micromamba/tests/test_update.py similarity index 100% rename from test/micromamba/test_update.py rename to micromamba/tests/test_update.py diff --git a/test/micromamba/test_virtual_pkgs.py b/micromamba/tests/test_virtual_pkgs.py similarity index 80% rename from test/micromamba/test_virtual_pkgs.py rename to micromamba/tests/test_virtual_pkgs.py index 1c9db2f9ec..a1c03c51ea 100644 --- a/test/micromamba/test_virtual_pkgs.py +++ b/micromamba/tests/test_virtual_pkgs.py @@ -1,13 +1,6 @@ -import json -import os import platform -import shutil -import subprocess -from pathlib import Path -import pytest - -from .helpers import create, get_env, info, random_string +from .helpers import info class TestVirtualPkgs: diff --git a/test/yaml_env.yml b/micromamba/tests/yaml_env.yml similarity index 100% rename from test/yaml_env.yml rename to micromamba/tests/yaml_env.yml diff --git a/setup.py b/setup.py deleted file mode 100644 index 5a50dc7654..0000000000 --- a/setup.py +++ /dev/null @@ -1,217 +0,0 @@ -# Copyright (c) 2019, QuantStack and Mamba Contributors -# -# Distributed under the terms of the BSD 3-Clause License. -# -# The full license is in the file LICENSE, distributed with this software. - -# -*- coding: utf-8 -*- - -import os -import sys - -import setuptools -from setuptools import Extension, setup -from setuptools.command.build_ext import build_ext - -here = os.path.dirname(os.path.abspath(__file__)) - -version_ns = {} -with open(os.path.join(here, "mamba", "_version.py")) as f: - exec(f.read(), {}, version_ns) - -__version__ = version_ns["__version__"] - -with open("include/mamba/core/version.hpp.in", "r") as fi: - cpp_version_template = fi.read() - -v = version_ns["version_info"] -cpp_version_template = ( - cpp_version_template.replace("@MAMBA_VERSION_MAJOR@", str(v[0])) - .replace("@MAMBA_VERSION_MINOR@", str(v[1])) - .replace("@MAMBA_VERSION_PATCH@", str(v[2])) -) - -with open("include/mamba/core/version.hpp", "w") as fo: - fo.write(cpp_version_template) - - -class get_pybind_include(object): - """Helper class to determine the pybind11 include path - The purpose of this class is to postpone importing pybind11 - until it is actually installed, so that the ``get_include()`` - method can be invoked.""" - - def __init__(self, user=False): - self.user = user - - def __str__(self): - import pybind11 - - return pybind11.get_include(self.user) - - -if sys.platform.startswith("win"): - libsolv_prefix = os.path.join(sys.prefix, "Library\\") -else: - libsolv_prefix = sys.prefix - -print("Looking for libsolv in: ", libsolv_prefix) - -extra_link_args = [] -if sys.platform == "darwin": - extra_link_args = ["-Wl,-rpath", "-Wl,%s" % os.path.abspath(libsolv_prefix)] - -library_dir = [] -if sys.platform == "win32": - try: - conda_prefix = os.getenv("CONDA_PREFIX") - if not conda_prefix: - conda_prefix = os.getenv("MINICONDA") - if not conda_prefix: - raise RuntimeError("No conda prefix found") - - library_dir = [os.path.join(conda_prefix, "Library\\lib\\")] - print("Looking for libsolv library in ", library_dir) - except Exception: - print("could not find conda prefix") - - CURL_LIB = "libcurl" - CRYPTO_LIB = "libcrypto" -else: - CURL_LIB = "curl" - CRYPTO_LIB = "crypto" - -libraries = ["archive", "solv", "solvext", "reproc++", CURL_LIB, CRYPTO_LIB] -if sys.platform == "win32": - libraries += ["advapi32", "ole32", "shell32"] - -ext_modules = [ - Extension( - "mamba.mamba_api", - [ - "src/mamba/py_interface.cpp", - "src/core/activation.cpp", - "src/core/channel.cpp", - "src/core/context.cpp", - "src/core/fetch.cpp", - "src/core/history.cpp", - "src/core/match_spec.cpp", - "src/core/menuinst.cpp", - "src/core/output.cpp", - "src/core/package_handling.cpp", - "src/core/package_cache.cpp", - "src/core/package_paths.cpp", - "src/core/prefix_data.cpp", - "src/core/progress_bar.cpp", - "src/core/package_info.cpp", - "src/core/pool.cpp", - "src/core/query.cpp", - "src/core/repo.cpp", - "src/core/shell_init.cpp", - "src/core/solver.cpp", - "src/core/subdirdata.cpp", - "src/core/thread_utils.cpp", - "src/core/transaction.cpp", - "src/core/transaction_context.cpp", - "src/core/url.cpp", - "src/core/util.cpp", - "src/core/util_os.cpp", - "src/core/validate.cpp", - "src/core/version.cpp", - "src/core/link.cpp", - "src/core/virtual_packages.cpp", - ], - include_dirs=[ - get_pybind_include(), - get_pybind_include(user=True), - os.path.join(libsolv_prefix, "include"), - "include/", - "src/", - ], - library_dirs=library_dir, - extra_link_args=extra_link_args, - libraries=libraries, - language="c++", - ) -] - - -# As of Python 3.6, CCompiler has a `has_flag` method. -# cf http://bugs.python.org/issue26689 -def has_flag(compiler, flagname): - """Return a boolean indicating whether a flag name is supported on - the specified compiler. - """ - import tempfile - - with tempfile.NamedTemporaryFile("w", suffix=".cpp") as f: - f.write("int main (int argc, char **argv) { return 0; }") - try: - compiler.compile([f.name], extra_postargs=[flagname]) - except setuptools.distutils.errors.CompileError: - return False - return True - - -class BuildExt(build_ext): - """A custom build extension for adding compiler-specific options.""" - - c_opts = { - "msvc": ["/EHsc", "/std:c++17", "/Ox", "/DNOMINMAX"], - "unix": ["-std=c++17", "-O3"], - } - - def build_extensions(self): - ct = self.compiler.compiler_type - - if sys.platform == "darwin": - self.c_opts["unix"] += ["-stdlib=libc++", "-mmacosx-version-min=10.7"] - if not has_flag(self.compiler, "-std=c++17"): - self.c_opts["unix"].remove("-std=c++17") - self.c_opts["unix"].append("-std=c++1z") - - opts = self.c_opts.get(ct, []) - if ct == "unix": - opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version()) - if has_flag(self.compiler, "-fvisibility=hidden"): - opts.append("-fvisibility=hidden") - elif ct == "msvc": - opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version()) - - if sys.platform == "win32": - self.compiler.macros.append(("REPROCXX_SHARED", 1)) - self.compiler.macros.append(("GHC_WIN_DISABLE_WSTRING_STORAGE_TYPE", 1)) - self.compiler.macros.append(("MAMBA_ONLY", 1)) - - for ext in self.extensions: - ext.extra_compile_args = opts - build_ext.build_extensions(self) - - -data_files = [ - ("etc/profile.d", ["mamba/shell_templates/mamba.sh"]), -] -if sys.platform == "win32": - data_files.append(("condabin", ["mamba/shell_templates/mamba.bat"]),) - data_files.append( - ("Library/bin", ["mamba/shell_templates/win_redirect/mamba.bat"]), - ) - -setup( - name="mamba", - version=__version__, - author="Wolf Vollprecht", - author_email="wolf.vollprecht@quantstack.net", - url="https://github.com/mamba-org/mamba", - description="A fast, libsolv based solver and installer for conda packages.", - packages=["mamba"], - entry_points={"console_scripts": ["mamba = mamba.mamba:main"]}, - long_description="A (hopefully faster) reimplementation of the slow bits of conda.", - ext_modules=ext_modules, - install_requires=[], - extras_require={"test": ["pytest", "pytest-lazy-fixture"]}, - cmdclass={"build_ext": BuildExt}, - data_files=data_files, - include_package_data=True, - zip_safe=False, -) diff --git a/src/core/version.cpp b/src/core/version.cpp deleted file mode 100644 index cc5f85fcc3..0000000000 --- a/src/core/version.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019, QuantStack and Mamba Contributors -// -// Distributed under the terms of the BSD 3-Clause License. -// -// The full license is in the file LICENSE, distributed with this software. - -#include "mamba/core/version.hpp" - -const char mamba_version[] = MAMBA_VERSION_STRING; -int mamba_version_major = MAMBA_VERSION_MAJOR; -int mamba_version_minor = MAMBA_VERSION_MINOR; -int mamba_version_patch = MAMBA_VERSION_PATCH; - -std::string -version() -{ - return MAMBA_VERSION_STRING; -} diff --git a/src/thirdparty/termcolor.hpp b/src/thirdparty/termcolor.hpp deleted file mode 100644 index 2553034c66..0000000000 --- a/src/thirdparty/termcolor.hpp +++ /dev/null @@ -1,552 +0,0 @@ -//! -//! termcolor -//! ~~~~~~~~~ -//! -//! termcolor is a header-only c++ library for printing colored messages -//! to the terminal. Written just for fun with a help of the Force. -//! -//! :copyright: (c) 2013 by Ihor Kalnytskyi -//! :license: BSD, see LICENSE for details -//! - -#ifndef TERMCOLOR_HPP_ -#define TERMCOLOR_HPP_ - -// the following snippet of code detects the current OS and -// defines the appropriate macro that is used to wrap some -// platform specific things -#if defined(_WIN32) || defined(_WIN64) -#define TERMCOLOR_OS_WINDOWS -#elif defined(__APPLE__) -#define TERMCOLOR_OS_MACOS -#elif defined(__unix__) || defined(__unix) -#define TERMCOLOR_OS_LINUX -#else -#error unsupported platform -#endif - -// This headers provides the `isatty()`/`fileno()` functions, -// which are used for testing whether a standart stream refers -// to the terminal. As for Windows, we also need WinApi funcs -// for changing colors attributes of the terminal. -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) -#include -#elif defined(TERMCOLOR_OS_WINDOWS) -#include -#include -#endif - -#include -#include - -namespace termcolor -{ - // Forward declaration of the `_internal` namespace. - // All comments are below. - namespace _internal - { - inline int colorize_index(); - inline FILE* get_standard_stream(const std::ostream& stream); - inline bool is_colorized(std::ostream& stream); - inline bool is_atty(const std::ostream& stream); - -#if defined(TERMCOLOR_OS_WINDOWS) - inline void win_change_attributes(std::ostream& stream, - int foreground, - int background = -1); -#endif - } // namespace _internal - - inline std::ostream& colorize(std::ostream& stream) - { - stream.iword(_internal::colorize_index()) = 1L; - return stream; - } - - inline std::ostream& nocolorize(std::ostream& stream) - { - stream.iword(_internal::colorize_index()) = 0L; - return stream; - } - - inline std::ostream& reset(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[00m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, -1); -#endif - } - return stream; - } - - inline std::ostream& bold(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[1m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& dark(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[2m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& italic(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[3m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& underline(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[4m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& blink(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[5m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& reverse(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[7m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& concealed(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[8m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - - inline std::ostream& crossed(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[9m"; -#elif defined(TERMCOLOR_OS_WINDOWS) -#endif - } - return stream; - } - -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - - template - inline std::ostream& color(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { - char command[14]; - std::snprintf(command, 14, "\033[38;5;%dm", code); - stream << command; - } - - return stream; - } - - template - inline std::ostream& on_color(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { - char command[14]; - std::snprintf(command, 14, "\033[48;5;%dm", code); - stream << command; - } - - return stream; - } - -#endif // defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - - inline std::ostream& grey(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[30m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, - 0 // grey (black) - ); -#endif - } - return stream; - } - - inline std::ostream& red(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[31m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& green(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[32m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_GREEN); -#endif - } - return stream; - } - - inline std::ostream& yellow(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[33m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_GREEN | FOREGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& blue(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[34m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE); -#endif - } - return stream; - } - - inline std::ostream& magenta(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[35m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& cyan(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[36m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, FOREGROUND_BLUE | FOREGROUND_GREEN); -#endif - } - return stream; - } - - inline std::ostream& white(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[37m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, - FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& on_grey(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[40m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, - -1, - 0 // grey (black) - ); -#endif - } - return stream; - } - - inline std::ostream& on_red(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[41m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& on_green(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[42m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN); -#endif - } - return stream; - } - - inline std::ostream& on_yellow(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[43m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN | BACKGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& on_blue(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[44m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_BLUE); -#endif - } - return stream; - } - - inline std::ostream& on_magenta(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[45m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_BLUE | BACKGROUND_RED); -#endif - } - return stream; - } - - inline std::ostream& on_cyan(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[46m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes(stream, -1, BACKGROUND_GREEN | BACKGROUND_BLUE); -#endif - } - return stream; - } - - inline std::ostream& on_white(std::ostream& stream) - { - if (_internal::is_colorized(stream)) - { -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - stream << "\033[47m"; -#elif defined(TERMCOLOR_OS_WINDOWS) - _internal::win_change_attributes( - stream, -1, BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED); -#endif - } - - return stream; - } - - //! Since C++ hasn't a way to hide something in the header from - //! the outer access, I have to introduce this namespace which - //! is used for internal purpose and should't be access from - //! the user code. - namespace _internal - { - // An index to be used to access a private storage of I/O streams. See - // colorize / nocolorize I/O manipulators for details. Due to the fact - // that static variables ain't shared between translation units, inline - // function with local static variable is used to do the trick and share - // the variable value between translation units. - inline int colorize_index() - { - static int colorize_index = std::ios_base::xalloc(); - return colorize_index; - } - - //! Since C++ hasn't a true way to extract stream handler - //! from the a given `std::ostream` object, I have to write - //! this kind of hack. - inline FILE* get_standard_stream(const std::ostream& stream) - { - if (&stream == &std::cout) - return stdout; - else if ((&stream == &std::cerr) || (&stream == &std::clog)) - return stderr; - - return nullptr; - } - - // Say whether a given stream should be colorized or not. It's always - // true for ATTY streams and may be true for streams marked with - // colorize flag. - inline bool is_colorized(std::ostream& stream) - { - return is_atty(stream) || static_cast(stream.iword(colorize_index())); - } - - //! Test whether a given `std::ostream` object refers to - //! a terminal. - inline bool is_atty(const std::ostream& stream) - { - FILE* std_stream = get_standard_stream(stream); - - // Unfortunately, fileno() ends with segmentation fault - // if invalid file descriptor is passed. So we need to - // handle this case gracefully and assume it's not a tty - // if standard stream is not detected, and 0 is returned. - if (!std_stream) - return false; - -#if defined(TERMCOLOR_OS_MACOS) || defined(TERMCOLOR_OS_LINUX) - return ::isatty(fileno(std_stream)); -#elif defined(TERMCOLOR_OS_WINDOWS) - return ::_isatty(_fileno(std_stream)); -#endif - } - -#if defined(TERMCOLOR_OS_WINDOWS) - //! Change Windows Terminal colors attribute. If some - //! parameter is `-1` then attribute won't changed. - inline void win_change_attributes(std::ostream& stream, int foreground, int background) - { - // yeah, i know.. it's ugly, it's windows. - static WORD defaultAttributes = 0; - - // Windows doesn't have ANSI escape sequences and so we use special - // API to change Terminal output color. That means we can't - // manipulate colors by means of "std::stringstream" and hence - // should do nothing in this case. - if (!_internal::is_atty(stream)) - return; - - // get terminal handle - HANDLE hTerminal = INVALID_HANDLE_VALUE; - if (&stream == &std::cout) - hTerminal = GetStdHandle(STD_OUTPUT_HANDLE); - else if (&stream == &std::cerr) - hTerminal = GetStdHandle(STD_ERROR_HANDLE); - - // save default terminal attributes if it unsaved - if (!defaultAttributes) - { - CONSOLE_SCREEN_BUFFER_INFO info; - if (!GetConsoleScreenBufferInfo(hTerminal, &info)) - return; - defaultAttributes = info.wAttributes; - } - - // restore all default settings - if (foreground == -1 && background == -1) - { - SetConsoleTextAttribute(hTerminal, defaultAttributes); - return; - } - - // get current settings - CONSOLE_SCREEN_BUFFER_INFO info; - if (!GetConsoleScreenBufferInfo(hTerminal, &info)) - return; - - if (foreground != -1) - { - info.wAttributes &= ~(info.wAttributes & 0x0F); - info.wAttributes |= static_cast(foreground); - } - - if (background != -1) - { - info.wAttributes &= ~(info.wAttributes & 0xF0); - info.wAttributes |= static_cast(background); - } - - SetConsoleTextAttribute(hTerminal, info.wAttributes); - } -#endif // TERMCOLOR_OS_WINDOWS - - } // namespace _internal - -} // namespace termcolor - -#undef TERMCOLOR_OS_WINDOWS -#undef TERMCOLOR_OS_MACOS -#undef TERMCOLOR_OS_LINUX - -#endif // TERMCOLOR_HPP_