1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

[version] add __variant__

Specifies origin and OS of executable files.
For example 'stable/windows'.
This commit is contained in:
Mike Fährmann 2024-05-27 21:37:01 +02:00
parent 020050ea8b
commit 601f5becc8
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
5 changed files with 39 additions and 11 deletions

View File

@ -42,7 +42,9 @@ jobs:
architecture: ${{ matrix.architecture }} architecture: ${{ matrix.architecture }}
- name: Date - name: Date
run: echo "DATE=$(date '+${{ env.DATE_FORMAT }}')" >> "$GITHUB_ENV" run: |
echo "DATE=$(date '+${{ env.DATE_FORMAT }}')" >> "$GITHUB_ENV"
echo "LABEL=$(python ./scripts/pyinstaller.py --print --os '${{ matrix.os }}' --arch '${{ matrix.architecture }}')" >> "$GITHUB_ENV"
- name: Update Version - name: Update Version
# use Python since its behavior is consistent across operating systems # use Python since its behavior is consistent across operating systems
@ -56,13 +58,17 @@ jobs:
r'\b(__version__ = "[^"]+)', r'\b(__version__ = "[^"]+)',
r"\1:${{ env.DATE }}", r"\1:${{ env.DATE }}",
content) content)
content = re.sub(
r'\b(__variant__ =).+',
r'\1 "dev/${{ env.LABEL }}"',
content)
with open(path, "w") as fp: with open(path, "w") as fp:
fp.write(content) fp.write(content)
- name: Build executable - name: Build executable
run: | run: |
pip install requests requests[socks] yt-dlp pyyaml ${{ matrix.python-packages }} pyinstaller pip install requests requests[socks] yt-dlp pyyaml ${{ matrix.python-packages }} pyinstaller
python ./scripts/pyinstaller.py --os '${{ matrix.os }}' --arch '${{ matrix.architecture }}' python ./scripts/pyinstaller.py --label '${{ env.LABEL }}'
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:

View File

@ -127,7 +127,7 @@ def main():
extra = "" extra = ""
if util.EXECUTABLE: if util.EXECUTABLE:
extra = " - Executable" extra = " - Executable ({})".format(version.__variant__)
else: else:
git_head = util.git_head() git_head = util.git_head()
if git_head: if git_head:

View File

@ -7,3 +7,4 @@
# published by the Free Software Foundation. # published by the Free Software Foundation.
__version__ = "1.27.0-dev" __version__ = "1.27.0-dev"
__variant__ = None

View File

@ -3,7 +3,6 @@
"""Build a standalone executable using PyInstaller""" """Build a standalone executable using PyInstaller"""
import PyInstaller.__main__
import argparse import argparse
import util import util
import sys import sys
@ -13,18 +12,34 @@ def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-o", "--os") parser.add_argument("-o", "--os")
parser.add_argument("-a", "--arch") parser.add_argument("-a", "--arch")
parser.add_argument("-l", "--label")
parser.add_argument("-e", "--extension") parser.add_argument("-e", "--extension")
parser.add_argument("-p", "--print", action="store_true")
args = parser.parse_args() args = parser.parse_args()
name = "gallery-dl" if args.label:
label = args.label
else:
label = ""
if args.os: if args.os:
name = "{}_{}".format(name, args.os.partition("-")[0].lower()) os = args.os.partition("-")[0].lower()
if os == "ubuntu":
os = "linux"
label += os
if args.arch == "x86": if args.arch == "x86":
name += "_x86" label += "_x86"
if args.print:
return print(label)
name = "gallery-dl"
if label:
name = "{}_{}".format(name, label)
if args.extension: if args.extension:
name = "{}.{}".format(name, args.extension.lower()) name = "{}.{}".format(name, args.extension.lower())
PyInstaller.__main__.run([ import PyInstaller.__main__
return PyInstaller.__main__.run([
"--onefile", "--onefile",
"--console", "--console",
"--name", name, "--name", name,

View File

@ -53,19 +53,20 @@ build-linux() {
cd "${ROOTDIR}" cd "${ROOTDIR}"
echo Building Linux executable echo Building Linux executable
build-vm 'ubuntu22.04' 'gallery-dl.bin' build-vm 'ubuntu22.04' 'gallery-dl.bin' 'linux'
} }
build-windows() { build-windows() {
cd "${ROOTDIR}" cd "${ROOTDIR}"
echo Building Windows executable echo Building Windows executable
build-vm 'windows7_x86_sp1' 'gallery-dl.exe' build-vm 'windows7_x86_sp1' 'gallery-dl.exe' 'windows'
} }
build-vm() { build-vm() {
VMNAME="$1" VMNAME="$1"
BINNAME="$2" BINNAME="$2"
LABEL="$3"
TMPPATH="/tmp/gallery-dl/dist/$BINNAME" TMPPATH="/tmp/gallery-dl/dist/$BINNAME"
# launch VM # launch VM
@ -77,6 +78,11 @@ build-vm() {
cp -a -t /tmp/gallery-dl -- \ cp -a -t /tmp/gallery-dl -- \
./gallery_dl ./scripts ./data ./setup.py ./README.rst ./gallery_dl ./scripts ./data ./setup.py ./README.rst
# update __variant__
sed -i \
-e "s#\(__variant__ *=\).*#\1 \"stable/${LABEL}\"#" \
/tmp/gallery-dl/gallery_dl/version.py
# remove old executable # remove old executable
rm -f "./dist/$BINNAME" rm -f "./dist/$BINNAME"