Updated 'checkout-deps' to check for 'pip'/'pip3' prior to installing 'AMBuild'
This commit is contained in:
parent
37355f9c57
commit
9bbbf60268
53
tools/checkout-deps.ps1
vendored
53
tools/checkout-deps.ps1
vendored
@ -32,7 +32,7 @@ param(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
Function Checkout-Repo
|
Function Get-Repository
|
||||||
{
|
{
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory=$true)][string]$Name,
|
[Parameter(Mandatory=$true)][string]$Name,
|
||||||
@ -74,7 +74,7 @@ if (-not (Test-Path "sourcemod" -PathType Container))
|
|||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkout-Repo -Name "mmsource-1.10" -Branch "1.10-dev" -Repo "https://github.com/alliedmodders/metamod-source.git"
|
Get-Repository -Name "mmsource-1.10" -Branch "1.10-dev" -Repo "https://github.com/alliedmodders/metamod-source.git"
|
||||||
|
|
||||||
if (-not (Test-Path "hl2sdk-proxy-repo" -PathType Container))
|
if (-not (Test-Path "hl2sdk-proxy-repo" -PathType Container))
|
||||||
{
|
{
|
||||||
@ -87,12 +87,49 @@ else
|
|||||||
Set-Location ..
|
Set-Location ..
|
||||||
}
|
}
|
||||||
|
|
||||||
$SDKS | % {
|
$SDKS | ForEach-Object {
|
||||||
Checkout-Repo -Name "hl2sdk-$_" -Branch $_ -Repo "hl2sdk-proxy-repo" "https://github.com/alliedmodders/hl2sdk.git"
|
Get-Repository -Name "hl2sdk-$_" -Branch $_ -Repo "hl2sdk-proxy-repo" "https://github.com/alliedmodders/hl2sdk.git"
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkout-Repo -Name "ambuild" -Branch "master" -Repo "https://github.com/alliedmodders/ambuild.git"
|
# Find a suitable installation of Python
|
||||||
Set-Location ambuild
|
$PYTHON_CMD = Get-Command 'python' -ErrorAction SilentlyContinue
|
||||||
& python setup.py install
|
if ($NULL -eq $PYTHON_CMD)
|
||||||
|
{
|
||||||
|
$PYTHON_CMD = Get-Command 'python3' -ErrorAction SilentlyContinue
|
||||||
|
if ($NULL -eq $PYTHON_CMD)
|
||||||
|
{
|
||||||
|
$PYTHON_CMD = Get-Command 'py' -ErrorAction SilentlyContinue
|
||||||
|
if ($NULL -eq $PYTHON_CMD)
|
||||||
|
{
|
||||||
|
Write-Error 'No suitable installation of Python detected'
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set-Location ..
|
$PYTHON_CMD = $PYTHON_CMD.Source # Convert the result into a string path.
|
||||||
|
|
||||||
|
& $PYTHON_CMD -c 'import ambuild2' 2>&1 1>$NULL
|
||||||
|
if ($LastExitCode -eq 1)
|
||||||
|
{
|
||||||
|
Write-Host -ForegroundColor Red "AMBuild is required to build SourceMod"
|
||||||
|
|
||||||
|
# Ensure PIP is installed, otherwise, install it.
|
||||||
|
& $PYTHON_CMD -m pip --version 2>&1 1>$NULL # We use PIP's '--version' as it's the least verbose.
|
||||||
|
if ($LastExitCode -eq 1) {
|
||||||
|
Write-Host -ForegroundColor Red 'The detected Python installation does not have PIP'
|
||||||
|
Write-Host 'Installing the latest version of PIP available (VIA "get-pip.py")'
|
||||||
|
|
||||||
|
$GET_PIP = Join-Path $(Resolve-Path './') 'get-pip.py'
|
||||||
|
Invoke-WebRequest -Uri "https://bootstrap.pypa.io/get-pip.py" -OutFile $GET_PIP
|
||||||
|
|
||||||
|
& $PYTHON_CMD $GET_PIP
|
||||||
|
if ($LastExitCode -eq 1) {
|
||||||
|
Write-Error 'Installation of PIP has failed'
|
||||||
|
Exit 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Get-Repository -Name "ambuild" -Branch "master" -Repo "https://github.com/alliedmodders/ambuild.git"
|
||||||
|
& $PYTHON_CMD -m pip install ./ambuild
|
||||||
|
}
|
||||||
|
48
tools/checkout-deps.sh
vendored
48
tools/checkout-deps.sh
vendored
@ -110,11 +110,11 @@ checkout
|
|||||||
|
|
||||||
if [ -z ${sdks+x} ]; then
|
if [ -z ${sdks+x} ]; then
|
||||||
sdks=( csgo hl2dm nucleardawn l4d2 dods l4d css tf2 insurgency sdk2013 doi )
|
sdks=( csgo hl2dm nucleardawn l4d2 dods l4d css tf2 insurgency sdk2013 doi )
|
||||||
|
|
||||||
if [ $ismac -eq 0 ]; then
|
if [ $ismac -eq 0 ]; then
|
||||||
# Add these SDKs for Windows or Linux
|
# Add these SDKs for Windows or Linux
|
||||||
sdks+=( orangebox blade episode1 bms )
|
sdks+=( orangebox blade episode1 bms )
|
||||||
|
|
||||||
# Add more SDKs for Windows only
|
# Add more SDKs for Windows only
|
||||||
if [ $iswin -eq 1 ]; then
|
if [ $iswin -eq 1 ]; then
|
||||||
sdks+=( darkm swarm bgt eye contagion )
|
sdks+=( darkm swarm bgt eye contagion )
|
||||||
@ -140,20 +140,54 @@ do
|
|||||||
checkout
|
checkout
|
||||||
done
|
done
|
||||||
|
|
||||||
`python -c "import ambuild2"` || `python3 -c "import ambuild2"`
|
python_cmd=`command -v python`
|
||||||
|
if [ -z "$python_cmd" ]; then
|
||||||
|
python_cmd=`command -v python3`
|
||||||
|
|
||||||
|
if [ -z "$python_cmd" ]; then
|
||||||
|
echo "No suitable installation of Python detected"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
`$python_cmd -c "import ambuild2"` 2>&1 1>/dev/null
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "AMBuild is required to build SourceMod"
|
||||||
|
|
||||||
|
`$python_cmd -m pip --version` 2>&1 1>/dev/null
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "The detected Python installation does not have PIP"
|
||||||
|
echo "Installing the latest version of PIP available (VIA \"get-pip.py\")"
|
||||||
|
|
||||||
|
get_pip="./get-pip.py"
|
||||||
|
get_pip_url="https://bootstrap.pypa.io/get-pip.py"
|
||||||
|
|
||||||
|
if [ `command -v wget` ]; then
|
||||||
|
wget $get_pip_url -O $get_pip
|
||||||
|
elif [ `command -v curl` ]; then
|
||||||
|
curl -o $get_pip $get_pip_url
|
||||||
|
else
|
||||||
|
echo "Failed to locate wget or curl. Install one of these programs to download 'get-pip.py'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
$python_cmd $get_pip
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
echo "Installation of PIP has failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
repo="https://github.com/alliedmodders/ambuild"
|
repo="https://github.com/alliedmodders/ambuild"
|
||||||
origin=
|
origin=
|
||||||
branch=master
|
branch=master
|
||||||
name=ambuild
|
name=ambuild
|
||||||
checkout
|
checkout
|
||||||
|
|
||||||
cd ambuild
|
|
||||||
if [ $iswin -eq 1 ] || [ $ismac -eq 1 ]; then
|
if [ $iswin -eq 1 ] || [ $ismac -eq 1 ]; then
|
||||||
python setup.py install
|
$python_cmd -m pip install ./ambuild
|
||||||
else
|
else
|
||||||
python setup.py build
|
|
||||||
echo "Installing AMBuild at the user level. Location can be: ~/.local/bin"
|
echo "Installing AMBuild at the user level. Location can be: ~/.local/bin"
|
||||||
python setup.py install --user
|
$python_cmd -m pip install --user ./ambuild
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user