Skip to content

Commit

Permalink
Replace __version__ import with reading the __init__.py file
Browse files Browse the repository at this point in the history
See: https://packaging.python.org/guides/single-sourcing-package-version/
To avoid error when installing from source (`pip install -e .`)
  • Loading branch information
jond01 committed Jun 20, 2021
1 parent 9108b69 commit 5652be3
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import codecs
import os.path

from setuptools import setup, find_packages

from medio import __version__

def read(rel_path):
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
return fp.read()


def get_version(rel_path):
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]
else:
raise RuntimeError("Unable to find version string.")


with open('README.md') as f:
long_description = f.read()


setup(name='medio',
version=__version__,
version=get_version("medio/__init__.py"),
description='Medical images I/O python package',
long_description=long_description,
long_description_content_type='text/markdown',
Expand All @@ -17,31 +33,31 @@
keywords=['medical-images', 'IO', 'itk', 'nibabel', 'pydicom', 'python'],
packages=find_packages(exclude=['*.tests']),
install_requires=[
'itk >= 5.1.2',
'nibabel >= 3.2.1',
'pydicom >= 2.1.2',
'dicom-numpy >= 0.5.0',
'numpy >= 1.18.1'
'itk >= 5.1.2',
'nibabel >= 3.2.1',
'pydicom >= 2.1.2',
'dicom-numpy >= 0.5.0',
'numpy >= 1.18.1',
],
python_requires='>=3.6',
classifiers=[
'Development Status :: 3 - Alpha',
'Development Status :: 3 - Alpha',

'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Healthcare Industry',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Intended Audience :: Education',
'Intended Audience :: Healthcare Industry',
'Intended Audience :: Science/Research',

'Topic :: Scientific/Engineering :: Medical Science Apps.',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Scientific/Engineering :: Medical Science Apps.',
'Topic :: Software Development :: Libraries :: Python Modules',

'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',

'Operating System :: OS Independent'
'Operating System :: OS Independent',
],
license='Apache License 2.0',
zip_safe=True)

0 comments on commit 5652be3

Please sign in to comment.