Skip to content

Commit

Permalink
build tweaks for native mingw installations: place more files in PREF…
Browse files Browse the repository at this point in the history
…IX/share/xpra and look them up there (tlb, icons, etc), add to PATH so ctypes will find the DLLs, etc

git-svn-id: https://xpra.org/svn/Xpra/trunk@19684 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 21, 2018
1 parent 27fb069 commit 47e9bda
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 42 deletions.
46 changes: 28 additions & 18 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def is_RH():
sd_listen_ENABLED = POSIX and pkg_config_ok("--exists", "libsystemd") and (not is_Ubuntu() or getUbuntuVersion()>[16, 4])
proxy_ENABLED = DEFAULT
client_ENABLED = DEFAULT
scripts_ENABLED = not WIN32

x11_ENABLED = DEFAULT and not WIN32 and not OSX
xinput_ENABLED = x11_ENABLED
Expand Down Expand Up @@ -224,6 +225,7 @@ def is_RH():
"csc_libyuv",
"bencode", "cython_bencode", "vsock", "netdev", "mdns",
"clipboard",
"scripts",
"server", "client", "dbus", "x11", "xinput", "uinput", "sd_listen",
"gtk_x11", "service",
"gtk2", "gtk3", "example",
Expand Down Expand Up @@ -260,10 +262,14 @@ def is_RH():
ssl_cert = None
ssl_key = None
minifier = None
if WIN32:
share_xpra = ""
else:
share_xpra = "share/xpra/"
filtered_args = []
for arg in sys.argv:
matched = False
for x in ("rpath", "ssl-cert", "ssl-key", "install"):
for x in ("rpath", "ssl-cert", "ssl-key", "install", "share-xpra"):
varg = "--%s=" % x
if arg.startswith(varg):
value = arg[len(varg):]
Expand Down Expand Up @@ -1052,8 +1058,8 @@ def install_html5(install_dir="www"):
gnome_include_path = os.environ.get("MINGW_PREFIX")

#only add the cx_freeze specific options
#if we aren't just building the Cython bits with "build_ext":
if "build_ext" not in sys.argv:
#only if we are packaging:
if "install_exe" in sys.argv:
#with cx_freeze, we don't use py_modules
del setup_options["py_modules"]
import cx_Freeze #@UnresolvedImport
Expand Down Expand Up @@ -1421,11 +1427,11 @@ def add_service_exe(script, icon, base_name):
add_data_files('www'+k, v)

if client_ENABLED or server_ENABLED:
add_data_files('', ['COPYING', 'README', 'win32/website.url'])
add_data_files('icons', glob.glob('icons\\*.ico') + glob.glob('icons\\*.png'))
add_data_files(share_xpra, ["win32/website.url"])
add_data_files('%sicons' % share_xpra, glob.glob('icons\\*.ico'))

if webcam_ENABLED:
add_data_files('', ['win32\\DirectShow.tlb'])
add_data_files(share_xpra, ["win32\\DirectShow.tlb"])

remove_packages(*external_excludes)
external_includes.append("pyu2f")
Expand Down Expand Up @@ -1456,7 +1462,7 @@ def add_service_exe(script, icon, base_name):
remove_packages("pygst", "gst", "gst.extend")

#add subset of PyOpenGL modules (only when installing):
if opengl_ENABLED and ("install_exe" in sys.argv or "install" in sys.argv):
if opengl_ENABLED and "install_exe" in sys.argv:
#for this hack to work, you must add "." to the sys.path
#so python can load OpenGL from the install directory
#(further complicated by the fact that "." is the "frozen" path...)
Expand All @@ -1474,16 +1480,15 @@ def add_service_exe(script, icon, base_name):
if not isinstance(e, WindowsError) or (not "already exists" in str(e)): #@UndefinedVariable
raise

add_data_files('', glob.glob("win32\\bundle-extra\\*"))
add_data_files('', ["bell.wav"])
add_data_files('http-headers', glob.glob("http-headers\\*"))
add_data_files('', glob.glob("win32\\bundle-extra\\*"))

#END OF win32
#*******************************************************************************
else:
#OSX and *nix:
scripts += ["scripts/xpra", "scripts/xpra_launcher", "scripts/xpra_browser", "scripts/xpra_udev_product_version", "scripts/xpra_signal_listener"]
if POSIX and not OSX:
if LINUX:
if scripts_ENABLED:
scripts += ["scripts/xpra_udev_product_version", "scripts/xpra_signal_listener"]
libexec_scripts = []
if is_Fedora() or is_CentOS():
libexec = "libexec"
Expand All @@ -1499,14 +1504,10 @@ def add_service_exe(script, icon, base_name):
if OPENBSD:
man_path = "man"
add_data_files("%s/man1" % man_path, ["man/xpra.1", "man/xpra_launcher.1", "man/xpra_browser.1"])
add_data_files("share/xpra", ["README", "COPYING"])
add_data_files("share/xpra/icons", glob.glob("icons/*png"))
add_data_files("share/applications", ["xdg/xpra-launcher.desktop", "xdg/xpra-browser.desktop", "xdg/xpra.desktop"])
add_data_files("share/mime/packages", ["xdg/application-x-xpraconfig.xml"])
add_data_files("share/icons", ["xdg/xpra.png", "xdg/xpra-mdns.png"])
add_data_files("share/appdata", ["xdg/xpra.appdata.xml"])
add_data_files('share/xpra/', ["bell.wav"])
add_data_files('share/xpra/http-headers', glob.glob("http-headers/*"))

#here, we override build and install so we can
#generate our /etc/xpra/xpra.conf
Expand All @@ -1527,7 +1528,7 @@ class install_data_override(install_data):
def run(self):
print("install_data_override: install_dir=%s" % self.install_dir)
if html5_ENABLED:
install_html5(os.path.join(self.install_dir, "share/xpra/www"))
install_html5(os.path.join(self.install_dir, "%swww" % share_xpra))
install_data.run(self)

root_prefix = self.install_dir.rstrip("/")
Expand Down Expand Up @@ -1700,6 +1701,15 @@ def osx_pkgconfig(*pkgs_options, **ekw):
pkgconfig = osx_pkgconfig


if scripts_ENABLED:
scripts += ["scripts/xpra", "scripts/xpra_launcher", "scripts/xpra_browser"]

add_data_files(share_xpra, ["README", "COPYING"])
add_data_files(share_xpra, ["bell.wav"])
add_data_files("%shttp-headers" % share_xpra, glob.glob("http-headers/*"))
add_data_files("%sicons" % share_xpra, glob.glob("icons/*png"))


if html5_ENABLED:
if WIN32 or OSX:
external_includes.append("websockify")
Expand Down Expand Up @@ -2130,7 +2140,7 @@ def which(cmd):
print(stdout or "")
print(stderr or "")
sys.exit(1)
CUDA_BIN = "share/xpra/cuda"
CUDA_BIN = "%scuda" % share_xpra
if WIN32:
CUDA_BIN = "CUDA"
add_data_files(CUDA_BIN, ["xpra/codecs/cuda_common/%s.fatbin" % x for x in kernels])
Expand Down
2 changes: 2 additions & 0 deletions src/win32/MINGW_BUILD.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ if [ "${PYTHON_MAJOR_VERSION}" == "3" ]; then
mv ./libgst*.dll ./lib/gstreamer-1.0/
#remove all the pointless duplication:
mv *dll lib/
#but keep python and gcc DLLs in the root:
cp lib/libpython*dll lib/libgcc*dll lib/libwinpthread*dll ./
#we don't need this one?
rm lib/libopenblas*
pushd lib > /dev/null
Expand Down
5 changes: 3 additions & 2 deletions src/xpra/net/net_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,10 @@ def get_iface(ip):
library = "libc.so"
try:
from ctypes import cdll, CDLL, c_char_p, c_uint, create_string_buffer
cdll.LoadLibrary(library)
#cdll.LoadLibrary(library)
from ctypes.util import find_library
#<CDLL 'libc.so.6', handle 7fcac419b000 at 7fcac1ab0c10>
_libc = CDLL(library)
_libc = CDLL(find_library(library))
log("successfully loaded socket C library from %s", library)
except ImportError as e:
log.error("library %s not found: %s", library, e)
Expand Down
15 changes: 8 additions & 7 deletions src/xpra/platform/win32/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@
REDIRECT_OUTPUT = envbool("XPRA_REDIRECT_OUTPUT", frozen is True and GetConsoleCP()==0)
if frozen:
#cx_freeze paths:
PATH = os.environ.get("PATH", "").split(os.pathsep)
edir = os.path.dirname(sys.executable)
def jedir(*paths):
return "\\".join([edir]+list(paths))
return os.path.join(*([edir]+list(paths)))
def addsyspath(*paths):
v = jedir(*paths)
if os.path.exists(v):
sys.path.append(v)
if v not in sys.path:
sys.path.append(v)
if os.path.isdir(v) and v not in PATH:
PATH.append(v)
addsyspath('')
addsyspath('bin')
addsyspath('bin', 'etc')
addsyspath('bin', 'lib')
addsyspath('bin', 'share')
addsyspath('bin', 'library.zip')
addsyspath('lib')
os.environ['GI_TYPELIB_PATH'] = jedir('lib', 'girepository-1.0')
os.environ["PATH"] = os.pathsep.join(PATH)

#don't know why this breaks with Python 3 yet...
FIX_UNICODE_OUT = envbool("XPRA_FIX_UNICODE_OUT", not REDIRECT_OUTPUT and PYTHON2)
Expand Down
3 changes: 2 additions & 1 deletion src/xpra/platform/win32/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@

if PYTHON3:
from ctypes import CDLL, pythonapi, c_void_p, py_object
from ctypes.util import find_library
PyCapsule_GetPointer = pythonapi.PyCapsule_GetPointer
PyCapsule_GetPointer.restype = c_void_p
PyCapsule_GetPointer.argtypes = [py_object]
log("PyCapsute_GetPointer=%s", PyCapsule_GetPointer)
gdkdll = CDLL("libgdk-3-0.dll")
gdkdll = CDLL(find_library("libgdk-3-0.dll"))
log("gdkdll=%s", gdkdll)


Expand Down
19 changes: 14 additions & 5 deletions src/xpra/platform/win32/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ def _get_data_dir():
return data_dir


def do_get_icon_dir():
def do_get_resources_dir():
from xpra.platform.paths import get_app_dir
return os.path.join(get_app_dir(), "icons")
app_dir = get_app_dir()
prefix = os.environ.get("MINGW_PREFIX")
for d in (app_dir, prefix):
if not d or not os.path.isdir(d):
return
share_xpra = os.path.join(d, "share", "xpra")
if os.path.exists(share_xpra):
return share_xpra
return app_dir

def do_get_icon_dir():
from xpra.platform.paths import get_resources_dir
return os.path.join(get_resources_dir(), "icons")


def do_get_system_conf_dirs():
Expand Down Expand Up @@ -117,9 +129,6 @@ def do_get_socket_dirs():
else:
os.environ['PATH'] = APP_DIR.encode('utf8') + os.pathsep + os.environ['PATH']

def do_get_resources_dir():
from xpra.platform.paths import get_app_dir
return get_app_dir()

def do_get_app_dir():
global APP_DIR
Expand Down
22 changes: 13 additions & 9 deletions src/xpra/platform/win32/win32_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
try:
from xpra.log import Logger
from xpra.platform.paths import get_app_dir
tlb_dir = get_app_dir()
app_dir = get_app_dir()
assert app_dir
log = Logger("webcam", "win32")
except ImportError:
tlb_dir = os.getcwd()
app_dir = os.getcwd()
def log(*args):
print(args[0] % args[1:])

Expand All @@ -28,15 +29,18 @@ def log(*args):
from xpra.platform.win32.comtypes_util import QuietenLogging


#load directshow:
win32_tlb_dir = os.path.join(tlb_dir, "win32")
if os.path.exists(win32_tlb_dir):
tlb_dir = win32_tlb_dir
directshow_tlb = os.path.join(tlb_dir, "DirectShow.tlb")
directshow_tlb = os.environ.get("XPRA_DIRECTSHOW_TLB", directshow_tlb)
#try to load directshow tlb from various directories,
#depending on how xpra was packaged, or even run from the source directory:
dirs = [app_dir, os.path.join(app_dir, "win32"), os.path.join(app_dir, "share", "xpra")]
filenames = [os.environ.get("XPRA_DIRECTSHOW_TLB")] + [os.path.join(d, "DirectShow.tlb") for d in dirs]
for filename in filenames:
if filename and os.path.exists(filename):
directshow_tlb = filename
break
log("directshow_tlb=%s", directshow_tlb)
if not os.path.exists(directshow_tlb):
if not directshow_tlb:
raise ImportError("DirectShow.tlb is missing")

with QuietenLogging():
directshow = client.GetModule(directshow_tlb)
log("directshow: %s", directshow)
Expand Down

0 comments on commit 47e9bda

Please sign in to comment.