Files
MINGW-packages/mingw-w64-gtk-doc/pyscript2exe.py
Christoph Reiter 6cde798f89 gtk-doc: Make mingw build work (#2911)
With 1.26 gtk-doc was ported to Python2/3 so we can use it with mingw Python 3.

Regarding the patches:

* Some path replacements for paths leaking from the autotools build system
* Since some other tools like meson expect that the gtkdoc utils are
  executables the pyscript2exe script generates a launcher exe for all
  utils. This is similar to what setuptools does for console entry points.
* Various Windows fixes, don't depend on the locale encoding when opening
  files and don't depend on the shell for executing commands.
  I'll try to upstream these changes once this gets more testing.

I've only tested building gexiv2 with this, larger packages might expose
more bugs.

Regarding meson: Remove the hack to invoke gtkdoc through msys perl, it's no
longer needed when mingw gtk-doc is installed. As there are no packages using
meson+gtkdoc right now this shouldn't break anything.
2017-09-18 09:49:20 +03:00

21 lines
587 B
Python

"""
Creates an exe launcher for Python scripts for the executing interpreter.
foobar.py -> foobar.exe + foobar-script.py
"""
import sys
import re
import os
from setuptools.command.easy_install import get_win_launcher
path = sys.argv[1]
with open(path, "rb") as f:
data = f.read()
with open(path, "wb") as f:
shebang = "#!/usr/bin/env " + os.path.basename(sys.executable)
f.write(re.sub(b"^#![^\n\r]*", shebang.encode(), data))
root, ext = os.path.splitext(path)
with open(root + ".exe", "wb") as f:
f.write(get_win_launcher("cli"))
os.rename(path, root + "-script.py")