Browse Source

use excfile strategy to avoid import trouble for version in setup.py

Guénaël Muller 6 years ago
parent
commit
160d3914e8
3 changed files with 14 additions and 3 deletions
  1. 1 1
      hapic/__init__.py
  2. 2 0
      hapic/infos.py
  3. 11 2
      setup.py

+ 1 - 1
hapic/__init__.py View File

1
 # -*- coding: utf-8 -*-
1
 # -*- coding: utf-8 -*-
2
 from hapic.hapic import Hapic
2
 from hapic.hapic import Hapic
3
 from hapic.data import HapicData
3
 from hapic.data import HapicData
4
+from hapic.infos import __version__
4
 
5
 
5
-__version__ = '0.41'
6
 _hapic_default = Hapic()
6
 _hapic_default = Hapic()
7
 
7
 
8
 with_api_doc = _hapic_default.with_api_doc
8
 with_api_doc = _hapic_default.with_api_doc

+ 2 - 0
hapic/infos.py View File

1
+# -*- coding: utf-8 -*-
2
+__version__ = '0.41'

+ 11 - 2
setup.py View File

4
 from setuptools import find_packages
4
 from setuptools import find_packages
5
 from os import path
5
 from os import path
6
 import sys
6
 import sys
7
-import hapic
7
+
8
+# INFO - G.M - 29-05-2018 - exec info.py file in order to obtain version
9
+# without any dependencies trouble.
10
+# see https://milkr.io/kfei/5-common-patterns-to-version-your-Python-package
11
+# section "Exec/execfile" for other example and "Import from the package" for
12
+# information about import strategy problem.
13
+infos_dict = {}
14
+with open("hapic/infos.py") as fp:
15
+    exec(fp.read(), infos_dict)
16
+version = infos_dict['__version__']
8
 
17
 
9
 here = path.abspath(path.dirname(__file__))
18
 here = path.abspath(path.dirname(__file__))
10
 
19
 
36
     # Versions should comply with PEP440.  For a discussion on single-sourcing
45
     # Versions should comply with PEP440.  For a discussion on single-sourcing
37
     # the version across setup.py and the project code, see
46
     # the version across setup.py and the project code, see
38
     # https://packaging.python.org/en/latest/single_source_version.html
47
     # https://packaging.python.org/en/latest/single_source_version.html
39
-    version=hapic.__version__,
48
+    version=version,
40
 
49
 
41
     description='HTTP api input/output manager',
50
     description='HTTP api input/output manager',
42
     # long_description=long_description,
51
     # long_description=long_description,