Skip to content

Recipe Data Files reffered by symbolic link

eliadh edited this page Aug 21, 2022 · 4 revisions

In case your data files are referred to by symbolic link (a common practice to enable build-time customizations), the directory which is the target of the symbolic link has to be explicitly collected.
let's say that you have a web app that has a static directory with some files and a child directory resources that contains other files which are referred to by a symbolic link:

static
  │
  ├── favicon.png
  ├── background.png
  └── resources
         ├── ...
	 └── ...

a regular directive in the spec file which collects the parent (static):

# spec file snippet
a = Analysis(['app.py'],
pathex=['/path/to/app'],
binaries=None,
datas=[('app/templates', 'templates'),
       ('app/static', 'static'),
	   ...],
...
)

won't collect the build time resources directory. the solution is to explicitly collect this directory as well

# spec file snippet
a = Analysis(['app.py'],
	pathex=['/path/to/app'],
	binaries=None,
datas=[('app/templates', 'templates'), 
	('app/static', 'static'),
	('app/static/resources', 'static/resources'), # <-- explicitly collect the resources directory!
	...],
...
)