mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
Implement PEP396
Implement PEP396 which specifies that a package should advertise its version via __version__ attribute. As devlib is often used as a development version directly from source, also add a __full_version__ attribute which appends the current commit ID to the version. Use the __full_version__ inside setup.py
This commit is contained in:
parent
4a862d06bb
commit
cc04e1a839
@ -30,3 +30,14 @@ from devlib.trace.serial_trace import SerialTraceCollector
|
||||
from devlib.host import LocalConnection
|
||||
from devlib.utils.android import AdbConnection
|
||||
from devlib.utils.ssh import SshConnection, TelnetConnection, Gem5Connection
|
||||
|
||||
from devlib.utils.version import get_commit as __get_commit
|
||||
|
||||
|
||||
__version__ = '0.0.4'
|
||||
|
||||
__commit = __get_commit()
|
||||
if __commit:
|
||||
__full_version__ = '{}-{}'.format(__version__, __commit)
|
||||
else:
|
||||
__full_version__ = __version__
|
||||
|
23
setup.py
23
setup.py
@ -13,6 +13,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
@ -37,6 +38,26 @@ try:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
with open(os.path.join(devlib_dir, '__init__.py')) as fh:
|
||||
# Extract the version by parsing the text of the file,
|
||||
# as may not be able to load as a module yet.
|
||||
for line in fh:
|
||||
if '__version__' in line:
|
||||
parts = line.split("'")
|
||||
__version__ = parts[1]
|
||||
break
|
||||
else:
|
||||
raise RuntimeError('Did not see __version__')
|
||||
|
||||
vh_path = os.path.join(devlib_dir, 'utils', 'version.py')
|
||||
# can load this, as it does not have any devlib imports
|
||||
version_helper = imp.load_source('version_helper', vh_path)
|
||||
commit = version_helper.get_commit()
|
||||
if commit:
|
||||
__version__ = '{}-{}'.format(__version__, commit)
|
||||
|
||||
|
||||
packages = []
|
||||
data_files = {}
|
||||
source_dir = os.path.dirname(__file__)
|
||||
@ -59,7 +80,7 @@ for root, dirs, files in os.walk(devlib_dir):
|
||||
params = dict(
|
||||
name='devlib',
|
||||
description='A framework for automating workload execution and measurment collection on ARM devices.',
|
||||
version='0.0.4',
|
||||
version=__version__,
|
||||
packages=packages,
|
||||
package_data=data_files,
|
||||
url='https://github.com/ARM-software/devlib',
|
||||
|
Loading…
x
Reference in New Issue
Block a user