Skip to content

Commit b177682

Browse files
committed
build: fix missing dist-info dir in installer
The installer currently doesn't include the dist-info directory of the `streamlink` package. This causes issues with `importlib.metadata` when it tries to find the package's metadata. This results in the following error when `--loglevel=debug` is set, as it lists the versions of Streamlink and its dependencies: > importlib.metadata.PackageNotFoundError: > No package metadata was found for streamlink While Streamlink's dependencies are defined as wheels in pynsist's build config and thus include their own dist-info directories that are then copied to the pkgs directory of the installer, the `streamlink` and `streamlink_cli` package names have to be explicitly defined, which means that Streamlink's dist-info directory won't be copied by pynsist. The only workaround for this seems to be adding the dist-info directory to the list of custom files of the installer. Changes: - Don't install streamlink in current venv and use a temp dir instead, similar to the portable build config - Remove unneeded and non-deterministic metadata from the dist-info dir - Set `PYTHONPATH` for loading streamlink from the temp dir - Add dist-info dir to custom files list in the installer build config
1 parent 31c3ad9 commit b177682

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Changelog - streamlink/windows-builds
33

44
## master
55

6+
- Fixed missing dist-info directory in installer, causing an error when `--loglevel=debug` was set due to missing metadata of the streamlink package
67
- Updated FFmpeg to 5.1
78
- Added `requirements.txt` for easier build dependency specification
89

build-installer.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ TEMP=$(mktemp -d) && trap "rm -rf '${TEMP}'" EXIT || exit 255
8383
DIR_REPO="${TEMP}/source.git"
8484
DIR_BUILD="${TEMP}/build"
8585
DIR_ASSETS="${TEMP}/assets"
86+
DIR_PKGS="${TEMP}/pkgs"
8687
DIR_WHEELS="${TEMP}/wheels"
8788

8889
mkdir -p \
@@ -141,10 +142,22 @@ build_app() {
141142
pip install \
142143
"${PIP_ARGS[@]}" \
143144
--no-cache-dir \
145+
--platform="${platform}" \
146+
--python-version="${pythonversion}" \
147+
--implementation="${implementation}" \
144148
--no-deps \
149+
--target="${DIR_PKGS}" \
150+
--no-compile \
145151
--upgrade \
146152
"${DIR_REPO}"
147153

154+
log "Removing unneeded dist files"
155+
( set -x; rm -r "${DIR_PKGS}/bin" "${DIR_PKGS}"/*.dist-info/direct_url.json; )
156+
sed -i -E \
157+
-e '/^.+\.dist-info\/direct_url\.json,sha256=/d' \
158+
-e '/^\.\.\/\.\.\//d' \
159+
"${DIR_PKGS}"/*.dist-info/RECORD
160+
148161
log "Creating icon"
149162
for size in 16 32 48 256; do
150163
# --without-gui and --export-png have been deprecated since Inkscape 1.0.0
@@ -232,9 +245,10 @@ prepare_installer() {
232245
log "Reading version string"
233246
local versionstring versionplain versionmeta vi_version installerversion
234247

235-
versionstring="$(python -c "from importlib.metadata import version;print(version('${appname}'))")"
248+
versionstring="$(PYTHONPATH="${DIR_PKGS}" python -c "from importlib.metadata import version;print(version('${appname}'))")"
236249
versionplain="${versionstring%%+*}"
237250
versionmeta="${versionstring##*+}"
251+
distinfo="${DIR_PKGS}/${appname}-${versionstring}.dist-info"
238252

239253
# Not a custom git reference (assume that only tagged releases are used as source)
240254
# Use plain version string with app release number and no abbreviated commit ID
@@ -269,18 +283,20 @@ prepare_installer() {
269283
env -i \
270284
DIR_BUILD="${DIR_BUILD}" \
271285
DIR_WHEELS="${DIR_WHEELS}" \
286+
DIR_DISTINFO="${distinfo}" \
272287
VERSION="${installerversion}" \
273288
PYTHONVERSION="${pythonversionfull}" \
274289
BITNESS="$([[ "${platform}" == "win_amd64" ]] && echo 64 || echo 32)" \
275290
INSTALLER_NAME="${DIR_DIST}/${appname}-${installerversion}-${BUILDNAME}.exe" \
276291
NSI_TEMPLATE="installer.nsi" \
277-
envsubst '$DIR_BUILD $DIR_WHEELS $VERSION $ENTRYPOINT $PYTHONVERSION $BITNESS $INSTALLER_NAME $NSI_TEMPLATE' \
292+
envsubst '$DIR_BUILD $DIR_DISTINFO $DIR_WHEELS $VERSION $ENTRYPOINT $PYTHONVERSION $BITNESS $INSTALLER_NAME $NSI_TEMPLATE' \
278293
< "${ROOT}/installer.cfg" \
279294
> "${DIR_BUILD}/installer.cfg"
280295
}
281296

282297
build_installer() {
283-
PYNSIST_CACHE_DIR="${DIR_BUILD}" pynsist "${DIR_BUILD}/installer.cfg"
298+
log "Building installer"
299+
PYTHONPATH="${DIR_PKGS}" PYNSIST_CACHE_DIR="${DIR_BUILD}" pynsist "${DIR_BUILD}/installer.cfg"
284300
}
285301

286302

installer.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ include_msvcrt=false
1313
[Include]
1414
packages=streamlink
1515
streamlink_cli
16+
files=${DIR_DISTINFO} > $INSTDIR/pkgs/
1617
local_wheels=${DIR_WHEELS}/*.whl
1718

1819
[Command streamlink]

0 commit comments

Comments
 (0)