Skip to content

Commit 9e84aef

Browse files
author
Christian Sandberg
committed
Use setuptools-scm for version and drop Python 2.7
1 parent fc4ea87 commit 9e84aef

File tree

5 files changed

+17
-24
lines changed

5 files changed

+17
-24
lines changed

canopen/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
from .version import __version__
1+
from pkg_resources import get_distribution, DistributionNotFound
22
from .network import Network, NodeScanner
33
from .node import RemoteNode, LocalNode
44
from .sdo import SdoCommunicationError, SdoAbortedError
55
from .objectdictionary import import_od, ObjectDictionary, ObjectDictionaryError
66
from .profiles.p402 import BaseNode402
77

88
Node = RemoteNode
9+
10+
try:
11+
__version__ = get_distribution(__name__).version
12+
except DistributionNotFound:
13+
# package is not installed
14+
__version__ = "unknown"
15+
16+
__pypi_url__ = "https://pypi.org/project/canopen/"

canopen/version.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

doc/conf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
#
1919
import os
2020
import sys
21+
from pkg_resources import get_distribution
2122
sys.path.insert(0, os.path.abspath('..'))
2223

23-
exec(open('../canopen/version.py').read())
24-
2524
# -- General configuration ------------------------------------------------
2625

2726
# If your documentation needs a minimal Sphinx version, state it here.
@@ -62,10 +61,10 @@
6261
# |version| and |release|, also used in various other places throughout the
6362
# built documents.
6463
#
65-
# The short X.Y version.
66-
version = '.'.join(__version__.split('.')[0:2])
6764
# The full version, including alpha/beta/rc tags.
68-
release = __version__
65+
release = get_distribution('canopen').version
66+
# The short X.Y version.
67+
version = '.'.join(release.split('.')[:2])
6968

7069
# The language for content autogenerated by Sphinx. Refer to documentation
7170
# for a list of supported languages.

setup.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

setup.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
from setuptools import setup, find_packages
22

3-
exec(open('canopen/version.py').read())
4-
53
description = open("README.rst").read()
64
# Change links to stable documentation
75
description = description.replace("/latest/", "/stable/")
8-
# Change pip install to this exact version
9-
description = description.replace(
10-
"pip install canopen",
11-
"pip install canopen==" + __version__)
126

137
setup(
148
name="canopen",
159
url="https://github.com/christiansandberg/canopen",
16-
version=__version__,
10+
use_scm_version=True,
1711
packages=find_packages(),
1812
author="Christian Sandberg",
1913
author_email="[email protected]",
@@ -23,10 +17,9 @@
2317
license="MIT",
2418
platforms=["any"],
2519
classifiers=[
26-
"Development Status :: 4 - Beta",
20+
"Development Status :: 5 - Production/Stable",
2721
"License :: OSI Approved :: MIT License",
2822
"Operating System :: OS Independent",
29-
"Programming Language :: Python :: 2",
3023
"Programming Language :: Python :: 3",
3124
"Intended Audience :: Developers",
3225
"Topic :: Scientific/Engineering"
@@ -35,9 +28,6 @@
3528
extras_require={
3629
"db_export": ["canmatrix"]
3730
},
38-
include_package_data=True,
39-
40-
# Tests can be run using `python setup.py test`
41-
test_suite="nose.collector",
42-
tests_require=["nose"]
31+
setup_requires=["setuptools_scm"],
32+
include_package_data=True
4333
)

0 commit comments

Comments
 (0)