Skip to content

Commit 3f5189f

Browse files
committed
better version handling
1 parent 0312009 commit 3f5189f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

ot/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@
1717
# utils functions
1818
from .utils import dist, unif
1919

20+
__version__ = "0.1.6"
21+
2022
__all__ = ["emd", "sinkhorn", "utils", 'datasets', 'bregman', 'lp', 'plot',
2123
'dist', 'unif', 'barycenter', 'sinkhorn_lpl1_mm', 'da', 'optim']

setup.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@
33
from setuptools import setup, find_packages
44
from codecs import open
55
from os import path
6-
import numpy
76
from setuptools.extension import Extension
87
from Cython.Build import cythonize
9-
8+
import numpy
9+
import re
10+
import os
1011

1112
here = path.abspath(path.dirname(__file__))
1213

1314

1415

15-
import os
16+
1617
#import glob
1718

18-
version='0.1.5'
19+
# dirty but working
20+
__version__ = re.search(
21+
r'__version__\s*=\s*[\'"]([^\'"]*)[\'"]', # It excludes inline comment too
22+
open('ot/__init__.py').read()).group(1)
23+
# The beautiful part is, I don't even need to check exceptions here.
24+
# If something messes up, let the build process fail noisy, BEFORE my release!
1925

2026
ROOT = os.path.abspath(os.path.dirname(__file__))
2127

@@ -29,7 +35,7 @@
2935

3036

3137
setup(name='POT',
32-
version=version,
38+
version=__version__,
3339
description='Python Optimal Transport Library',
3440
long_description=README,
3541
author=u'Remi Flamary, Nicolas Courty',
@@ -43,7 +49,7 @@
4349
language="c++", # generate and compile C++ code,
4450
include_dirs=[numpy.get_include(),os.path.join(ROOT,'ot/lp')])),
4551
platforms=['linux','macosx','windows'],
46-
download_url='https://github.com/rflamary/POT/archive/V{}.tar.gz'.format(version),
52+
download_url='https://github.com/rflamary/POT/archive/V{}.tar.gz'.format(__version__),
4753
license = 'MIT',
4854
scripts=[],
4955
data_files=[],

0 commit comments

Comments
 (0)