Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pip #196

Merged
merged 2 commits into from
Mar 6, 2023
Merged

Pip #196

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions install_windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ function Test-Command( [string] $CommandName ) {
(Get-Command $CommandName -ErrorAction SilentlyContinue) -ne $null
}

foreach ($p_cmd in ("python3","python")) {
cmd /c $p_cmd --version | Out-Null
foreach ($p_cmd in ("python3", "python", "py")) {
cmd /c $p_cmd --version | findstr "Python" | Out-Null
if (!$?) { continue }
$RTT_PYTHON = $p_cmd
break
}

if (!(Test-Command $RTT_PYTHON)) {
cmd /c $RTT_PYTHON --version | findstr "Python" | Out-Null
if (!$?) {
echo "Python not installed. Will install python 3.11.2."
echo "Downloading Python."
wget -O Python_setup.exe https://www.python.org/ftp/python/3.11.2/python-3.11.2.exe
Expand All @@ -21,33 +22,43 @@ if (!(Test-Command $RTT_PYTHON)) {
cmd /c Python_setup.exe /quiet TargetDir=D:\Progrem\Python311 InstallAllUsers=1 PrependPath=1 Include_test=0
}
else {
cmd /c Python_setup.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
cmd /c Python_setup.exe /quiet PrependPath=1 Include_test=0
}
echo "Install Python done. please close the current terminal and run this script again."
exit
}


if (!(Test-Command git)) {
echo "Git not installed. Will install Git."
echo "Installing git."
winget install --id Git.Git -e --source winget
}

cmd /c $RTT_PYTHON -m pip list | Out-Null
$PIP_SOURCE = "https://pypi.org/simple"
$PIP_HOST = "pypi.org"
if ($args[0] -eq "--gitee") {
$PIP_SOURCE = "http://mirrors.aliyun.com/pypi/simple"
$PIP_HOST = "mirrors.aliyun.com"
}

cmd /c $RTT_PYTHON -m pip list -i $PIP_SOURCE --trusted-host $PIP_HOST | Out-Null
if (!$?) {
echo "Installing pip."
cmd /c $RTT_PYTHON -m ensurepip --upgrade
}

cmd /c $RTT_PYTHON -m pip install --upgrade pip | Out-Null
cmd /c $RTT_PYTHON -m pip install --upgrade pip -i $PIP_SOURCE --trusted-host $PIP_HOST | Out-Null

if (!(Test-Command scons)) {
echo "Installing scons."
cmd /c $RTT_PYTHON -m pip install scons
cmd /c $RTT_PYTHON -m pip install scons -i $PIP_SOURCE --trusted-host $PIP_HOST
}

cmd /c $RTT_PYTHON -m pip list | findstr "requests" | Out-Null
cmd /c $RTT_PYTHON -m pip list -i $PIP_SOURCE --trusted-host $PIP_HOST | findstr "requests" | Out-Null
if (!$?) {
echo "Installing requests."
cmd /c $RTT_PYTHON -m pip install requests
cmd /c $RTT_PYTHON -m pip install requests -i $PIP_SOURCE --trusted-host $PIP_HOST
}

$url="https://raw.githubusercontent.com/RT-Thread/env/master/touch_env.ps1"
Expand Down
2 changes: 1 addition & 1 deletion touch_env.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (!(Test-Path -Path $env_dir)) {
mkdir $env_dir\packages | Out-Null
mkdir $env_dir\tools | Out-Null
git clone $package_url $env_dir/packages/packages
echo 'source "$PKGS_DIR/packages/Kconfig"' > $env_dir/packages/Kconfig
echo 'source "$PKGS_DIR/packages/Kconfig"' | Out-File -FilePath $env_dir/packages/Kconfig -Encoding ASCII
git clone $ENV_URL $env_dir/tools/scripts
echo '$env:path="$HOME\.env\tools\scripts;$env:path"' > $env_dir/env.ps1
}