Skip to content

Commit

Permalink
Updated for pip and pypi release
Browse files Browse the repository at this point in the history
  • Loading branch information
mcraig-ibme committed Feb 5, 2019
1 parent a769048 commit 7f6b61b
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build*
oxasl_ve/_version.py
dist
oxasl_ve.egg-info/
.pytest_cache
123 changes: 123 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
Quantiphyse licence
===================

These licence terms apply to all licences granted by THE CHANCELLOR, MASTERS
AND SCHOLARS OF THE UNIVERSITY OF OXFORD whose administrative offices are at
office at University Offices, Wellington Square, Oxford OX1 2JD, United Kingdom
(the "University") for use of or access to OXASL_VE ("the Software"),
a Python interface to the VEASLC tool for modelling vessel encoded ASL data.

By using the Software provided directly to you by email, you (the "User") are
confirming that you agree that your use of the Software is subject to these
licence terms.

PLEASE READ THESE LICENCE TERMS CAREFULLY BEFORE USING THE SOFTWARE. IF YOU DO
NOT AGREE TO THESE LICENCE TERMS YOU SHOULD NOT USE THE SOFTWARE.

THE SOFTWARE ARE INTENDED FOR ACADEMICS CARRYING OUT RESEARCH AND NOT FOR USE
BY CONSUMERS OR COMMERCIAL BUSINESSES.

1. Academic Use Licence

1.1 The User is granted a limited non-exclusive and non-transferable royalty
free licence to access and use the Software provided that the User will:

(a) limit their use of the Software to their own internal academic
non-commercial research which is undertaken for the purposes of education
or other scholarly use;

(b) not use the Software for or on behalf of any third party or to provide a
service or integrate all or part of the Software into a product for sale
or license to third parties;

(c) use the Software in accordance with the prevailing instructions and
guidance for use given on the Website and comply with procedures on the
Website for user identification, authentication and access;

(d) comply with all applicable laws and regulations with respect to their use
of the Software;

(e) except to the extent expressly permitted under these terms, not attempt
to: reverse compile, disassemble or copy, modify, duplicate, create
derivative works from, frame, mirror, republish, download, display,
transmit, or distribute all or any portion of the Software or Website in
any form or media or by any means; and

(f) ensure that the Copyright Notice "Copyright © 2018, University of Oxford"
appears prominently wherever results from the Software are used, and is
referenced or cited with the Copyright Notice when the Software is
described in any research publication or on any documents or other
material created using the Software.

1.2 the University reserves the right at any time and without liability or
prior notice to the User to revise, modify and replace the functionality
and performance of the access to and operation of the Software.

1.3 The User acknowledges and agrees that the University owns all
intellectual property rights in the Software. The User shall not have any
right, title or interest in or to any results or other output from the
Software.

1.4 This Licence will terminate immediately and the User will no longer have
any right exercise any of the rights granted to the User upon any breach
of the conditions in Section 1.1 of this Licence.

2. Indemnity and Liability

2.1 The User shall defend, indemnify and hold harmless the University against
any claims, actions, proceedings, losses, damages, expenses and costs
(including without limitation court costs and reasonable legal fees)
arising out of or in connection with the User's possession or use of the
Software, or any breach of these terms by the User.

2.2 The Software are provided on an 'as is' basis and the User uses the
Software at their own risk. No representations, conditions, warranties or
other terms of any kind are given in respect of the Software and all
statutory warranties and conditions are excluded to the fullest extent
permitted by law. Without affecting the generality of the previous
sentences, the University gives no implied or express warranty and makes
no representation that the Software or any part of them:

(a) will enable specific results to be obtained; or

(b) meets a particular specification or is comprehensive within its field or
that it is error free or will operate without interruption; or

(c) is suitable for any particular, or the User's specific purposes.

2.3 Except in relation to fraud, death or personal injury, the University's
liability to the User for any use of the Software, in negligence or
arising in any other way out of the subject matter of these licence
terms, will not extend to any incidental or consequential damages or
losses, or any loss of profits, loss of revenue, loss of data, loss of
contracts or opportunity, whether direct or indirect.

2.4 The User hereby irrevocably undertakes to the University not to make any
claim against any employee, student, researcher or other individual
engaged by the University, being a claim which seeks to enforce against
any of them any liability whatsoever in connection with this agreement
or its subject-matter.

3. General

3.1 Severability - If any provision (or part of a provision) of these licence
terms is found by any court or administrative body of competent
jurisdiction to be invalid, unenforceable or illegal, the other
provisions shall remain in force.

3.2 Entire Agreement - These licence terms and any documents referred to in
them, constitute the whole agreement between the parties and supersede
any previous arrangement, understanding or agreement between them
relating to the Software.

3.3 Law and Jurisdiction - These licence terms and any disputes or claims
arising out of or in connection with them shall be governed by, and
construed in accordance with, the law of England. The User irrevocably
submits to the exclusive jurisdiction of the English courts for any
dispute or claim that arises out of or in connection with these licence
terms.

If you are interested in using the Software commercially, please contact
Oxford University Innovation Limited to negotiate a licence. Contact details
are chandra.ramanujan@innovation.ox.ac.uk quoting reference 14419.

1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include LICENSE requirements.txt
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# OXASL_VE

Python interface to the C++ based VEASLC tool for Vessel-encoded ASL designed for use with the OXASL
processing pipeline

## Citation

*A General Framework for the Analysis of Vessel Encoded Arterial Spin Labelling for Vascular Territory Mapping*
M Chappell, T Okell, P Jezzard and M Woolrich
Magnetic Resonance in Medicine 64:1529-1539 (2010)
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
oxasl
numpy
fslpy>=1.13

136 changes: 81 additions & 55 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,99 @@
#!/usr/bin/env python
"""
Build Python interface for veaslc
Setup script for oxasl_ve
"""
import os
import sys
import subprocess
import re
import io

from setuptools import setup, find_packages
from setuptools import setup
from setuptools import find_packages

def git_version():
# Full version includes the Git commit hash
full_version = subprocess.check_output('git describe --dirty', shell=True).decode("utf-8").strip(" \n")
MODULE = 'oxasl_ve'

# Python standardized version in form major.minor.patch.dev<build>
version_regex = re.compile(r"v?(\d+\.\d+\.\d+(-\d+)?).*")
match = version_regex.match(full_version)
if match:
std_version = match.group(1).replace("-", ".dev")
else:
raise RuntimeError("Failed to parse version string %s" % full_version)
def get_filetext(rootdir, filename):
""" Get the text of a local file """
with io.open(os.path.join(rootdir, filename), encoding='utf-8') as f:
return f.read()

def git_version():
""" Get the full and python standardized version from Git tags (if possible) """
try:
# Full version includes the Git commit hash
full_version = subprocess.check_output('git describe --dirty', shell=True).decode("utf-8").strip(" \n")

return full_version, std_version
# Python standardized version in form major.minor.patch.post<build>
version_regex = re.compile(r"v?(\d+\.\d+\.\d+(-\d+)?).*")
match = version_regex.match(full_version)
if match:
std_version = match.group(1).replace("-", ".post")
else:
raise RuntimeError("Failed to parse version string %s" % full_version)
return full_version, std_version
except:
# Any failure, return None. We may not be in a Git repo at all
return None, None

def git_timestamp():
return subprocess.check_output('git log -1 --format=%cd', shell=True).decode("utf-8").strip(" \n")
""" Get the last commit timestamp from Git (if possible)"""
try:
return subprocess.check_output('git log -1 --format=%cd', shell=True).decode("utf-8").strip(" \n")
except:
# Any failure, return None. We may not be in a Git repo at all
return None

def update_metadata(rootdir, version_str, timestamp_str):
""" Update the version and timestamp metadata in the module _version.py file """
with io.open(os.path.join(rootdir, MODULE, "_version.py"), "w", encoding='utf-8') as f:
f.write("__version__ = '%s'\n" % version_str)
f.write("__timestamp__ = '%s'\n" % timestamp_str)

def set_metadata(module_dir, version_str, timestamp_str):
vfile = open(os.path.join(module_dir, "oxasl_ve", "_version.py"), "w")
vfile.write("__version__ = '%s'\n" % version_str)
vfile.write("__timestamp__ = '%s'\n" % timestamp_str)
vfile.close()
def get_requirements(rootdir):
""" Get a list of all entries in the requirements file """
with io.open(os.path.join(rootdir, 'requirements.txt'), encoding='utf-8') as f:
return [l.strip() for l in f.readlines()]

# Read in requirements from the requirements.txt file.
with open('requirements.txt', 'rt') as f:
requirements = [l.strip() for l in f.readlines()]
def get_version(rootdir):
""" Get the current version number (and update it in the module _version.py file if necessary)"""
version, timestamp = git_version()[1], git_timestamp()

# Generate a list of all of the packages that are in your project.
packages = find_packages()
if version is not None and timestamp is not None:
# We got the metadata from Git - update the version file
update_metadata(rootdir, version, timestamp)
else:
# Could not get metadata from Git - use the version file if it exists
with io.open(os.path.join(rootdir, MODULE, '_version.py'), encoding='utf-8') as f:
md = f.read()
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", md, re.M)
if match:
version = match.group(1)
else:
version = "unknown"
return version

rootdir = os.path.join(os.path.abspath(os.path.dirname(__file__)))
_, stdv = git_version()
timestamp = git_timestamp()
set_metadata(rootdir, stdv, timestamp)
module_dir = os.path.abspath(os.path.dirname(__file__))

desc = "Python interface for vessel-encoded ASL"
longdesc = desc
kwargs = {
'name' : 'oxasl-ve',
'version' : get_version(module_dir),
'description' : 'Python library for manipulating and modelling ASL data',
'long_description' : get_filetext(module_dir, 'README.md'),
'long_description_content_type' : 'text/markdown',
'url' : 'https://oxasl.readthedocs.io/',
'author' : 'Martin Craig',
'author_email' : 'martin.craig@eng.ox.ac.uk',
'license' : 'License granted by University of Oxford for use by academics carrying out research and not for use by consumers or commercial businesses. See LICENSE file for more details',
'install_requires' : get_requirements(module_dir),
'packages' : find_packages(),
'classifiers' : [
'Development Status :: 3 - Alpha',
'Intended Audience :: Science/Research',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'License :: Free for non-commercial use',
],
}

# setup parameters
setup(name='oxasl_ve',
version=stdv,
description=desc,
long_description=longdesc,
author='Michael Chappell, Martin Craig',
author_email='martin.craig@eng.ox.ac.uk',
packages=packages,
include_package_data=True,
data_files=[],
setup_requires=[],
install_requires=[],
entry_points={
},
classifiers=["Programming Language :: Python :: 2.7",
"Development Status:: 3 - Alpha",
'Programming Language :: Python',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Intended Audience :: End Users/Desktop",
"Topic :: Scientific/Engineering :: Bio-Informatics",])
setup(**kwargs)

0 comments on commit 7f6b61b

Please sign in to comment.