Skip to content

Shared code/configuration in .spec files #9008

Answered by rokm
marcelstoer asked this question in Help
Discussion options

You must be logged in to vote

The directory that contains .spec file is not automatically added to python's search path. Technically, it never really is; it is the location of the entry-point script that ends up being added to search path, but only when Analysis is instantiated.

So if you want your CommonSpec to be discoverable at the start of spec, you need to add the spec location to python's search path:

import sys
import os

sys.path.insert(0, os.path.dirname(SPEC))  # SPEC is defined by PyInstaller in the context in which the spec is executed

import CommonSpec

a = Analysis(
    ['my-app.py'],
    pathex=[],
    binaries=[],
    datas=CommonSpec.datas,
...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@marcelstoer
Comment options

Answer selected by marcelstoer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants