Install PyInstaller within the pipenv - this appears to resolve some path searching issues
PyInstaller 2018 Version has issues with virtual environments and specifically with venv 16.7.9 (used by pipenv). This may be resovled by the 9 Jan 2020 Version. The develop branch appears to solve the issue:
pipenv install -e git+https://github.com/pyinstaller/pyinstaller.git@develop#egg=PyInstaller
Run PyInstaller from inside the pipenv shell:
pyinstaller --clean --debug=all --noconfirm foo.spec
Paths are calculated from the working directory from which the binary is called; relative paths are rooted in the current working directory.
Example:
$ pwd
/home/foo/bar/
# execute a built pyinstaller script:
$ ./spam/myScript
# relative paths such as `./config.ini` are rooted in the current working directory:
# thus ./config.ini resolves to: /home/foo/bar/config.ini
# instead of: ./home/foo/bar/spam/config.ini
When in doubt, regenerate it!
Binary includes are mapped literally:
binaries=[('./foo/bar/spam.bin', './foo')]
Literally maps to dist/myProject/foo/spam.bin
If it is necessary to maintain the directory structure the code snip below can be added to the .spec file:
from pathlib import Path
def getPathTuples(path):
"""recursively search `path` for files and create a tuple of the original relative path
and the destination path in the format: ('path/subDirA/subDir1/file1.bin', 'path/subDirA/subDir1/')
"""
myPath = Path(path)
allEntries = list()
for entry in list(myPath.glob('*')):
if Path.is_dir(entry):
allEntries = allEntries + getPathTuples(entry)
else:
allEntries.append((str(entry), str(entry.parent)))
return allEntries
binDirs = ['./fonts', './images']
binTuples = []
for each in binDirs:
tuples =(getPathTuples(each))
for tup in tuples:
binTuples.append(tup)
binTuples