mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Make files - fallback to python(3.8) from PATH if .venv doesn't exist (#4863)
This commit is contained in:
parent
1ff976b3d0
commit
9bb61ba882
12
Makefile
12
Makefile
@ -4,6 +4,12 @@ PYTHON ?= python3.8
|
|||||||
|
|
||||||
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
ifneq ($(wildcard $(ROOT_DIR)/.venv/.),)
|
||||||
|
VENV_PYTHON = $(ROOT_DIR)/.venv/bin/python
|
||||||
|
else
|
||||||
|
VENV_PYTHON = $(PYTHON)
|
||||||
|
endif
|
||||||
|
|
||||||
define HELP_BODY
|
define HELP_BODY
|
||||||
Usage:
|
Usage:
|
||||||
make <command>
|
make <command>
|
||||||
@ -25,11 +31,11 @@ export HELP_BODY
|
|||||||
|
|
||||||
# Python Code Style
|
# Python Code Style
|
||||||
reformat:
|
reformat:
|
||||||
$(PYTHON) -m black $(ROOT_DIR)
|
$(VENV_PYTHON) -m black $(ROOT_DIR)
|
||||||
stylecheck:
|
stylecheck:
|
||||||
$(PYTHON) -m black --check $(ROOT_DIR)
|
$(VENV_PYTHON) -m black --check $(ROOT_DIR)
|
||||||
stylediff:
|
stylediff:
|
||||||
$(PYTHON) -m black --check --diff $(ROOT_DIR)
|
$(VENV_PYTHON) -m black --check --diff $(ROOT_DIR)
|
||||||
|
|
||||||
# Translations
|
# Translations
|
||||||
gettext:
|
gettext:
|
||||||
|
|||||||
12
make.bat
12
make.bat
@ -2,18 +2,24 @@
|
|||||||
|
|
||||||
if [%1] == [] goto help
|
if [%1] == [] goto help
|
||||||
|
|
||||||
|
if exist "%~dp0.venv\" (
|
||||||
|
set "VENV_PYTHON=%~dp0.venv\Scripts\python"
|
||||||
|
) else (
|
||||||
|
set VENV_PYTHON=python
|
||||||
|
)
|
||||||
|
|
||||||
goto %1
|
goto %1
|
||||||
|
|
||||||
:reformat
|
:reformat
|
||||||
"%~dp0.venv\Scripts\black" "%~dp0."
|
"%VENV_PYTHON%" -m black "%~dp0."
|
||||||
goto:eof
|
goto:eof
|
||||||
|
|
||||||
:stylecheck
|
:stylecheck
|
||||||
"%~dp0.venv\Scripts\black" --check "%~dp0."
|
"%VENV_PYTHON%" -m black --check "%~dp0."
|
||||||
goto:eof
|
goto:eof
|
||||||
|
|
||||||
:stylediff
|
:stylediff
|
||||||
"%~dp0.venv\Scripts\black" --check --diff "%~dp0."
|
"%VENV_PYTHON%" -m black --check --diff "%~dp0."
|
||||||
goto:eof
|
goto:eof
|
||||||
|
|
||||||
:newenv
|
:newenv
|
||||||
|
|||||||
18
make.ps1
18
make.ps1
@ -41,33 +41,39 @@ param (
|
|||||||
)
|
)
|
||||||
|
|
||||||
function reformat() {
|
function reformat() {
|
||||||
black $PSScriptRoot
|
& $script:venvPython -m black $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
function stylecheck() {
|
function stylecheck() {
|
||||||
black --check $PSScriptRoot
|
& $script:venvPython -m black --check $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
function stylediff() {
|
function stylediff() {
|
||||||
black --check --diff $PSScriptRoot
|
& $script:venvPython -m black --check --diff $PSScriptRoot
|
||||||
}
|
}
|
||||||
|
|
||||||
function newenv() {
|
function newenv() {
|
||||||
py -3.8 -m venv --clear .venv
|
py -3.8 -m venv --clear .venv
|
||||||
.\.venv\Scripts\python.exe -m pip install -U pip setuptools
|
& $PSScriptRoot\.venv\Scripts\python.exe -m pip install -U pip setuptools
|
||||||
syncenv
|
syncenv
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncenv() {
|
function syncenv() {
|
||||||
.\.venv\Scripts\python.exe -m pip install -Ur .\tools\dev-requirements.txt
|
& $PSScriptRoot\.venv\Scripts\python.exe -m pip install -Ur .\tools\dev-requirements.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
function activateenv() {
|
function activateenv() {
|
||||||
.\.venv\Scripts\Activate.ps1
|
& $PSScriptRoot\.venv\Scripts\Activate.ps1
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:availableCommands = @("reformat", "stylecheck", "stylediff", "newenv", "syncenv", "activateenv")
|
$script:availableCommands = @("reformat", "stylecheck", "stylediff", "newenv", "syncenv", "activateenv")
|
||||||
|
|
||||||
|
if (Test-Path -LiteralPath "$PSScriptRoot\.venv" -PathType Container) {
|
||||||
|
$script:venvPython = "$PSScriptRoot\.venv\Scripts\python.exe"
|
||||||
|
} else {
|
||||||
|
$script:venvPython = "python"
|
||||||
|
}
|
||||||
|
|
||||||
if ($help -or !$command) {
|
if ($help -or !$command) {
|
||||||
Get-Help $MyInvocation.InvocationName
|
Get-Help $MyInvocation.InvocationName
|
||||||
exit
|
exit
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user