Skip to content

Commit

Permalink
[dist] Generate version info in correct place.
Browse files Browse the repository at this point in the history
  • Loading branch information
Breakthrough committed May 19, 2024
1 parent 5dd1912 commit dacbabf
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ jobs:
- name: Build DVR-Scan
run: |
python dist/prep_release.py
pyinstaller dist/dvr-scan.spec
python dist/post_release.py
- name: Assemble Portable Distribution
run: |
python dist/create_win64_release.py
7z e -odist/ffmpeg ffmpeg-6.0-full_build.7z LICENSE -r
Move-Item -Path ffmpeg.exe -Destination dist/dvr-scan/ffmpeg.exe
Move-Item -Path dist/ffmpeg/LICENSE -Destination dist/dvr-scan/LICENSE-FFMPEG -Force
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ install:
- echo * * BUILDING WINDOWS EXE * *
- echo * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# Build Windows .EXE and create Windows distribution
- python dist/pre_release.py
- pyinstaller dist/dvr-scan.spec
- python dist/create_win64_release.py
- python dist/post_release.py
- appveyor DownloadFile https://github.com/GyanD/codexffmpeg/releases/download/6.0/ffmpeg-6.0-full_build.7z
- 7z e ffmpeg-6.0-full_build.7z -odist/ffmpeg ffmpeg.exe LICENSE -r
- move dist\ffmpeg\ffmpeg.exe dist\dvr-scan\
Expand Down
2 changes: 1 addition & 1 deletion dist/create_win64_release.py → dist/post_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
for file_path in glob.glob(os.path.join(BASE_PATH, file_glob)):
os.remove(file_path)

# Collect self dependencies.
# TODO: See if the following can be added to COLLECT instead of including
# these files as part of the .spec file Analysis step.

for f in glob.glob(os.path.join(BASE_PATH, "dvr-scan/*")):
shutil.move(f, DIST_PATH)

Expand Down
61 changes: 61 additions & 0 deletions dist/pre_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
import os
import sys
sys.path.append(os.path.abspath("."))

import dvr_scan
VERSION = dvr_scan.__version__

with open("dist/.version_info", "wb") as f:
v = VERSION.split(".")
assert len(v) <= 3

if len(v) == 3:
(maj, min, pat) = int(v[0]), int(v[1]), int(v[2])
else:
(maj, min, pat) = int(v[0]), int(v[1]), 0

f.write(f"""# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(0, {maj}, {min}, {pat}),
prodvers=(0, {maj}, {min}, {pat}),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x4,
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1,
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0,
# Creation date and time stamp.
date=(0, 0)
),
kids=[
StringFileInfo(
[
StringTable(
u'040904B0',
[StringStruct(u'CompanyName', u'github.com/Breakthrough'),
StringStruct(u'FileDescription', u'dvr-scan.readthedocs.io'),
StringStruct(u'FileVersion', u'{VERSION}'),
StringStruct(u'InternalName', u'DVR-Scan'),
StringStruct(u'LegalCopyright', u'Copyright © 2024 Brandon Castellano'),
StringStruct(u'OriginalFilename', u'dvr-scan.exe'),
StringStruct(u'ProductName', u'DVR-Scan'),
StringStruct(u'ProductVersion', u'{VERSION}')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
)
""".encode())

0 comments on commit dacbabf

Please sign in to comment.