Skip to content
This repository was archived by the owner on Jun 20, 2024. It is now read-only.

Commit aa374ed

Browse files
committed
Switch to using __about__ for package metadata
1 parent 9010c63 commit aa374ed

4 files changed

Lines changed: 22 additions & 19 deletions

File tree

setup.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,23 @@
1212
tests_require = ['begins', 'funconf']
1313

1414

15-
def load_version(filename='./virtualbox/version.py'):
16-
"""Parse a __version__ number from a source file"""
17-
with open(filename) as source:
18-
text = source.read()
19-
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", text)
20-
if not match:
21-
msg = "Unable to find version number in {}".format(filename)
22-
raise RuntimeError(msg)
23-
version = match.group(1)
24-
return version
15+
base_dir = os.path.dirname(os.path.abspath(__file__))
16+
about = {}
17+
with open(os.path.join(base_dir, 'virtualbox', '__about__.py')) as f:
18+
exec(f.read(), about)
2519

2620

2721
setup(
28-
name="pyvbox",
29-
version=load_version(),
22+
name=about['__name__'],
23+
version=about['__version__'],
3024
packages=["virtualbox",
3125
"virtualbox.library_ext"],
32-
author="Michael Dorman",
33-
author_email="mjdorma+pyvbox@gmail.com",
34-
url="https://github.com/mjdorma/pyvbox",
26+
author=about['__author__'],
27+
author_email=about['__email__'],
28+
url=about['__url__'],
3529
description="A complete VirtualBox Main API implementation",
3630
long_description=open('README.rst').read(),
37-
license="Apache-2.0",
31+
license=about['__license__'],
3832
zip_safe=False,
3933
install_requires=install_requires,
4034
platforms=['cygwin', 'win', 'linux'],

virtualbox/__about__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
__name__ = 'pyvbox'
2+
__author__ = 'Michael Dorman'
3+
__email__ = 'mjdorma+pyvbox@gmail.com'
4+
__version__ = '1.3.0b1'
5+
__license__ = 'Apache-2.0'
6+
__url__ = 'https://github.com/mjdorma/pyvbox'

virtualbox/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
from multiprocessing import current_process
2525

2626
from virtualbox.library_ext import library
27+
from .__about__ import (__name__, # noqa: F401
28+
__version__,
29+
__author__,
30+
__email__,
31+
__license__,
32+
__url__)
2733

2834

2935
# Adopt on the library API root documentation
@@ -238,5 +244,3 @@ def __init__(self, url='http://localhost/', user='', password=''):
238244
# Lazy include...
239245
from virtualbox import pool # noqa: F401
240246
from virtualbox import events # noqa: F401
241-
from virtualbox import version # noqa: F401
242-
from virtualbox.version import __version__ # noqa: F401

virtualbox/version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)