Skip to content

Commit

Permalink
Merge pull request #130 from jonwright/master
Browse files Browse the repository at this point in the history
make it pip installable with --editable
  • Loading branch information
jonwright authored Apr 8, 2021
2 parents d472d1a + 6ed24d9 commit 57a39f4
Show file tree
Hide file tree
Showing 119 changed files with 133 additions and 83 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ jobs:
command: |
python3 -m venv venv
. venv/bin/activate
pip install six numpy scipy fabio pillow matplotlib pyopengl xfab pyopengltk h5py PyCifRW
python setup.py build install
python3 -m pip install pip setuptools --upgrade
python3 -m pip install pytest numpy
python3 -m pip install --editable .
- save_cache:
key: ImageD11-{{arch}}-{{ checksum "setup.py" }}
paths:
- ./venv

# run tests!
# run tests
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose
# https://pytest.org
Expand All @@ -48,8 +49,7 @@ jobs:
name: run tests
command: |
. venv/bin/activate
cd test
python run_tests.py
python3 -m pytest
- store_artifacts:
path: test-reports
Expand Down
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ jobs:
osx_image: xcode11.2 # Python 3.7.4 running on macOS 10.14.4
language: shell # 'language: python' is an error on Travis CI macOS
install:
- pip3 install --upgrade pip # all three OSes agree about 'pip3'
- pip3 install .
- pip3 install --upgrade pip setuptools # all three OSes agree about 'pip3'
- pip3 install pytest numpy
- pip3 install --editable .
# 'python3' is a 'command not found' error on Windows but 'py' works on Windows only
script:
- cd test && OMP_NUM_THREADS=2 python3 run_tests.py
- OMP_NUM_THREADS=2 python3 -m pytest
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 16 additions & 2 deletions ImageD11src/cImageD11.py → ImageD11/cImageD11.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@


# check for avx2 and import cImageD11 module
# import cImageD11 compiled module and patch the docstrings

import sys
import struct
from ImageD11 import cImageD11_docstrings
from ImageD11._cImageD11 import *

try:
from ImageD11._cImageD11 import *
except ImportError:
print("Failed to import compiled C code for cImageD11 module")
print("Are you running from a source directory?")
print("Try something like:")
print(" python -m pip install --editable .")
print("or:")
print(" python setup.py develop")
print("or:")
print(" python setup.py build_ext --inplace")
sys.exit()

# For 32 or 64 bits
nbyte = struct.calcsize("P") # 4 or 8
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.
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.
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.
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.
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.
29 changes: 8 additions & 21 deletions ImageD11src/tkGui/twodplot.py → ImageD11/tkGui/twodplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,27 +337,14 @@ def on_up(self,event):


if __name__=="__main__":
import epffile, powbase, mcadata, ciidata
if len(sys.argv)<3:
import numpy as np
from math import pi
print("Usage: %s filename format"%(sys.argv[0]))
x=np.arange(0.0,3.0,0.01)
dat=epffile.powderdata(x,
np.sin(2*pi*x)+5,
np.sqrt(sin(2*pi*x)+5),
{ "title":"sin x" })
else:
try:
if sys.argv[2]=="powbase":
dat=powbase.powbase(sys.argv[1])
if sys.argv[2]=="epf":
dat=epffile.epffile(sys.argv[1])
if sys.argv[2]=="mca":
dat=mcadata.mcadata(sys.argv[1])
except:
print("Could not read your file %s" % (sys.argv[1]))
raise

import numpy as np
from math import pi
x=np.arange(0.0,3.0,0.01)
dat=epffile.powderdata(x,
np.sin(2*pi*x)+5,
np.sqrt(sin(2*pi*x)+5),
{ "title":"sin x" })

root = Tk.Tk()
root.wm_title("Two dimensional plotting")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ Version 1.9.8, Jon Wright, [email protected]

This is the source code for ImageD11. Probably you wanted a compiled version.

You can try to get it via:

`pip install ImageD11`
If your pip is up-to-date, you can try to install it like this (numpy is needed
to compile):
```
python -m pip install --upgrade pip setuptools
python -m pip install numpy
python -m pip install ImageD11
```
To get all the possible dependencies too, you can try:
`python -m pip install ImageD11[full]`

Some (dated) documentation is here: https://imaged11.readthedocs.io/

Expand All @@ -17,15 +23,15 @@ If you are at ESRF on an old linux computer you can try "module load fable".
To use from git, try this:

- Download and install python 3.7+, perhaps from www.python.org but probably from conda.
- Preload packages from conda (or your system package manager): numpy, scipy, matplotlib, h5py, pillow, pycifrw, xfab
- Preload binary packages from conda (or your system package manager):
numpy, scipy, matplotlib, h5py, pillow, pycifrw, xfab, pyqt, pillow, silx[full] etc
- `pip install git+https://github.com/FABLE-3DXRD/ImageD11.git`

If you want the sources then checkout like this:
If you want to work with the sources then you can try like this:
```
$ python -m pip install --upgrade pip
$ git clone https://github.com/FABLE-3DXRD/ImageD11.git && cd ImageD11
$ python setup.py build bdist_wheel
Followed by installation in your virtual or conda environment:
$ pip install dist/ImageD11_[version you built].whl
$ python -m pip install --editable .
```

After it is installed, you should find a script ImageD11_gui.py, somewhere in your path.
Expand Down
11 changes: 5 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ install:
- "SET PATH=%CONDA%;%CONDA%\\Scripts;%CONDA%\\Library\\bin;%CONDA%\\DLLS;%PATH%"
- conda config --set always_yes yes --set changeps1 no
- conda info -a
- python -m pip install --upgrade pip
- python -m pip install numpy h5py==2.10.0 --only-binary=h5py
- python setup.py build
- python -m pip install --ignore-installed certifi --upgrade-strategy only-if-needed --only-binary=h5py .
- python -m pip install --upgrade pip setuptools
- python -m pip install pytest numpy
- python -m pip install --ignore-installed certifi --upgrade-strategy only-if-needed --only-binary=h5py --editable .


test_script:
- cd test
- python run_tests.py
- python -m pytest

3 changes: 2 additions & 1 deletion sandbox/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def update_wtd( recon, proj, angle, msk, dbg=True ):


def make_data():
import rad, Image
import rad
from PIL import Image
im = Image.open("phantom3.gif")
a = np.asarray(im).astype(np.float32)
print(a.min(),a.max())
Expand Down
2 changes: 2 additions & 0 deletions sandbox/bgfilter_grab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@


from __future__ import print_function
#import multiprocessing, os
#cpu = str(multiprocessing.cpu_count())-1
#os.environ['OPENBLAS_NUM_THREADS']=cpu
Expand Down
2 changes: 1 addition & 1 deletion sandbox/ev78/integrate_them.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python

from __future__ import print_function
import sys
#sys.path.append('/users/wright/software/lib/python')

Expand Down
2 changes: 2 additions & 0 deletions sandbox/ev78/makevols.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

from __future__ import print_function

import fabio, numpy as np, h5py

# read in .txt file and .dat files
Expand Down
1 change: 1 addition & 0 deletions sandbox/ev78/watch_direcs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from __future__ import print_function

import glob, os, sys, time

Expand Down
2 changes: 2 additions & 0 deletions sandbox/fit_rotating.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

from __future__ import print_function

from scipy.spatial.transform import Rotation, RotationSpline
from ImageD11 import grain, columnfile, cImageD11, transform
import sys, numpy as np, pylab as pl, os
Expand Down
3 changes: 1 addition & 2 deletions sandbox/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@


import numpy as np
from ImageD11 import cImageD11, grain, transform
import unitcell
from ImageD11 import cImageD11, grain, transform, unitcell

import math, time, sys, logging

Expand Down
2 changes: 1 addition & 1 deletion sandbox/map/gridgrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#
from ImageD11 import transform, transformer, indexing, parameters
from ImageD11.closest import score
from ImageD11.cImageD11 import score
import sys


Expand Down
2 changes: 1 addition & 1 deletion sandbox/map/gridmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#
from ImageD11 import transform, transformer, indexing, parameters
from ImageD11.closest import score
from ImageD11.cImageD11 import score
import sys


Expand Down
1 change: 1 addition & 0 deletions sandbox/newpeaksearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from __future__ import print_function
import sys
import h5py, timeit
import numpy as np
Expand Down
3 changes: 1 addition & 2 deletions sandbox/offset_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import print_function

import numpy as np
from PIL import Image
REAL = np.float

def normalise( im ):
Expand Down Expand Up @@ -39,7 +40,6 @@ def find_offset( c ):

def register_image( rname, cname ):
""" We take the current and place it onto reference """
import Image
ref = normalise(np.asarray(Image.open(rname)).sum(axis=2, dtype=REAL))
cur = normalise(np.asarray(Image.open(cname)).sum(axis=2, dtype=REAL))
fftshape = ( ref.shape[0] + cur.shape[0] + 4,
Expand Down Expand Up @@ -77,7 +77,6 @@ def display_registered( current, reference, xf, yf ):


def test(filename):
import Image
rgb = np.asarray(Image.open(filename))
vals = 1.0*rgb[:,:,0] + rgb[:,:,1] + rgb[:,:,2]
print(vals.shape)
Expand Down
2 changes: 2 additions & 0 deletions sandbox/segment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

from __future__ import print_function

import sys, timeit
import numpy as np #, numba
import scipy.ndimage
Expand Down
1 change: 1 addition & 0 deletions sandbox/segment2d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

from __future__ import print_function
import sys, timeit
import numpy as np #, numba
import scipy.ndimage
Expand Down
1 change: 1 addition & 0 deletions sandbox/segment_hdf_slurm/segment1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os, time
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
import h5py, hdf5plugin
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[tool:pytest]
norecursedirs = ImageD11src/depreciated
norecursedirs = ImageD11/depreciated
Loading

0 comments on commit 57a39f4

Please sign in to comment.