Skip to content

Commit 53c7a32

Browse files
committed
Single-sourcing the version in a __version__.py file (graphql-python#142)
1 parent 9e6dc7e commit 53c7a32

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
author = 'graphql-python.org'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '3.0.0a1'
25+
from gql import __version__
26+
release = __version__
2627

2728

2829
# -- General configuration ---------------------------------------------------

gql/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- all the transports classes implementing different communication protocols
88
"""
99

10+
from .__version__ import __version__
1011
from .client import Client
1112
from .gql import gql
1213
from .transport.aiohttp import AIOHTTPTransport
@@ -15,6 +16,7 @@
1516
from .transport.websockets import WebsocketsTransport
1617

1718
__all__ = [
19+
"__version__",
1820
"gql",
1921
"AIOHTTPTransport",
2022
"Client",

gql/__version__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "3.0.0a1"

setup.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
from setuptools import setup, find_packages
24

35
install_requires = [
@@ -28,12 +30,18 @@
2830
"isort==4.3.21",
2931
"mypy==0.770",
3032
"sphinx>=3.0.0,<4",
31-
"sphinx_rtd_theme>=0.4,<1"
33+
"sphinx_rtd_theme>=0.4,<1",
3234
] + tests_require
3335

36+
# Get version from __version__.py file
37+
current_folder = os.path.abspath(os.path.dirname(__file__))
38+
about = {}
39+
with open(os.path.join(current_folder, "gql", "__version__.py"), "r") as f:
40+
exec(f.read(), about)
41+
3442
setup(
3543
name="gql",
36-
version="3.0.0a1",
44+
version=about["__version__"],
3745
description="GraphQL client for Python",
3846
long_description=open("README.md").read(),
3947
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)