takluyver / pynsist

Build Windows installers for Python applications
https://pynsist.readthedocs.io/
Other
882 stars 119 forks source link

Config>application>extra_preamble not working #132

Closed skillingt closed 6 years ago

skillingt commented 6 years ago

extra_preamble in the config file application section doesn't appear to do anything.

installer.cfg

[Application]
name=Hello World
version=1.0
# How to launch the app - this calls the 'HelloWorld' function from the 'HelloWorld' package:
entry_point=HelloWorld:HelloWorld
console=true
extra_preamble=bakeKeys.py

[Python]
version=3.6.3
bitness=64

[Command runHelloWorld]
entry_point=HelloWorld:HelloWorld

[Build]
nsi_template=installer.cfg.template

[Include]
# Importable packages that your application requires, one per line
#packages = requests
#     bs4
#     html5lib

# Other files and folders that should be installed
#files = LICENSE
#   data_files/

bakeKeys.py

with open('somefile.txt', 'w') as the_file:
    the_file.write('Hello\n')

Text file is never written to, not during creation of installer or during installation itself. This is a trivial example, what I want to do is replace a string with a secret key that is located in the build template to avoid uploading an API key to source control. Would like to use the functionality of extra_preamble instead of a wrapper script for the installer.

takluyver commented 6 years ago

Sorry, extra_preamble doesn't do what you think - it's run when the user launches your application, not when building or running the installer. You'll probably need to go down the wrapper script route.

skillingt commented 6 years ago

Thanks for your quick response. I've used AppVeyor in the past which allows scripts to be run before and after building (in which I included a script just like one I mentioned). This would be a great addition to your application as well. Thank you for your work already, this is a very useful utility.