diff --git a/.gitignore b/.gitignore index 9f1ead3dd..ee2ed042e 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ venv doc/source/main_help.rst Dockerfile b2/licenses_output.txt -b2.spec +*.spec diff --git a/noxfile.py b/noxfile.py index 474fd7143..7baf4f4da 100644 --- a/noxfile.py +++ b/noxfile.py @@ -317,9 +317,9 @@ def bundle(session: nox.Session): 'VERSION': version, 'NAME': binary_name, }) - pathlib.Path('b2.spec').write_text(spec) + pathlib.Path(f'{binary_name}.spec').write_text(spec) - session.run('pyinstaller', *session.posargs, 'b2.spec', **run_kwargs) + session.run('pyinstaller', *session.posargs, f'{binary_name}.spec', **run_kwargs) if SYSTEM == 'linux' and not NO_STATICX: session.run( @@ -343,7 +343,9 @@ def bundle(session: nox.Session): # Pick only the shortest named executable. # All the longer ones should be for different versions, the shortest one will be the latest stable. - executable = min([str(path) for path in pathlib.Path('dist').glob('*')], key=lambda path: len(path)) + executable = min( + [str(path) for path in pathlib.Path('dist').glob('*')], key=lambda path: len(path) + ) print(f'sut_path={executable}') diff --git a/pyinstaller-hooks/hook-b2.py b/pyinstaller-hooks/hook-b2.py index 7e9e6fafc..110efaa0e 100644 --- a/pyinstaller-hooks/hook-b2.py +++ b/pyinstaller-hooks/hook-b2.py @@ -13,5 +13,21 @@ license_file = Path('b2/licenses_output.txt') assert license_file.exists() datas = [ - (str(license_file), '.'), + # When '.' was provided here, the license file was copied to the root of the executable. + # Before ApiVer, it pasted the file to the `b2/` directory. + # I have no idea why it worked before or how it works now. + # If you mean to debug it in the future, know that `pyinstaller` provides a special + # attribute in the `sys` module whenever it runs. + # + # Example: + # import sys + # if hasattr(sys, '_MEIPASS'): + # self._print(f'{NAME}') + # self._print(f'{sys._MEIPASS}') + # elems = [elem for elem in pathlib.Path(sys._MEIPASS).glob('**/*')] + # self._print(f'{elems}') + # + # If used at the very start of the `_run` of `Licenses` command, it will print + # all the files that were unpacked from the executable. + (str(license_file), 'b2/'), ]