Skip to content

Commit

Permalink
fix windows dll dir for pip
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed Feb 25, 2017
1 parent 1ebdc00 commit c18e84f
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/urh/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@


def main():
if sys.platform == "win32":
urh_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
assert os.path.isdir(urh_dir)

dll_dir = os.path.realpath(os.path.join(urh_dir, "dev", "native", "lib", "win"))
print("Using DLLs from:", dll_dir)
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']

if sys.version_info < (3, 4):
print("You need at least Python 3.4 for this application!")
sys.exit(1)

t = time.time()
if GENERATE_UI and not hasattr(sys, 'frozen'):
try:
Expand All @@ -27,10 +39,9 @@ def main():

generate_ui.gen()

print("Time for generating UI: %.2f seconds" % (time.time() - t), file=sys.stderr)
print("Time for generating UI: %.2f seconds" % (time.time() - t))
except (ImportError, FileNotFoundError):
print("Will not regenerate UI, because script cant be found. This is okay in "
"release.", file=sys.stderr)
print("Will not regenerate UI, because script cant be found. This is okay in release.")

urh_exe = sys.executable if hasattr(sys, 'frozen') else sys.argv[0]
urh_exe = os.readlink(urh_exe) if os.path.islink(urh_exe) else urh_exe
Expand All @@ -42,15 +53,15 @@ def main():
if os.path.exists(src_dir) and not prefix.startswith("/usr") \
and not re.match(r"(?i)c:\\program", prefix):
# Started locally, not installed
print("Using modules from {0}".format(src_dir), file=sys.stderr)
print("Using modules from {0}".format(src_dir))
sys.path.insert(0, src_dir)

try:
import urh.cythonext.signalFunctions
import urh.cythonext.path_creator
import urh.cythonext.util
except ImportError:
print("Could not find C++ extensions, trying to build them.", file=sys.stderr)
print("Could not find C++ extensions, trying to build them.")
old_dir = os.curdir
os.chdir(os.path.join(src_dir, "urh", "cythonext"))

Expand Down Expand Up @@ -105,22 +116,4 @@ def main():


if __name__ == "__main__":
if sys.platform == "win32":
try:
import urh
urh_dir = os.path.dirname(urh.__file__) if not os.path.islink(urh.__file__) else os.path.dirname(os.readlink(urh.__file__))
assert os.path.isdir(urh_dir)
print("Found URH install dir:", urh_dir)
except ImportError:
print("Could not import UHR, assuming running from source")
urh_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
assert os.path.isdir(urh_dir)

dll_dir = os.path.realpath(os.path.join(urh_dir, "dev", "native", "lib", "win"))
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']

if sys.version_info < (3, 4):
print("You need at least Python 3.4 for this application!")
sys.exit(1)

main()

0 comments on commit c18e84f

Please sign in to comment.