Commit f98cd6eb authored by Carsten Richter's avatar Carsten Richter

Merge branch 'windows' into 'master'

Add Windows support

Closes #51

See merge request !74
parents 8cfb0dbc 85543c40
Pipeline #5073 passed with stages
in 4 minutes and 57 seconds
......@@ -10,7 +10,7 @@ X-SOCS aims at retrieving strain and tilt maps of nanostructures, films, surface
Installation
------------
X-SOCS runs on Linux with `Python <https://www.python.org/>`_ >=3.4 or 2.7.
X-SOCS runs on Linux and Windows with `Python <https://www.python.org/>`_ >=3.4.
See `How to install XSocs <http://kmap.gitlab-pages.esrf.fr/xsocs/install.html>`_ for details and dependencies.
......
......@@ -187,25 +187,25 @@ def find_executable(target):
return None, None
home = os.path.dirname(os.path.abspath(__file__))
LIBPATH = os.path.join(home, 'build', _distutils_dir_name('lib'))
cwd = os.getcwd()
os.chdir(home)
build = subprocess.Popen([sys.executable, "setup.py", "build"],
shell=False, cwd=os.path.dirname(os.path.abspath(__file__)))
build_rc = build.wait()
if not os.path.exists(LIBPATH):
logger.warning("`lib` directory does not exist, trying common Python3 lib")
LIBPATH = os.path.join(os.path.split(LIBPATH)[0], "lib")
os.chdir(cwd)
if build_rc == 0:
logger.info("Build process ended.")
else:
logger.error("Build process ended with rc=%s", build_rc)
sys.exit(-1)
if __name__ == "__main__":
home = os.path.dirname(os.path.abspath(__file__))
LIBPATH = os.path.join(home, 'build', _distutils_dir_name('lib'))
cwd = os.getcwd()
os.chdir(home)
build = subprocess.Popen([sys.executable, "setup.py", "build"],
shell=False, cwd=os.path.dirname(os.path.abspath(__file__)))
build_rc = build.wait()
if not os.path.exists(LIBPATH):
logger.warning("`lib` directory does not exist, trying common Python3 lib")
LIBPATH = os.path.join(os.path.split(LIBPATH)[0], "lib")
os.chdir(cwd)
if build_rc == 0:
logger.info("Build process ended.")
else:
logger.error("Build process ended with rc=%s", build_rc)
sys.exit(-1)
if len(sys.argv) < 2:
logger.warning("usage: ./bootstrap.py <script>\n")
script = None
......
This diff is collapsed.
......@@ -29,10 +29,13 @@ __authors__ = ["D. Naudet"]
__license__ = "MIT"
__date__ = "15/09/2016"
import logging
import sys
_logger = logging.getLogger(__name__)
from silx.gui import qt as Qt
print('Using Qt {0}'.format(Qt.qVersion()))
_logger.info('Using Qt {0}'.format(Qt.qVersion()))
from .XsocsGui import XsocsGui
from .process.MergeWidget import MergeWidget
......
......@@ -259,17 +259,11 @@ class KmapMerger(object):
else:
n_proc = self.__n_proc
def init(term_evt_, shared_progress_):
global g_term_evt
global g_shared_progress
g_term_evt = term_evt_
g_shared_progress = shared_progress_
# setting progress to 0
np.frombuffer(self.__shared_progress, dtype='int32')[:] = 0
pool = Pool(n_proc,
initializer=init,
initializer=_init_process,
initargs=(term_evt,
self.__shared_progress),
maxtasksperchild=2)
......@@ -711,6 +705,17 @@ def parse_scan_command(command):
# #######################################################################
# #######################################################################
def _init_process(term_evt_, shared_progress_):
"""Init function for process
:param term_evt_: Process terminaison event
:param shared_progress_: Shared progress array
"""
global g_term_evt
global g_shared_progress
g_term_evt = term_evt_
g_shared_progress = shared_progress_
def _add_edf_data(scan_id,
proc_idx,
......
......@@ -33,6 +33,7 @@ __date__ = "05/01/2016"
import os
import shutil
import sys
import tempfile
import unittest
......@@ -46,19 +47,14 @@ from xsocs.process.fit.peak_fit import PeakFitter
from xsocs.io.FitH5 import FitH5
# ==============================================================
# ==============================================================
# ==============================================================
def _cmp_fit_h5_files(test_case, ref_h5, this_h5):
"""
Compares two FitH5 files.
"""Compares two FitH5 files.
:param test_case:
:param ref_h5:
:param this_h5:
:return:
"""
ref_entries = ref_h5.entries()
this_entries = this_h5.entries()
......@@ -69,15 +65,14 @@ def _cmp_fit_h5_files(test_case, ref_h5, this_h5):
def _cmp_fit_h5_processes(test_case, ref_h5, this_h5, entry):
"""
Compares two FitH5 files
"""Compares two FitH5 files
:param test_case:
:param ref_h5:
:param this_h5:
:param entry:
:return:
"""
ref_processes = ref_h5.processes(entry)
this_processes = this_h5.processes(entry)
test_case.assertEqual(ref_processes, this_processes)
......@@ -95,8 +90,8 @@ def _cmp_fit_h5_results(test_case,
this_h5,
entry,
process):
"""
Compares two FitH5 files
"""Compares two FitH5 files
:param test_case:
:param ref_h5:
:param this_h5:
......@@ -104,7 +99,6 @@ def _cmp_fit_h5_results(test_case,
:param process:
:return:
"""
ref_results = ref_h5.get_result_names(
entry, process)
this_results = this_h5.get_result_names(
......@@ -112,24 +106,27 @@ def _cmp_fit_h5_results(test_case,
test_case.assertEqual(ref_results, this_results)
if sys.platform == 'win32': # Relax tests on Windows
compare_arrays = np.allclose
else:
compare_arrays = np.array_equal
for result in ref_results:
ref_qx = ref_h5.get_qx_result(entry, process, result)
this_qx = this_h5.get_qx_result(entry, process, result)
test_case.assertTrue(np.array_equal(ref_qx, this_qx))
test_case.assertTrue(compare_arrays(ref_qx, this_qx))
ref_qy = ref_h5.get_qy_result(entry, process, result)
this_qy = this_h5.get_qy_result(entry, process, result)
test_case.assertTrue(np.array_equal(ref_qy, this_qy))
test_case.assertTrue(compare_arrays(ref_qy, this_qy))
ref_qz = ref_h5.get_qz_result(entry, process, result)
this_qz = this_h5.get_qz_result(entry, process, result)
test_case.assertTrue(np.array_equal(ref_qz, this_qz))
test_case.assertTrue(compare_arrays(ref_qz, this_qz))
class TestPeakFitter(ParametricTestCase):
"""
Unit tests of the qspace converter class.
"""
"""Unit tests of the qspace converter class."""
@classmethod
def setUpClass(cls):
......@@ -155,9 +152,6 @@ class TestPeakFitter(ParametricTestCase):
self._tmpTestDir = None
def test_nominal(self):
"""
"""
manager = self._manager
keys = ['fit_f', 'qspace_f']
......@@ -198,21 +192,11 @@ class TestPeakFitter(ParametricTestCase):
_cmp_fit_h5_files(self, fit_ref_h5, fit_out_h5)
# ==============================================================
# ==============================================================
# ==============================================================
test_cases = (TestPeakFitter
,)
def suite():
loader = unittest.defaultTestLoader
test_suite = unittest.TestSuite()
for test_class in test_cases:
tests = loader.loadTestsFromTestCase(test_class)
test_suite.addTests(tests)
test_suite.addTests(
loader.loadTestsFromTestCase(TestPeakFitter))
return test_suite
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment