Skip to content

Commit

Permalink
Win precompile (#291)
Browse files Browse the repository at this point in the history
build precompiled wheels for windows on git tag
  • Loading branch information
jopohl committed Jun 11, 2017
1 parent a63f284 commit 353ce68
Show file tree
Hide file tree
Showing 34 changed files with 62 additions and 57 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ sudo pip3 install urh


### Windows
1. Install [Visual C++ Build Tools 2015](http://landinghub.visualstudio.com/visual-cpp-build-tools).
2. Install [Python 3 for Windows](https://www.python.org/downloads/windows/). Choose a __64 Bit__ version!
3. (Optional) Open a terminal (__cmd__) and type: ``` pip install numpy ``` - _This speeds the installation up a bit._
4. In a terminal, type: ``` pip install urh ```.
5. Type ``` urh ``` in a terminal or search for ``` urh ``` in search bar.
If you run a Python 3.4 you need to install [Visual C++ Build Tools 2015](http://landinghub.visualstudio.com/visual-cpp-build-tools) first. It is recommended to use Python 3.5 or later on Windows, so no C++ compiler needs to be installed.
1. Install [Python 3 for Windows](https://www.python.org/downloads/windows/).
- Make sure you tick the _Add Python to PATH_ checkbox on first page in python installer.
- Choose a __64 Bit__ version for native device support!
2. Open a terminal (__cmd__) and type: ``` pip install numpy ```.
- If you do not have a C++ Compiler on your system it is essential to install numpy before URH!
3. In a terminal, type: ``` pip install urh ```.
4. Type ``` urh ``` in a terminal or search for ``` urh ``` in search bar to start the application.

### Mac OS X
1. Install [Python 3 for Mac OS X](https://www.python.org/downloads/mac-osx/).
Expand Down
26 changes: 16 additions & 10 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
environment:
TWINE_USERNAME:
secure: qqioSb3Yu/QTOdDKx10sDQ==
TWINE_PASSWORD:
secure: y8XwCStmwBEwWyXQ108iC7I+WFje6C7rbc0ypp56Q2g=
TWINE_REPOSITORY_URL:
'https://pypi.python.org/pypi/'
matrix:
- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.x"
Expand Down Expand Up @@ -54,7 +60,7 @@ install:
# pip will build them from source using the MSVC compiler matching the
# target Python version and architecture
- pip install -r requirements.txt
- pip install pytest wheel
- pip install pytest wheel twine

build_script:
# Build the compiled extension
Expand All @@ -65,17 +71,17 @@ test_script:
- python -m pytest -s
- pip install .
- urh autoclose
- pip uninstall -y urh

#after_test:
# # If tests are successful, create binary packages for the project.
# - python setup.py bdist_wheel
after_test:
# If tests are successful, create binary packages for the project.
- python setup.py bdist_wheel
# - python setup.py bdist_wininst
# - ps: "ls dist"
- ps: "ls dist"

#artifacts:
artifacts:
# # Archive the generated packages in the ci.appveyor.com build report.
# - path: dist\*
- path: dist\*

#on_success:
# - TODO: upload the content of dist/*.whl to a public wheelhouse
#
on_success:
- ps: If ($env:APPVEYOR_REPO_TAG -eq "true" -And $env:APPVEYOR_REPO_BRANCH -eq "master") { Invoke-Expression "twine upload --skip-existing dist/*" } Else { write-output "Only deploy to PyPi for tags on master!"}
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import src.urh.version as version

if sys.platform == "win32":
OPEN_MP_FLAG = "-openmp"
OPEN_MP_FLAG = "/openmp"
elif sys.platform == "darwin":
OPEN_MP_FLAG = "" # no OpenMP support in default Mac OSX compiler
else:
Expand Down Expand Up @@ -71,8 +71,6 @@ def get_package_data():
for plugin in PLUGINS:
package_data["urh.plugins." + plugin] = ['*.ui', "*.txt"]

is_release = os.path.isfile("/tmp/urh_releasing") # make sure precompiled binding are uploaded to PyPi

package_data["urh.dev.native.lib"] = ["*.cpp", "*.c", "*.pyx", "*.pxd"]

# Bundle headers
Expand All @@ -83,9 +81,9 @@ def get_package_data():
rel_dir_path = os.path.relpath(os.path.join(dirpath, dir_name), include_dir)
package_data["urh.dev.native.includes."+rel_dir_path.replace(os.sep, ".")] = ["*.h"]

if sys.platform == "win32" or is_release:
# we use precompiled device backends on windows
package_data["urh.dev.native.lib.win"] = ["*"]
# we use precompiled device backends on windows
package_data["urh.dev.native.lib.win.x64"] = ["*"]
package_data["urh.dev.native.lib.win.x86"] = ["*"]

return package_data

Expand Down
2 changes: 1 addition & 1 deletion src/urh/dev/native/ExtensionHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_device_extensions(use_cython: bool, library_dirs=None):
return [] # only 64 bit python supported for native device backends

result = []
lib_dir = os.path.realpath(os.path.join(cur_dir, "lib/win"))
lib_dir = os.path.realpath(os.path.join(cur_dir, "lib/win/x64"))
for dev_name, params in DEVICES.items():
result.append(get_device_extension(dev_name, [params["lib"]], [lib_dir], include_dirs))

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added src/urh/dev/native/lib/win/x64/vcomp140.dll
Binary file not shown.
File renamed without changes.
Binary file added src/urh/dev/native/lib/win/x86/vcomp140.dll
Binary file not shown.
12 changes: 3 additions & 9 deletions src/urh/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ def main():
print("You need at least Python 3.4 for this application!")
sys.exit(1)

if sys.platform == "win32":
urh_dir = os.path.dirname(os.path.realpath(__file__)) if not os.path.islink(__file__) \
else os.path.dirname(os.path.realpath(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']

t = time.time()
if GENERATE_UI and not hasattr(sys, 'frozen'):
try:
Expand Down Expand Up @@ -59,6 +50,9 @@ def main():
print("Adding {0} to pythonpath. This is only important when running URH from source.".format(src_dir))
sys.path.insert(0, src_dir)

from urh.util import util
util.set_windows_lib_path()

try:
import urh.cythonext.signalFunctions
import urh.cythonext.path_creator
Expand Down
15 changes: 15 additions & 0 deletions src/urh/util/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import sys


def set_windows_lib_path():
if sys.platform == "win32":
util_dir = os.path.dirname(os.path.realpath(__file__)) if not os.path.islink(__file__) \
else os.path.dirname(os.path.realpath(os.readlink(__file__)))
urh_dir = os.path.realpath(os.path.join(util_dir, ".."))
assert os.path.isdir(urh_dir)

arch = "x64" if sys.maxsize > 2**32 else "x86"
dll_dir = os.path.realpath(os.path.join(urh_dir, "dev", "native", "lib", "win", arch))
print("Using DLLs from:", dll_dir)
os.environ['PATH'] = os.environ['PATH'] + ";" + dll_dir
2 changes: 1 addition & 1 deletion src/urh/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "1.6.4.2"
VERSION = "1.6.4.3"
8 changes: 3 additions & 5 deletions tests/HackRFTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import numpy as np
import sys

if sys.platform == "win32":
import os
cur_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
dll_dir = os.path.realpath(os.path.join(cur_dir, "..", "src", "urh", "dev", "native", "lib", "win"))
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']
from urh.util import util

util.set_windows_lib_path()


from urh.dev.native.HackRF import HackRF
Expand Down
7 changes: 2 additions & 5 deletions tests/TestLimeSDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@

import numpy as np

if sys.platform == "win32":
from urh.util import util


cur_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
dll_dir = os.path.realpath(os.path.join(cur_dir, "..", "src", "urh", "dev", "native", "lib", "win"))
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']
util.set_windows_lib_path()

from urh.dev.native.lib import limesdr

Expand Down
8 changes: 3 additions & 5 deletions tests/TestRTLSDR.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

import numpy as np

if sys.platform == "win32":
import os
cur_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
dll_dir = os.path.realpath(os.path.join(cur_dir, "..", "src", "urh", "dev", "native", "lib", "win"))
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']
from urh.util import util

util.set_windows_lib_path()

from urh.dev.native.RTLSDR import RTLSDR
try:
Expand Down
8 changes: 3 additions & 5 deletions tests/TestUSRP.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import sys

if sys.platform == "win32":
import os
cur_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(os.readlink(__file__))
dll_dir = os.path.realpath(os.path.join(cur_dir, "..", "src", "urh", "dev", "native", "lib", "win"))
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']
from urh.util import util

util.set_windows_lib_path()


from urh.dev.native.USRP import USRP
Expand Down
8 changes: 3 additions & 5 deletions tests/test_win_native_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ class TestWinNativeBackend(QtTestCase):
def test_native_backends_installed(self):
if sys.platform == "win32":
if platform.architecture()[0] == "64bit":
import os
cur_dir = os.path.dirname(__file__) if not os.path.islink(__file__) else os.path.dirname(
os.readlink(__file__))
dll_dir = os.path.realpath(os.path.join(cur_dir, "..", "src", "urh", "dev", "native", "lib", "win"))
os.environ['PATH'] = dll_dir + ';' + os.environ['PATH']
from urh.util import util

util.set_windows_lib_path()

# noinspection PyUnresolvedReferences
from urh.dev.native.lib import hackrf
Expand Down

0 comments on commit 353ce68

Please sign in to comment.