Commit 5503c141 authored by Damien Naudet's avatar Damien Naudet

first time load

parents
language: python
matrix:
include:
- python: 2.7
os: linux
env: BUILD_COMMAND=sdist
- python: 3.4
os: linux
env: BUILD_COMMAND=sdist
- python: 3.5
os: linux
env: BUILD_COMMAND=sdist
- language: generic
os: osx
env: BUILD_COMMAND=bdist_wheel
cache:
apt: true
addons:
apt:
packages:
- libhdf5-serial-1.8.4
- libhdf5-serial-dev
install:
# Mac OS X specific bootstrap
- source ./ci/travis_osx.sh
- travis_osx_install_begin
# Upgrade distribution modules
- pip install --upgrade setuptools
- pip install --upgrade pip
# Install build dependencies
- pip install wheel
- pip install --trusted-host www.edna-site.org --find-links http://www.edna-site.org/pub/wheelhouse/ numpy
# Print Python info
- python ./ci/info_platform.py
- pip freeze
# Generate source package or wheel
- python setup.py $BUILD_COMMAND
- ls dist
# Mac OS X specific cleanup
- travis_osx_install_end
script:
# Mac OS X specific bootstrap
- travis_osx_run_begin
# Upgrade distribution modules
- pip install --upgrade setuptools
- pip install --upgrade pip
# Install from source package
- pip install --pre --find-links dist/ --trusted-host www.edna-site.org --find-links http://www.edna-site.org/pub/wheelhouse/ kmap
# Print Python info
- python ci/info_platform.py
- pip freeze
# Run the tests
- python run_tests.py
# Mac OS X specific cleanup
- travis_osx_run_end
Change Log
==========
Unreleased
----------
include README.rst
include MANIFEST.in
include run_tests.py
recursive-include kmap *.pyx *.pxd *.pxi
recursive-include kmap *.h *.c *.cpp
recursive-include doc/source *.py *.rst *.png *.ico
kmap
====
TBD
Installation
------------
The latest development version can be obtained from the git repository::
git clone https://github.com/kmap/kmap.git
cd kmap
pip install . [--user]
Dependencies
------------
* `Python <https://www.python.org/>`_ 2.7, 3.4 and 3.5.
* `numpy <http://www.numpy.org>`_
* `h5py <http://www.h5py.org/>`_
* `silx <tbd>`_
* A Qt binding: `PyQt5, PyQt4 <https://riverbankcomputing.com/software/pyqt/intro>`_ or `PySide <https://pypi.python.org/pypi/PySide/>`_
Supported platforms: Linux, Windows, Mac OS X.
Documentation
-------------
To build the documentation from the source (requires `Sphinx <http://www.sphinx-doc.org>`_), run::
python setup.py build build_doc
Testing
-------
|Travis Status| |Appveyor Status|
To run the tests, from the source directory, run::
python run_tests.py
License
-------
The source code of kmap is licensed under the MIT and LGPL licenses.
See the `copyright file TBD`_ for details.
.. |Travis Status| image:: TBD
.. |Appveyor Status| image:: TBD
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Bootstrap helps you to test scripts without installing them
by patching your PYTHONPATH on the fly
example: ./bootstrap.py ipython
"""
__authors__ = ["Frédéric-Emmanuel Picca", "Jérôme Kieffer"]
__contact__ = "jerome.kieffer@esrf.eu"
__license__ = "MIT"
__date__ = "27/11/2015"
import sys
import os
import shutil
import distutils.util
import subprocess
TARGET = os.path.basename(os.path.dirname(os.path.abspath(__file__))).split("-")[0]
def _copy(infile, outfile):
"link or copy file according to the OS. Nota those are HARD_LINKS"
if "link" in dir(os):
os.link(infile, outfile)
else:
shutil.copy(infile, outfile)
def _distutils_dir_name(dname="lib"):
"""
Returns the name of a distutils build directory
"""
platform = distutils.util.get_platform()
architecture = "%s.%s-%i.%i" % (dname, platform,
sys.version_info[0], sys.version_info[1])
return architecture
def _distutils_scripts_name():
"""Return the name of the distrutils scripts sirectory"""
f = "scripts-{version[0]}.{version[1]}"
return f.format(version=sys.version_info)
def _get_available_scripts(path):
res = []
try:
res = " ".join([s.rstrip('.py') for s in os.listdir(path)])
except OSError:
res = ["no script available, did you ran "
"'python setup.py build' before bootstrapping ?"]
return res
def _copy_files(source, dest, extn):
"""
copy all files with a given extension from source to destination
"""
if not os.path.isdir(dest):
os.makedirs(dest)
full_src = os.path.join(os.path.dirname(__file__), source)
for clf in os.listdir(full_src):
if clf.endswith(extn) and clf not in os.listdir(dest):
_copy(os.path.join(full_src, clf), os.path.join(dest, clf))
def runfile(fname):
try:
execfile(fname)
except SyntaxError:
env = os.environ.copy()
env.update({"PYTHONPATH": LIBPATH + os.pathsep + os.environ.get("PYTHONPATH", ""),
"PATH": SCRIPTSPATH + os.pathsep + os.environ.get("PATH", "")})
run = subprocess.Popen(sys.argv, shell=False, env=env)
run.wait()
home = os.path.dirname(os.path.abspath(__file__))
SCRIPTSPATH = os.path.join(home,
'build', _distutils_scripts_name())
LIBPATH = (os.path.join(home,
'build', _distutils_dir_name('lib')))
if (not os.path.isdir(SCRIPTSPATH)) or (not os.path.isdir(LIBPATH)):
build = subprocess.Popen([sys.executable, "setup.py", "build"],
shell=False, cwd=os.path.dirname(__file__))
print("Build process ended with rc= %s" % build.wait())
# _copy_files("openCL", os.path.join(LIBPATH, TARGET, "openCL"), ".cl")
# _copy_files("gui", os.path.join(LIBPATH, TARGET, "gui"), ".ui")
# _copy_files("calibration", os.path.join(LIBPATH, TARGET, "calibration"), ".D")
if __name__ == "__main__":
if len(sys.argv) < 2:
print("usage: ./bootstrap.py <script>\n")
print("Available scripts : %s\n" %
_get_available_scripts(SCRIPTSPATH))
sys.exit(1)
os.system("cd %s;python setup.py build; cd -" % home)
print("Executing %s from source checkout" % (sys.argv[1]))
sys.path.insert(0, LIBPATH)
print("01. Patched sys.path with %s" % LIBPATH)
sys.path.insert(0, SCRIPTSPATH)
print("02. Patched sys.path with %s" % SCRIPTSPATH)
script = sys.argv[1]
sys.argv = sys.argv[1:]
print("03. patch the sys.argv : ", sys.argv)
print("04. Executing %s.main()" % (script,))
fullpath = os.path.join(SCRIPTSPATH, script)
if os.path.exists(fullpath):
runfile(fullpath)
else:
if os.path.exists(script):
runfile(script)
else:
for dirname in os.environ.get("PATH", "").split(os.pathsep):
fullpath = os.path.join(dirname, script)
if os.path.exists(fullpath):
runfile(fullpath)
break
os:
- Visual Studio 2015
cache:
- '%LOCALAPPDATA%\pip\Cache'
# fetch repository as zip archive
shallow_clone: true
environment:
global:
WIN_SDK_ROOT: "C:\\Program Files\\Microsoft SDKs\\Windows"
VENV_BUILD_DIR: "venv_build"
VENV_TEST_DIR: "venv_test"
matrix:
# Python 3.5
- PYTHON_DIR: "C:\\Python35-x64"
QT_BINDINGS: "PyQt5"
# Python 2.7
- PYTHON_DIR: "C:\\Python27-x64"
QT_BINDINGS: "PyQt4"
- PYTHON_DIR: "C:\\Python27-x64"
QT_BINDINGS: "PySide"
install:
# Add Python to PATH
- "SET PATH=%PYTHON_DIR%;%PYTHON_DIR%\\Scripts;%PATH%"
# Upgrade distribution modules
# Disabled as pip uprade fails
# - "pip install --upgrade setuptools"
# - "pip install --upgrade pip"
# Install virtualenv
- "pip install virtualenv"
- "virtualenv --version"
build_script:
# Create build virtualenv
- "virtualenv --clear %VENV_BUILD_DIR%"
- "%VENV_BUILD_DIR%\\Scripts\\activate.bat"
# Install buils dependencies
- "pip install wheel"
- "pip install --trusted-host www.edna-site.org --find-links http://www.edna-site.org/pub/wheelhouse/ numpy"
# Print Python info
- "python ci\\info_platform.py"
- "pip freeze"
# Build
- "python setup.py bdist_wheel bdist_msi"
- ps: "ls dist"
# Leave build virtualenv
- "%VENV_BUILD_DIR%\\Scripts\\deactivate.bat"
- "rmdir %VENV_BUILD_DIR% /s /q"
test_script:
# Create test virtualenv
- "virtualenv --clear %VENV_TEST_DIR%"
- "%VENV_TEST_DIR%\\Scripts\\activate.bat"
# Install Qt binding and matplotlib (until they are dependencies)
# Install PyQt4 from www.edna-site.org and PyQt5/PySide from pypi
- "pip install --pre --trusted-host www.edna-site.org --find-links http://www.edna-site.org/pub/wheelhouse/ %QT_BINDINGS%"
- "pip install matplotlib"
# Install the generated wheel package to test it
#- "pip install --pre --find-links dist/ --trusted-host www.edna-site.org --find-links http://www.edna-site.org/pub/wheelhouse/ kmap"
# Print Python info
- "python ci\\info_platform.py"
- "pip freeze"
- "python run_tests.py"
# Leave test virtualenv
- "%VENV_TEST_DIR%\\Scripts\\deactivate.bat"
- "rmdir %VENV_TEST_DIR% /s /q"
artifacts:
# Archive the generated wheel package in the ci.appveyor.com build report.
- path: dist\*
#!/usr/bin/env python
# coding: utf-8
"""Print information about python."""
__authors__ = ["Jérôme Kieffer"]
__date__ = "08/12/2015"
__license__ = "MIT"
import sys
print("Python %s bits" % (tuple.__itemsize__ * 8))
print(" maxsize: %s\t maxunicode: %s" % (sys.maxsize, sys.maxunicode))
print(sys.version)
print(" ")
try:
from distutils.sysconfig import get_config_vars
except ImportError:
from sysconfig import get_config_vars
print("Config: " + str(get_config_vars("CONFIG_ARGS")))
print("")
try:
import numpy
except ImportError:
print("Numpy not installed")
else:
print("Numpy %s" % numpy.version.version)
print(" include %s" % numpy.get_include())
print(" options %s" % numpy.get_printoptions())
print("")
#!/bin/bash
# Script for travis-CI Mac OS X specific setup.
#
# It provides 4 functions:
# - travis_osx_install_begin: Install pip and setup a virtualenv for the build
# - travis_osx_install_end: Deactivate the build virtualenv
# - travis_osx_run_begin: Setup a virtualenv for the tests
# - travis_osx_run_end: Deactivate test virtualenv
#
# On Linux, those functions do nothing.
# Directory where to create build virtualenv
VENV_BUILD_DIR=./venv_build
# Directory qhere to create test virtualenv
VENV_TEST_DIR=./venv_test
if [ "$TRAVIS_OS_NAME" != "osx" ]; then
function travis_osx_install_begin {
echo NoOp
}
function travis_osx_install_end {
echo NoOp
}
function travis_osx_run_begin {
echo NoOp
}
function travis_osx_run_end {
echo NoOp
}
else
function travis_osx_install_begin {
echo Mac OS X install begin: Install pip and setup build venv
set -x # echo on
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
pip install virtualenv --user
virtualenv --version
virtualenv --clear $VENV_BUILD_DIR
set +x # echo off
echo "Activate virtualenv $VENV_BUILD_DIR"
source $VENV_BUILD_DIR/bin/activate
}
function travis_osx_install_end {
echo Mac OS X install end: Deactivate and delete virtualenv
echo deactivate
deactivate
set -x # echo on
rm -rf $VENV_BUILD_DIR
set +x # echo off
}
function travis_osx_run_begin {
echo Mac OS X run begin: Setup test venv
set -x # echo on
virtualenv --clear $VENV_TEST_DIR
set +x # echo off
echo "Activate virtualenv $VENV_TEST_DIR"
source $VENV_TEST_DIR/bin/activate
}
function travis_osx_run_end {
echo Mac OS X run end: Deactivate and delete virtualenv
echo deactivate
deactivate
set -x # echo on
rm -rf $VENV_TEST_DIR
set +x # echo off
}
fi
machine:
python:
version: 2.7
checkout:
post:
# Clean-up to make sure we start from a fresh build env
- rm -rf dist/ build/
dependencies:
pre:
# Install deb packages
#- sudo apt-get update
- sudo apt-get install libhdf5-serial-1.8.4 libhdf5-serial-dev
# Upgrade distribution modules
- pip install --upgrade setuptools
- pip install --upgrade pip
# Install build dependencies
- pip install --upgrade wheel
- pip install --upgrade numpy cython
# Print Python info
- python ./ci/info_platform.py
- pip freeze
override:
# Build
- python setup.py sdist bdist_wheel
# Copy source tarball to artifacts
- cp dist/*.tar.gz $CIRCLE_ARTIFACTS
# Install generated wheel and its dependencies
- pip install --upgrade --pre --find-links dist/ kmap
post:
# Clean-up
- python setup.py clean --all
# Uninstall kmap before caching
# Hack to avoid caching installed package
- pip uninstall --yes kmap
test:
pre:
# Install generated wheel
- pip install --pre --find-links dist/ kmap
override:
# Print Python info
- python ci/info_platform.py
- pip freeze
# Run the tests
- python run_tests.py
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: kmap
Source: https://github.com/kmap-project
Files: *
Copyright: 2015-2016 European Synchrotron Radiation Facility
Data analysis unit (kmap@esrf.fr)
License: MIT
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
License: BSD-3
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of the <organization> nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT
HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License: GPL-3.0+
This package is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This package is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
.
On Debian systems, the complete text of the GNU General
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
License: public-domain
You can use this free for any purpose. It's in the public domain. It
has no warranty
License: LGPL-2.1+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
.
On Debian systems, the complete text of the GNU Lesser General Public
License can be found in "/usr/share/common-licenses/LGPL-2.1".
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
from __future__ import absolute_import, print_function, division
__authors__ = ["Jérôme Kieffer"]
__license__ = "MIT"
__date__ = "28/01/2016"
import os
project = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
try:
from ._version import __date__ as date # noqa
from ._version import version, version_info, hexversion, strictversion # noqa
except ImportError:
raise RuntimeError(
"Do NOT use %s from its sources: build it and use the built version" % project)
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2015-2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
__authors__ = ["D. Naudet"]
__license__ = "MIT"
__date__ = "01/03/2016"
# coding: utf-8
# /*##########################################################################
# Copyright (C) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ############################################################################*/
__authors__ = ["D. Naudet"]
__license__ = "MIT"
__date__ = "20/04/2016"
import time
cimport numpy as np
cimport cython
import numpy as np
from cython.parallel import prange, threadid
ctypedef fused data_t:
numpy.float64_t
# numpy.float32_t
# numpy.int32_t
# numpy.int64_t
def medfilt2D(image,
kernel=(3, 3)):
image_c = np.ascontiguousarray(image.reshape(-1))
kernel_c = np.ascontiguousarray(kernel.reshape(-1),
dtype=np.int32)
def _histogramnd_get_lut_fused(sample_t[:] i_sample,
int i_n_dims,
int i_n_elems,
sample_t[:] i_bins_rng,
int[:] i_n_bins,
lut_t[:] o_lut,
numpy.uint32_t[:] o_histo,
bint last_bin_closed):
This diff is collapsed.
# /*##########################################################################
# coding: utf-8
# Copyright (C) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: