Skip to content

Commit d23229d

Browse files
author
Sylvain MARIE
committed
- Added __version__ attribute
- Not using pytest-cov anymore: bug - simplified setup.py thanks to markdown-enabled long description
1 parent b61adc1 commit d23229d

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

autoclass/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,17 @@
77
autoprops_decorate, DuplicateOverrideError, getter_override, setter_override, autoprops_override_decorate
88
from autoclass.utils import AutoclassDecorationException
99

10+
try:
11+
# Distribution mode : import from _version.py generated by setuptools_scm during release
12+
from ._version import version as __version__
13+
except ImportError:
14+
# Source mode : use setuptools_scm to get the current version from src using git
15+
from setuptools_scm import get_version as _gv
16+
from os import path as _path
17+
__version__ = _gv(_path.join(_path.dirname(__file__), _path.pardir))
18+
1019
__all__ = [
20+
'__version__',
1121
# submodules
1222
'autoargs_', 'autoclass_', 'autodict_', 'autohash_', 'autoprops_', 'utils',
1323
# symbols

ci_tools/run_tests.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ trap "cleanup" INT TERM EXIT
2222
echo -e "\n\n****** Running tests ******\n\n"
2323
if [ "${TRAVIS_PYTHON_VERSION}" = "3.5" ]; then
2424
# full
25-
python -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html --cov-report term-missing --cov=./autoclass -v autoclass/tests/
25+
coverage run --source autoclass -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html --cov-report term-missing --cov=./autoclass -v autoclass/tests/
26+
# buggy
27+
# python -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html --cov-report term-missing --cov=./autoclass -v autoclass/tests/
2628
else
2729
# faster - skip coverage and html report
2830
python -m pytest --junitxml=reports/junit/junit.xml -v autoclass/tests/

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 1.17.2 - Added `__version__` attribute
4+
5+
Added `__version__` attribute at package level.
6+
37
### 1.17.1 - Fixed bug with latest `valid8`
48

59
* Fixed `ValidationError` happening in all use cases. Fixed [#25](https://github.com/smarie/python-autoclass/issues/25).

setup.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
INSTALL_REQUIRES = ['decopatch', 'funcsigs;python_version<"3.3"', 'valid8', 'makefun']
1515
DEPENDENCY_LINKS = []
1616
SETUP_REQUIRES = ['pytest-runner', 'setuptools_scm', 'pypandoc', 'pandoc']
17-
TESTS_REQUIRE = ['pytest', 'pytest-logging', 'pytest-cov', 'PyContracts', 'enforce', 'pytypes', 'valid8>=2.0.0']
17+
TESTS_REQUIRE = ['pytest', 'pytest-logging', 'PyContracts', 'enforce', 'pytypes', 'valid8>=2.0.0']
1818
EXTRAS_REQUIRE = {'contracts': ['PyContracts'],
1919
'enforce': ['enforce'],
2020
'validate': ['valid8']}
@@ -23,9 +23,7 @@
2323
try:
2424
from setuptools_scm import get_version
2525
except Exception as e:
26-
raise_from(Exception('Required packages for setup not found. You may wish you execute '
27-
'"pip install -r ci_tools/requirements-setup.txt" to install them or alternatively install '
28-
'them manually using conda or other system. The list is : ' + str(SETUP_REQUIRES)), e)
26+
raise_from(Exception('Required packages for setup not found. Please install `setuptools_scm`'), e)
2927

3028
# ************** ID card *****************
3129
DISTNAME = 'autoclass'
@@ -42,17 +40,9 @@
4240
KEYWORDS = 'auto code generator getter setter constructor autoarg autoprops decorator property properties fields ' \
4341
'attribute attr contract object class enforce valid boilerplate pep484 type-hints runtime-typechecking ' \
4442
'typechecking'
45-
# --Get the long description from the README file
46-
# with open(path.join(here, 'README.md'), encoding='utf-8') as f:
47-
# LONG_DESCRIPTION = f.read()
48-
try:
49-
import pypandoc
50-
LONG_DESCRIPTION = pypandoc.convert(path.join(here, 'docs', 'long_description.md'), 'rst').replace('\r', '')
51-
except(ImportError):
52-
from warnings import warn
53-
warn('WARNING pypandoc could not be imported - we recommend that you install it in order to package the '
54-
'documentation correctly')
55-
LONG_DESCRIPTION = open('README.md').read()
43+
44+
with open(path.join(here, 'docs', 'long_description.md')) as f:
45+
LONG_DESCRIPTION = f.read()
5646

5747
# ************* VERSION **************
5848
# --Get the Version number from VERSION file, see https://packaging.python.org/single_source_version/ option 4.
@@ -65,6 +55,7 @@
6555
name=DISTNAME,
6656
description=DESCRIPTION,
6757
long_description=LONG_DESCRIPTION,
58+
long_description_content_type='text/markdown',
6859

6960
# Versions should comply with PEP440. For a discussion on single-sourcing
7061
# the version across setup.py and the project code, see
@@ -125,7 +116,7 @@
125116
dependency_links=DEPENDENCY_LINKS,
126117

127118
# we're using git
128-
use_scm_version=True, # this provides the version + adds the date if local non-commited changes.
119+
use_scm_version={'write_to': '%s/_version.py' % DISTNAME}, # this provides the version + adds the date if local non-commited changes.
129120
# use_scm_version={'local_scheme':'dirty-tag'}, # this provides the version + adds '+dirty' if local non-commited changes.
130121
setup_requires=SETUP_REQUIRES,
131122

0 commit comments

Comments
 (0)