install.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Copyright (c) 2019, QuantStack and Mamba Contributors
  2. //
  3. // Distributed under the terms of the BSD 3-Clause License.
  4. //
  5. // The full license is in the file LICENSE, distributed with this software.
  6. #ifndef MAMBA_API_INSTALL_HPP
  7. #define MAMBA_API_INSTALL_HPP
  8. #include <string>
  9. #include <vector>
  10. #include <nlohmann/json.hpp>
  11. #include <solv/solver.h>
  12. #include <yaml-cpp/yaml.h>
  13. #include "mamba/core/context.hpp"
  14. #include "mamba/core/mamba_fs.hpp"
  15. #include "mamba/core/package_cache.hpp"
  16. #include "mamba/core/package_info.hpp"
  17. #include "mamba/core/pool.hpp"
  18. #include "mamba/core/repo.hpp"
  19. #include "mamba/core/solver.hpp"
  20. namespace mamba
  21. {
  22. void install();
  23. void install_specs(
  24. const std::vector<std::string>& specs,
  25. bool create_env = false,
  26. int solver_flag = SOLVER_INSTALL,
  27. int is_retry = 0
  28. );
  29. void install_explicit_specs(const std::vector<std::string>& specs, bool create_env = false);
  30. void install_lockfile_specs(
  31. const std::string& lockfile_specs,
  32. const std::vector<std::string>& categories,
  33. bool create_env = false
  34. );
  35. namespace detail
  36. {
  37. void create_target_directory(const fs::u8path prefix);
  38. void create_empty_target(const fs::u8path& prefix);
  39. void file_specs_hook(std::vector<std::string>& file_specs);
  40. void channels_hook(std::vector<std::string>& channels);
  41. bool download_explicit(const std::vector<PackageInfo>& pkgs, MultiPackageCache& pkg_caches);
  42. struct other_pkg_mgr_spec
  43. {
  44. std::string pkg_mgr;
  45. std::vector<std::string> deps;
  46. std::string cwd;
  47. };
  48. bool operator==(const other_pkg_mgr_spec& s1, const other_pkg_mgr_spec& s2);
  49. struct yaml_file_contents
  50. {
  51. std::string name;
  52. std::vector<std::string> dependencies, channels;
  53. std::vector<other_pkg_mgr_spec> others_pkg_mgrs_specs;
  54. };
  55. bool eval_selector(const std::string& selector);
  56. yaml_file_contents read_yaml_file(fs::u8path yaml_file);
  57. std::tuple<std::vector<PackageInfo>, std::vector<MatchSpec>>
  58. parse_urls_to_package_info(const std::vector<std::string>& urls);
  59. inline void to_json(nlohmann::json&, const other_pkg_mgr_spec&)
  60. {
  61. }
  62. }
  63. }
  64. namespace YAML
  65. {
  66. template <>
  67. struct convert<mamba::detail::other_pkg_mgr_spec>
  68. {
  69. static Node encode(const mamba::detail::other_pkg_mgr_spec& /*rhs*/)
  70. {
  71. return Node();
  72. }
  73. static bool decode(const Node& /*node*/, mamba::detail::other_pkg_mgr_spec& /*rhs*/)
  74. {
  75. return true;
  76. }
  77. };
  78. }
  79. #endif