-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathnt.ps1
54 lines (44 loc) · 1.46 KB
/
nt.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# author: Chen Zhang
# usage:
# * compiling for python 3.9 | 3.10 | 3.11 | 3.12 with documents embedded
# PS> nt.ps1
# * compiling for python 3.11 without documents embedded
# PS> nt.ps1 '311' -add_doc $FALSE
param([Array]$envs=('39', '310', '311', '312'), [String]$root=$PWD.ToString(),
[Bool]$add_doc=$TRUE)
$dist_dir = $root+'/dist'
$doc_dir = $root+'/docs'
function activate_conda_hook() {
C:\ProgramData\anaconda3\shell\condabin\conda-hook.ps1
conda activate 'C:\ProgramData\anaconda3'
}
function single_compiler([String]$env) {
$env1 = 'py'+$env
conda activate $env1
Write-Output 'Compiling in environment:'
python --version
$installed = pip list | Where-Object {$_ -Match 'informatics'}
if ($installed) {pip uninstall informatics --yes}
if (!$add_doc) {
Set-Location $doc_dir
make clean
Set-Location $root
}
python -m build -w -Cbuild_ext
if ($add_doc) {
Set-Location $dist_dir
$whl1 = Get-ChildItem -Name | Where-Object {$_ -Match 'win_amd64.whl$'} | Where-Object {$_ -Match 'cp'+$env}
if ($whl1) {pip install $whl1}
Set-Location $doc_dir
(make clean)-and(make html)
Set-Location $root
python -m build -w -Cbuild_ext
pip uninstall informatics --yes
}
conda deactivate
}
function batch_compiler([Array]$arr) {
activate_conda_hook
foreach ($env in $arr) {single_compiler $env}
}
batch_compiler $envs