Skip to content

Commit 00ab7d0

Browse files
author
Gauvain Pocentek
committed
Rework the __version__ import
This simplifies the setup.py script Also provide a --version option for CLI
1 parent 9f256a7 commit 00ab7d0

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

gitlab/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
import six
2929

3030
import gitlab.config
31+
import gitlab.version
3132
from gitlab.exceptions import * # noqa
3233
from gitlab.objects import * # noqa
3334

3435
__title__ = 'python-gitlab'
35-
__version__ = '0.11.1'
36+
__version__ = gitlab.version.version
3637
__author__ = 'Gauvain Pocentek'
3738
__email__ = 'gauvain@pocentek.net'
3839
__license__ = 'LGPL3'

gitlab/cli.py

+6
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,14 @@ def do_project_owned(gl, what, args):
240240

241241

242242
def main():
243+
if "--version" in sys.argv:
244+
print(gitlab.__version__)
245+
exit(0)
246+
243247
parser = argparse.ArgumentParser(
244248
description="GitLab API Command Line Interface")
249+
parser.add_argument("--version", help="Display the version.",
250+
action="store_true")
245251
parser.add_argument("-v", "--verbose", "--fancy",
246252
help="Verbose mode",
247253
action="store_true")

gitlab/version.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = '0.11.1'

setup.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@
33

44
from setuptools import setup
55
from setuptools import find_packages
6-
7-
8-
def get_version():
9-
with open('gitlab/__init__.py') as f:
10-
for line in f:
11-
if line.startswith('__version__'):
12-
return eval(line.split('=')[-1])
6+
import gitlab.version
137

148

159
setup(name='python-gitlab',
16-
version=get_version(),
10+
version=gitlab.version.version,
1711
description='Interact with GitLab API',
1812
long_description='Interact with GitLab API',
1913
author='Gauvain Pocentek',

0 commit comments

Comments
 (0)