0

I have an application that I package with pyinstaller to windows package. I wanted to use the filelock.py to secure file writes. That file comes as a single .py file instead of a packages and that requires apparently a slightly different approach to integrate in pyinstaller.

I have this structure in my datas list in the specfile:

...
datas=[...
       ('C:\\Users\\user\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\pymzml', '.\\pymzml'),
       ('C:\\Users\\user\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\filelock.py', '.\\filelock'),                    
...]

the first one is an example for a "normal" package. And the second is the not-working example for filelock.

I think the problem is that filelock does not follow a standard structure where the program is located in a subfolder /filelock/filelock.py instead only the file is installed when using pip pip install filelock.

Soerendip
  • 7,684
  • 15
  • 61
  • 128

1 Answers1

1

If your script does "import filelock", then pyinstaller will go find the file and include in the package, just like it finds "import sys" and "import os". You don't have to tell it where to find it.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • It is a more complex program. The import is not in the script but somewhere deep down in the guts. Will try to add it to the script as well. Although, then flake8 will complain about unused imports. – Soerendip Feb 11 '21 at 19:10
  • "datas" is not the right answer. You want the `hiddenimports` parameter. You can use the `--debug-imports` flag to help identify those. – Tim Roberts Feb 20 '21 at 00:12