From c51cfb42da77a54b0db328877c6fcf42d366bac9 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Tue, 11 May 2021 09:06:38 +0100 Subject: [PATCH] Conda package (#2) * added conda recipe to create data package * add build script for linux Co-authored-by: Edoardo Pasca --- recipe/bld.bat | 2 ++ recipe/build.sh | 2 ++ recipe/meta.yaml | 16 +++++++++++++++ setup.py | 47 +++++++++++++++++++++++++++++++++++++++++++++ test/manual_test.py | 22 +++++++++++++++++++++ 5 files changed, 89 insertions(+) create mode 100644 recipe/bld.bat create mode 100644 recipe/build.sh create mode 100644 recipe/meta.yaml create mode 100644 setup.py create mode 100644 test/manual_test.py diff --git a/recipe/bld.bat b/recipe/bld.bat new file mode 100644 index 0000000..ca59e53 --- /dev/null +++ b/recipe/bld.bat @@ -0,0 +1,2 @@ +cd %RECIPE_DIR%\.. +%PYTHON% setup.py install \ No newline at end of file diff --git a/recipe/build.sh b/recipe/build.sh new file mode 100644 index 0000000..aa59b4d --- /dev/null +++ b/recipe/build.sh @@ -0,0 +1,2 @@ +cd $RECIPE_DIR/.. +$PYTHON setup.py install \ No newline at end of file diff --git a/recipe/meta.yaml b/recipe/meta.yaml new file mode 100644 index 0000000..99900b8 --- /dev/null +++ b/recipe/meta.yaml @@ -0,0 +1,16 @@ +package: + name: cil-data + version: 21.0.0 + +build: + number: 0 + +requirements: + + build: + - python + +about: + home: http://www.ccpi.ac.uk/cil + license: Apache 2.0 License + summary: 'CCPi Core Imaging Library' \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8045586 --- /dev/null +++ b/setup.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# CCP in Tomographic Imaging (CCPi) Core Imaging Library (CIL). + +# Copyright 2017 UKRI-STFC +# Copyright 2017 University of Manchester + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from distutils.core import setup +import os +import sys + + +cil_version='21.0.0' + +setup( + name="cil-data", + version=cil_version, + data_files = [('share/cil', [ '24737_fd_normalised.nxs', + 'boat.tiff', + 'camera.png', + 'peppers.tiff', + 'rainbow.png', + 'resolution_chart.tiff', + 'shapes.png' + ])], + + # metadata for upload to PyPI + author="CCPi developers", + maintainer="Edoardo Pasca", + maintainer_email="edoardo.pasca@stfc.ac.uk", + description='CCPi Core Imaging Library - Example Data', + license="Apache v2.0", + keywords="Dataset", + url="http://www.ccpi.ac.uk/cil", # project home page, if any + +) \ No newline at end of file diff --git a/test/manual_test.py b/test/manual_test.py new file mode 100644 index 0000000..94de639 --- /dev/null +++ b/test/manual_test.py @@ -0,0 +1,22 @@ +import os, sys +import matplotlib.pyplot as plt +import numpy as np +from PIL import Image + +data_dir = os.path.abspath( + os.path.join(sys.prefix, 'share','cil') +) + +pics = ['boat.tiff', 'camera.png', 'rainbow.png', 'resolution_chart.tiff', 'shapes.png'] +for which in pics: + dpath = os.path.join(data_dir, which) + with Image.open(dpath) as f: + print("opening {}".format(dpath)) + bands = f.getbands() + if len(bands) > 1: + if len(bands) == 4: + f = f.convert('RGB') + bands = f.getbands() + plt.imshow(f) + plt.show() +