Convert the script to a Python package
It can now be invoked via `python -m msys2_autobuild` or by installing it, which adds a "msys2-autobuild" script. This is a first step towards splitting up the code. The HTTP cache is now stored in the working directory instead of the source directory.
This commit is contained in:
parent
d0ddf60737
commit
0d25d51a04
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
@ -16,6 +16,9 @@ on:
|
||||
schedule:
|
||||
- cron: '0 0/3 * * *'
|
||||
|
||||
env:
|
||||
PYTHONUNBUFFERED: 1
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
@ -66,7 +69,7 @@ jobs:
|
||||
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
|
||||
OPTIONAL_DEPS: ${{ github.event.inputs.optional_deps }}
|
||||
run: |
|
||||
python -u autobuild.py write-build-plan --optional-deps "$OPTIONAL_DEPS" build_plan.json
|
||||
python -m msys2_autobuild write-build-plan --optional-deps "$OPTIONAL_DEPS" build_plan.json
|
||||
buildPlan="$(cat build_plan.json)"
|
||||
echo "build-plan=$buildPlan" >> $GITHUB_OUTPUT
|
||||
|
||||
@ -76,7 +79,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
|
||||
run: |
|
||||
python -u autobuild.py clean-assets
|
||||
python -m msys2_autobuild clean-assets
|
||||
|
||||
- name: Show build queue
|
||||
if: steps.check.outputs.build-plan != '[]'
|
||||
@ -85,7 +88,7 @@ jobs:
|
||||
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
|
||||
OPTIONAL_DEPS: ${{ github.event.inputs.optional_deps }}
|
||||
run: |
|
||||
python -u autobuild.py show --optional-deps "$OPTIONAL_DEPS"
|
||||
python -m msys2_autobuild show --optional-deps "$OPTIONAL_DEPS"
|
||||
|
||||
build:
|
||||
needs: schedule
|
||||
@ -171,4 +174,4 @@ jobs:
|
||||
$env:VCPKG_ROOT=''
|
||||
$BUILD_ROOT='C:\'
|
||||
$MSYS2_ROOT=(msys2 -c 'cygpath -w /')
|
||||
python -u autobuild.py build ${{ matrix.build-args }} "$MSYS2_ROOT" "$BUILD_ROOT"
|
||||
python -m msys2_autobuild build ${{ matrix.build-args }} "$MSYS2_ROOT" "$BUILD_ROOT"
|
||||
|
||||
8
.github/workflows/maint.yml
vendored
8
.github/workflows/maint.yml
vendored
@ -59,8 +59,8 @@ jobs:
|
||||
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
|
||||
CLEAR_FAILED_BUILD_TYPES: ${{ github.event.inputs.clear_failed_build_types }}
|
||||
run: |
|
||||
python -u autobuild.py clear-failed --build-types "$CLEAR_FAILED_BUILD_TYPES"
|
||||
python -u autobuild.py update-status
|
||||
python -m msys2_autobuild clear-failed --build-types "$CLEAR_FAILED_BUILD_TYPES"
|
||||
python -m msys2_autobuild update-status
|
||||
|
||||
- name: Clear failed packages
|
||||
if: ${{ github.event.inputs.clear_failed_packages != '' }}
|
||||
@ -69,5 +69,5 @@ jobs:
|
||||
GITHUB_TOKEN_READONLY: ${{ secrets.GITHUBTOKENREADONLY }}
|
||||
CLEAR_FAILED_PACKAGES: ${{ github.event.inputs.clear_failed_packages }}
|
||||
run: |
|
||||
python -u autobuild.py clear-failed --packages "$CLEAR_FAILED_PACKAGES"
|
||||
python -u autobuild.py update-status
|
||||
python -m msys2_autobuild clear-failed --packages "$CLEAR_FAILED_PACKAGES"
|
||||
python -m msys2_autobuild update-status
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# msys2-autobuild
|
||||
|
||||
## autobuild.py
|
||||
## CLI
|
||||
|
||||
```console
|
||||
$ pacman -S mingw-w64-x86_64-python-tabulate mingw-w64-x86_64-python-pygithub mingw-w64-x86_64-python-requests
|
||||
@ -11,7 +11,7 @@ $ python -m pip install --user -r requirements.txt
|
||||
```
|
||||
|
||||
```console
|
||||
$ ./autobuild.py --help
|
||||
$ python -m msys2_autobuild --help
|
||||
usage: autobuild.py [-h]
|
||||
{build,show,should-run,update-status,fetch-assets,upload-assets,clean-assets}
|
||||
...
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
@ -1671,7 +1669,7 @@ def install_requests_cache() -> Generator:
|
||||
# Monkey patch globally, so pygithub uses it as well.
|
||||
# Only do re-validation with etag/date etc and ignore the cache-control headers that
|
||||
# github sends by default with 60 seconds.
|
||||
cache_dir = os.path.join(SCRIPT_DIR, '.autobuild_cache')
|
||||
cache_dir = os.path.join(os.getcwd(), '.autobuild_cache')
|
||||
os.makedirs(cache_dir, exist_ok=True)
|
||||
requests_cache.install_cache(
|
||||
always_revalidate=True,
|
||||
@ -1786,5 +1784,5 @@ def main(argv: List[str]) -> None:
|
||||
args.func(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv)
|
||||
def run() -> None:
|
||||
return main(sys.argv)
|
||||
3
msys2_autobuild/__main__.py
Normal file
3
msys2_autobuild/__main__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from . import run
|
||||
|
||||
run()
|
||||
2
poetry.lock
generated
2
poetry.lock
generated
@ -769,4 +769,4 @@ files = [
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.8.1"
|
||||
content-hash = "9ef21636afb4a916efb9a6b2a646f317a0e854c793cadb72c737d4ab77a0046b"
|
||||
content-hash = "eb5347d2acbf38939ee4195dbfe6df3397d58bfedee304099bd295bea938800a"
|
||||
|
||||
@ -17,6 +17,9 @@ flake8 = "^6.0.0"
|
||||
types-tabulate = "^0.9.0.0"
|
||||
types-requests = "^2.25.0"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
msys2-autobuild = 'msys2_autobuild:run'
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user