mirror of
https://github.com/RubyMetric/chsrc
synced 2025-07-16 20:27:27 +08:00
Rewrite Anaconda
This commit is contained in:
parent
2aef111e74
commit
65ca09e332
@ -135,7 +135,7 @@
|
||||
#include "recipe/ware/Guix.c"
|
||||
#include "recipe/ware/Flathub.c"
|
||||
#include "recipe/ware/Docker-Hub.c"
|
||||
#include "recipe/ware/Anaconda.c"
|
||||
#include "recipe/ware/Anaconda/Anaconda.c"
|
||||
|
||||
#include "recipe/menu.c"
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Yangmoooo <yangmoooo@outlook.com>
|
||||
* | yongxiang <1926885268@qq.com>
|
||||
* |
|
||||
* Created On : <2023-09-10>
|
||||
* Last Modified : <2024-12-08>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @update 2024-12-08
|
||||
* @note 这些链接将会在setsrc函数中补充完整
|
||||
*/
|
||||
static Source_t wr_anaconda_sources[] =
|
||||
{
|
||||
{&UpstreamProvider, "https://repo.anaconda.com/"},
|
||||
{&Nju, "https://mirror.nju.edu.cn/anaconda/"},
|
||||
{&Bjtu, "https://mirror.bjtu.edu.cn/anaconda/"},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/anaconda/"},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn/anaconda/"},
|
||||
{&Zju, "https://mirrors.zju.edu.cn/anaconda/"},
|
||||
{&Sjtug_Zhiyuan, "https://mirror.sjtu.edu.cn/anaconda"},
|
||||
{&Pku, "https://mirrors.pku.edu.cn/anaconda/"},
|
||||
{&NJTech, "https://mirrors.njtech.edu.cn/anaconda/"},
|
||||
};
|
||||
def_sources_n(wr_anaconda);
|
||||
|
||||
|
||||
void
|
||||
wr_anaconda_setsrc (char *option)
|
||||
{
|
||||
chsrc_yield_source_and_confirm (wr_anaconda);
|
||||
|
||||
char *main = xy_2strjoin (source.url, "pkgs/main");
|
||||
char *r = xy_2strjoin (source.url, "pkgs/r");
|
||||
char *msys2 = xy_2strjoin (source.url, "pkgs/msys2");
|
||||
char *cloud = xy_2strjoin (source.url, "cloud");
|
||||
|
||||
char *file = xy_strjoin (22,
|
||||
"channels:\n - defaults\n"
|
||||
"show_channel_urls: true\ndefault_channels:"
|
||||
"\n - ", main,
|
||||
"\n - ", r,
|
||||
"\n - ", msys2,
|
||||
"\ncustom_channels:\n"
|
||||
" conda-forge: ", cloud,
|
||||
"\n msys2: ", cloud,
|
||||
"\n bioconda: ", cloud,
|
||||
"\n menpo: ", cloud,
|
||||
"\n pytorch: ", cloud,
|
||||
"\n pytorch-lts: ", cloud,
|
||||
"\n simpleitk: ", cloud,
|
||||
"\n deepmodeling: ", cloud);
|
||||
|
||||
|
||||
// TODO: 待确认 windows 上也是这里吗?
|
||||
char *config = xy_2strjoin (xy_os_home, "/.condarc");
|
||||
|
||||
if (xy_on_windows)
|
||||
{
|
||||
bool exist = chsrc_check_program ("conda");
|
||||
if (!exist)
|
||||
{
|
||||
chsrc_error ("未找到 conda 命令,请检查是否存在");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
chsrc_run ("conda config --set show_channel_urls yes", RunOpt_Default);
|
||||
}
|
||||
|
||||
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
|
||||
println (file);
|
||||
|
||||
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");
|
||||
|
||||
chsrc_determine_chgtype (ChgType_SemiAuto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
def_target_s (wr_anaconda);
|
96
src/recipe/ware/Anaconda/Anaconda.c
Normal file
96
src/recipe/ware/Anaconda/Anaconda.c
Normal file
@ -0,0 +1,96 @@
|
||||
/** ------------------------------------------------------------
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
* -------------------------------------------------------------
|
||||
* File Authors : Aoran Zeng <ccmywish@qq.com>
|
||||
* Contributors : Yangmoooo <yangmoooo@outlook.com>
|
||||
* | yongxiang <1926885268@qq.com>
|
||||
* |
|
||||
* Created On : <2023-09-10>
|
||||
* Last Modified : <2025-07-14>
|
||||
* ------------------------------------------------------------*/
|
||||
|
||||
#include "rawstr4c.h"
|
||||
|
||||
/**
|
||||
* @update 2025-07-14
|
||||
* @note 这些链接将会在setsrc函数中补充完整
|
||||
*/
|
||||
static Source_t wr_anaconda_sources[] =
|
||||
{
|
||||
{&UpstreamProvider, "https://repo.anaconda.com", NULL},
|
||||
{&Tuna, "https://mirrors.tuna.tsinghua.edu.cn", NULL},
|
||||
{&Bjtu, "https://mirror.bjtu.edu.cn", NULL},
|
||||
{&Nju, "https://mirror.nju.edu.cn", NULL},
|
||||
{&Bfsu, "https://mirrors.bfsu.edu.cn", NULL},
|
||||
{&Zju, "https://mirrors.zju.edu.cn", NULL},
|
||||
{&Pku, "https://mirrors.pku.edu.cn", NULL},
|
||||
{&NJTech, "https://mirrors.njtech.edu.cn", NULL},
|
||||
{&Ustc, "https://mirrors.ustc.edu.cn", NULL},
|
||||
{&Sjtug_Siyuan, "https://mirror.sjtu.edu.cn", NULL},
|
||||
{&Lzuoss, "https://mirror.lzu.edu.cn", NULL}
|
||||
};
|
||||
def_sources_n(wr_anaconda);
|
||||
|
||||
|
||||
void
|
||||
wr_anaconda_getsrc (char *option)
|
||||
{
|
||||
chsrc_view_file ("~/.condarc");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @consult https://help.mirrors.cernet.edu.cn/anaconda/
|
||||
*/
|
||||
void
|
||||
wr_anaconda_setsrc (char *option)
|
||||
{
|
||||
chsrc_yield_source_and_confirm (wr_anaconda);
|
||||
|
||||
char *w = xy_str_gsub (_rawstr4c_condarc, "@1@", source.url);
|
||||
|
||||
/* Windows 也是在这里 */
|
||||
char *configfile = xy_2strjoin (xy_os_home, "/.condarc");
|
||||
|
||||
if (xy_on_windows)
|
||||
{
|
||||
if (xy_file_exist (configfile))
|
||||
{
|
||||
chsrc_note2 ("配置文件不存在,将使用 conda 命令创建");
|
||||
bool conda_exist = chsrc_check_program ("conda");
|
||||
if (!conda_exist)
|
||||
{
|
||||
chsrc_error ("未找到 conda 命令,请检查是否存在");
|
||||
exit (Exit_UserCause);
|
||||
}
|
||||
chsrc_run ("conda config --set show_channel_urls yes", RunOpt_Default);
|
||||
}
|
||||
}
|
||||
|
||||
chsrc_note2 (xy_strjoin (3, "请向 ", configfile, " 中手动添加:"));
|
||||
println (w);
|
||||
|
||||
chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引");
|
||||
|
||||
chsrc_note2 ("若还需要添加其他第三方源, 可参考: https://help.mirrors.cernet.edu.cn/anaconda/");
|
||||
|
||||
chsrc_determine_chgtype (ChgType_SemiAuto);
|
||||
chsrc_conclude (&source);
|
||||
}
|
||||
|
||||
|
||||
Feature_t
|
||||
wr_anaconda_feat (char *option)
|
||||
{
|
||||
Feature_t f = {0};
|
||||
|
||||
f.can_get = true;
|
||||
f.can_reset = false;
|
||||
|
||||
f.can_english = false;
|
||||
f.can_user_define = false;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
def_target_gsf (wr_anaconda);
|
10
src/recipe/ware/Anaconda/rawstr4c.h
Normal file
10
src/recipe/ware/Anaconda/rawstr4c.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Generated by rawstr4c
|
||||
*
|
||||
* Date: 2025-07-14T03:31:57.086531+08:00
|
||||
*/
|
||||
|
||||
char _rawstr4c_condarc[] = "\143\150\141\156\156\145\154\163\072\012\040\040\055\040\144\145\146\141\165\154\164\163\012\163\150\157\167\137\143\150\141\156\156\145\154\137\165\162\154\163\072\040\164\162\165\145\012\144\145\146\141\165\154\164\137\143\150\141\156\156\145\154\163\072\012\040\040\055\040\100\061\100\057\141\156\141\143\157\156\144\141\057\160\153\147\163\057\155\141\151\156\012\040\040\055\040\100\061\100\057\141\156\141\143\157\156\144\141\057\160\153\147\163\057\162\012\040\040\055\040\100\061\100\057\141\156\141\143\157\156\144\141\057\160\153\147\163\057\155\163\171\163\062\012\143\165\163\164\157\155\137\143\150\141\156\156\145\154\163\072\012\040\040\143\157\156\144\141\055\146\157\162\147\145\072\040\100\061\100\057\141\156\141\143\157\156\144\141\057\143\154\157\165\144\012\040\040\160\171\164\157\162\143\150\072\040\100\061\100\057\141\156\141\143\157\156\144\141\057\143\154\157\165\144\012";
|
||||
|
33
src/recipe/ware/Anaconda/rawstr4c.md
Normal file
33
src/recipe/ware/Anaconda/rawstr4c.md
Normal file
@ -0,0 +1,33 @@
|
||||
<!-- -----------------------------------------------------------
|
||||
! SPDX-License-Identifier: GPL-3.0-or-later
|
||||
! -------------------------------------------------------------
|
||||
! Config Type : rawstr4c (Markdown)
|
||||
! Config Authors: Aoran Zeng <ccmywish@qq.com>
|
||||
! Contributors : Nil Null <nil@null.org>
|
||||
! Created On : <2025-07-14>
|
||||
! Last Modified : <2025-07-14>
|
||||
! ---------------------------------------------------------- -->
|
||||
|
||||
# rawstr4c input
|
||||
|
||||
- output = `:global-variable-only-header`
|
||||
- translate = `:oct`
|
||||
|
||||
## Anaconda
|
||||
|
||||
- prefix = `RAWSTR_wr_anaconda`
|
||||
- keep-postfix = `false`
|
||||
- name = `condarc`
|
||||
|
||||
```yaml
|
||||
channels:
|
||||
- defaults
|
||||
show_channel_urls: true
|
||||
default_channels:
|
||||
- @1@/anaconda/pkgs/main
|
||||
- @1@/anaconda/pkgs/r
|
||||
- @1@/anaconda/pkgs/msys2
|
||||
custom_channels:
|
||||
conda-forge: @1@/anaconda/cloud
|
||||
pytorch: @1@/anaconda/cloud
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user