Skip to content

Instantly share code, notes, and snippets.

@syfluqs
Created June 20, 2017 06:16
Show Gist options
  • Save syfluqs/7696a7d507c5aa410dcf20a7b1ca8f96 to your computer and use it in GitHub Desktop.
Save syfluqs/7696a7d507c5aa410dcf20a7b1ca8f96 to your computer and use it in GitHub Desktop.
A makefile for compiling python scripts to exe on windows.
PYTHONPATH:=C:\Python35
PYTHONLIB:=python35
.PHONY: build
build:
cython --embed $(file).py -o $(file).c
#Applying Wmain@16 linker error workaround patch
@sed 's/int wmain(int argc/int main(int argc/' $(file).c > cython_build_temp.c
gcc cython_build_temp.c -o $(file) -I $(PYTHONPATH)\include -L $(PYTHONPATH)\libs -l$(PYTHONLIB)
rm cython_build_temp.c
.PHONY: no_console_build
no_console_build:
cython --embed $(file).py -o $(file).c
#Applying Wmain@16 linker error workaround patch
@sed 's/int wmain(int argc/int main(int argc/' $(file).c > cython_build_temp.c
gcc cython_build_temp.c -o $(file) -I $(PYTHONPATH)\include -L $(PYTHONPATH)\libs -l$(PYTHONLIB) -Wl,--subsystem,windows
rm cython_build_temp.c
@syfluqs
Copy link
Author

syfluqs commented Jun 20, 2017

rename cython_win_makefile.mak to makefile

Usage :
To build example.py
make build file=example
OR
make no_console_build file=example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment