diff --git a/cpp_test.py b/cpp_test.py deleted file mode 100644 index d80148d0e..000000000 --- a/cpp_test.py +++ /dev/null @@ -1,127 +0,0 @@ -import cppimport - -from multiprocessing.pool import Pool as MPool - -import bz2 -from urllib import request -import sys -import json -import os -import time -from datetime import datetime, timedelta - -from conda.core.subdir_data import SubdirData -from conda.models.channel import Channel -from conda.core.link import UnlinkLinkTransaction, PrefixSetup -from conda.cli.install import handle_txn -from conda.core.prefix_data import PrefixData -from conda.resolve import MatchSpec - -api = cppimport.imp('interface') -# import interface as api - -prefix = '/home/wolfv/miniconda3/' -channels = ['conda-forge', 'r', 'anaconda'] -# what_to_get = ["opencv ==3.4.2"] -# what_to_get = ["conda-build"] -what_to_get = ["xtensor-r", "r-base ==3.5.1"] -url_template = 'https://conda.anaconda.org/{}/linux-64/repodata.json.bz2' - - -installed = sorted(PrefixData(prefix, pip_interop_enabled=True).iter_records(), - key=lambda x: x.name) - - -def ensure_dir(file_path): - directory = os.path.dirname(file_path) - if not os.path.exists(directory): - os.makedirs(directory) - -ensure_dir("./__cache__/") - -def download(args): - channel, url, idx = args - print("Checking: ", args) - cache_file = os.path.join('./__cache__/', channel + '.json') - - has_cache = os.path.isfile(cache_file) - if has_cache: - print(datetime.fromtimestamp(os.path.getmtime(cache_file))) - if datetime.now() - datetime.fromtimestamp(os.path.getmtime(cache_file)) > timedelta(hours=24): - print("Cache invalidated...") - has_cache = False - - if has_cache == False: - req = request.urlopen(url) - print("Downloading ", cache_file) - with open(cache_file, 'w') as ftmp: - ftmp.write(bz2.decompress(req.read()).decode('utf-8')) - - return True - -def download_all(channels): - global repos - repos = {channel: {} for channel in channels} - - channel_args = [(channel, url_template.format(channel), i) for i, channel in enumerate(channels)] - mpool = MPool(8) - result = mpool.map(download, channel_args) - return True - -repos = download_all(channels) - -installed_list_json = [] -for prec in installed: - installed_list_json.append(prec.dist_fields_dump()) - -with open('./installed.json', 'w') as fo: - json.dump(installed_list_json, fo) - -if os.path.isfile('./installed.json'): - print("Using installed.json from this folder") - installed_json = './installed.json' -else: - print("Couldn't find installed.json. Generate with `conda list --json > installed.json` from the command line.") - installed_json = "" - -channel_json = [(c, './__cache__/{}.json'.format(c)) for c in channels] - -to_link, to_unlink = api.solve(channel_json, installed_json, what_to_get) - -print(to_link, to_unlink) - -channel_data = {} -for c in channels: - chan = Channel.from_channel_name(c) - chan.platform = 'linux-64' - channel_data[c] = SubdirData(chan).load() - -print(channel_data) - -to_unlink_records = [] -to_link_records = [] - -for c, pkg in to_unlink: - for p in installed: - if p['name'] == pkg: - to_unlink_records.append(p) - -for c, pkg, json_ in to_link: - for p in channel_data[c]._package_records: - if p['fn'] == pkg: - to_link_records.append(p) - -pref_setup = PrefixSetup( - target_prefix = prefix, - unlink_precs = to_unlink_records, - link_precs = to_link_records, - remove_specs = [], - update_specs = [MatchSpec(spec) for spec in what_to_get] -) - -conda_transaction = UnlinkLinkTransaction(pref_setup) - -class Args(): - name = None - -handle_txn(conda_transaction, prefix, Args(), True) \ No newline at end of file diff --git a/include/json_helper.hpp b/include/json_helper.hpp index 9071f19fe..f86454d32 100644 --- a/include/json_helper.hpp +++ b/include/json_helper.hpp @@ -1,7 +1,10 @@ -#include "thirdparty/simdjson/simdjson.h" +#ifndef MAMBA_JSON_HELPER_HPP +#define MAMBA_JSON_HELPER_HPP #include +#include "thirdparty/simdjson/simdjson.h" + void compute_dump(ParsedJson::iterator& pjh, std::ostream& os) { if (pjh.is_object()) @@ -44,4 +47,6 @@ void compute_dump(ParsedJson::iterator& pjh, std::ostream& os) { pjh.print(os); // just print the lone value } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/include/parsing.cpp b/include/parsing.cpp index d289d4f93..cc3984a61 100644 --- a/include/parsing.cpp +++ b/include/parsing.cpp @@ -1,6 +1,3 @@ -#ifndef MAMBA_PARSING -#define MAMBA_PARSING - #include "parsing.hpp" #include @@ -291,5 +288,3 @@ Id parse_to_relation(const std::string_view& dep, Pool* pool) { return id; } } - -#endif diff --git a/include/parsing.hpp b/include/parsing.hpp index 1a88ef201..85eed1da4 100644 --- a/include/parsing.hpp +++ b/include/parsing.hpp @@ -1,5 +1,5 @@ -#ifndef MAMBA_PARSING -#define MAMBA_PARSING +#ifndef MAMBA_PARSING_HPP +#define MAMBA_PARSING_HPP #include #include diff --git a/include/solver.hpp b/include/solver.hpp index bbbc4a2ae..e2c4536e7 100644 --- a/include/solver.hpp +++ b/include/solver.hpp @@ -1,3 +1,6 @@ +#ifndef MAMBA_SOLVER_HPP +#define MAMBA_SOLVER_HPP + #include #include @@ -6,4 +9,6 @@ std::tuple>, solve(std::vector> repos, std::string installed, std::vector jobs, - bool strict_priority); \ No newline at end of file + bool strict_priority); + +#endif \ No newline at end of file