Blob Blame History Raw
%global desc %{expand: \
DIPY is a python toolbox for analysis of MR diffusion imaging.
DIPY is for research only; please do not use results from DIPY for clinical

Current information can always be found from the DIPY website -}

# Full documentation downloads 100+MB of data, so we'd rather users look at the
# upstream documentation
%bcond_with docs

# Fail because of xvfb related errors, also still depends on nose
%bcond_with tests

%global forgeurl

Name:           python-dipy
Version:        1.7.0
Release:        %autorelease
Summary:        Diffusion MRI utilities in python

%global tag %{version}

License:        BSD
Source0:        %forgesource


%package -n python3-dipy
Summary:            %{summary}
BuildRequires:      python3-devel
BuildRequires:      gcc
%if %{with tests}
BuildRequires:      %{py3_dist xvfbwrapper}
BuildRequires:      xorg-x11-server-Xvfb
# Not mentioned in setup scripts
BuildRequires:      %{py3_dist nose}
# Not mentioned in build scripts
BuildRequires:      %{py3_dist pytest}
Suggests:           %{py3_dist ipython}

# Required for some modules but not in Fedora yet
# BuildRequires:      %%{py3_dist cvxpy}

%description -n python3-dipy

%package doc
BuildArch:      noarch
Summary:        %{summary}

%description doc
Documentation for %{name}.

export TEST_WITH_XVFB=true
# clean it all up (from the Makefile)
find . -name "*.so" -print -delete
find . -name "*.pyd" -print -delete
find . -name "*.c" -print -delete
find . -name "*.html" -print -delete
rm -rf build
rm -rf docs/_build
rm -rf docs/dist
rm -rf dipy/dipy.egg-info

# Correct interpreter for these---used in building docs and so on
sed -i 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/' doc/tools/
sed -i 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/' doc/tools/
find tools/ -name "*.py" -exec sed -i 's/#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/' '{}' \;

# Other shebangs and permission fixes
for f in "dipy/boots/" "dipy/reconst/benchmarks/" "dipy/reconst/" "dipy/reconst/"  "dipy/workflows/" "dipy/workflows/" "dipy/reconst/" "dipy/reconst/" "dipy/workflows/tests/"
    chmod -x "$f"
    sed -i '/^#!\/usr\/bin\/env python/ d' "$f"
    sed -i '/^#!\/usr\/bin\/python/ d' "$f"

%pyproject_buildrequires -r

export TEST_WITH_XVFB=true

%if %{with docs}
pushd doc
    export PYTHONPATH=../build/
    make SPHINXBUILD=sphinx-build-3 PYTHON=%{__python3} html
    rm -rf _build/html/.doctrees
    rm -rf _build/html/.buildinfo

%pyproject_save_files dipy

export TEST_WITH_XVFB=True
%if %{with tests}
export PYTHONPATH="%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}"
%{__python3} -c 'import dipy; dipy.test()'

%files -n python3-dipy -f %{pyproject_files}
%doc README.rst Changelog AUTHOR

%files doc
%license LICENSE
# Installed by package
%if %{with docs}
%doc doc/_build/html