Skip to content

Commit 53d3331

Browse files
authored
Simplify python package description (#7187)
* Validate dev-version value in packaging_test.sh Skip `cirq_ts` which does not have the `__version__` attribute. * Remove dev-release note from package description Make setup.py files simpler and independent of CIRQ_PRE_RELEASE_VERSION. PyPI makes it already clear enough if looking at a development version. * Use `runpy` instead of `exec` to load version value Make it less mysterious how is the `__version__` value set. * Replace `io.open()` with builtin `open()` `io.open` is an alias for `open` anyway. * Normalize `.dev` version value to `.dev0` Address setuptools notice to that effect. * Use suffix `.dev0` for the main development branch
1 parent 0eea89e commit 53d3331

26 files changed

+81
-224
lines changed

cirq-aqt/cirq_aqt/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
"""Define version number here, read it from setup.py automatically"""
1616

17-
__version__ = "1.5.0.dev"
17+
__version__ = "1.5.0.dev0"

cirq-aqt/cirq_aqt/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq_aqt.__version__ == "1.5.0.dev"
6+
assert cirq_aqt.__version__ == "1.5.0.dev0"

cirq-aqt/setup.py

+6-26
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import io
16-
import os
15+
import runpy
16+
1717
from setuptools import find_packages, setup
1818

19-
# This reads the __version__ variable from cirq/_version.py
20-
__version__ = ''
21-
exec(open('cirq_aqt/_version.py').read())
19+
# This reads the __version__ variable from cirq_aqt/_version.py
20+
__version__ = runpy.run_path('cirq_aqt/_version.py')['__version__']
21+
assert __version__, 'Version string cannot be empty'
2222

2323
name = 'cirq-aqt'
2424

@@ -27,24 +27,7 @@
2727
)
2828

2929
# README file as long_description.
30-
long_description = io.open('README.md', encoding='utf-8').read()
31-
32-
# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
33-
# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
34-
# it will be a pre-release version on PyPi. See
35-
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
36-
# for more details.
37-
if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
38-
__version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
39-
long_description = (
40-
"<div align='center' width='50%'>\n\n"
41-
"| ⚠️ WARNING |\n"
42-
"|:----------:|\n"
43-
"| **This is a development version of `cirq-aqt` and may be<br>"
44-
"unstable. For the latest stable release of `cirq-aqt`,<br>"
45-
"please visit** <https://pypi.org/project/cirq-aqt>.|\n"
46-
"\n</div>\n\n" + long_description
47-
)
30+
long_description = open('README.md', encoding='utf-8').read()
4831

4932
# Read in requirements
5033
requirements = open('requirements.txt').readlines()
@@ -55,9 +38,6 @@
5538
'cirq_aqt.' + package for package in find_packages(where='cirq_aqt')
5639
]
5740

58-
# Sanity check
59-
assert __version__, 'Version string cannot be empty'
60-
6141
setup(
6242
name=name,
6343
version=__version__,

cirq-core/cirq/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
'of cirq (e.g. "python -m pip install cirq==1.1.*")'
2929
)
3030

31-
__version__ = "1.5.0.dev"
31+
__version__ = "1.5.0.dev0"

cirq-core/cirq/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq.__version__ == "1.5.0.dev"
6+
assert cirq.__version__ == "1.5.0.dev0"

cirq-core/setup.py

+5-25
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import io
16-
import os
15+
import runpy
16+
1717
from setuptools import find_packages, setup
1818

1919
# This reads the __version__ variable from cirq/_version.py
20-
__version__ = ''
21-
exec(open('cirq/_version.py').read())
20+
__version__ = runpy.run_path('cirq/_version.py')['__version__']
21+
assert __version__, 'Version string cannot be empty'
2222

2323
name = 'cirq-core'
2424

@@ -28,24 +28,7 @@
2828
)
2929

3030
# README file as long_description.
31-
long_description = io.open('README.md', encoding='utf-8').read()
32-
33-
# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
34-
# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
35-
# it will be a pre-release version on PyPi. See
36-
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
37-
# for more details.
38-
if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
39-
__version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
40-
long_description = (
41-
"<div align='center' width='50%'>\n\n"
42-
"| ⚠️ WARNING |\n"
43-
"|:----------:|\n"
44-
"| **This is a development version of `cirq-core` and may be<br>"
45-
"unstable. For the latest stable release of `cirq-core`,<br>"
46-
"please visit** <https://pypi.org/project/cirq-core>.|\n"
47-
"\n</div>\n\n" + long_description
48-
)
31+
long_description = open('README.md', encoding='utf-8').read()
4932

5033
# Read in requirements
5134
requirements = open('requirements.txt').readlines()
@@ -58,9 +41,6 @@
5841
'cirq.' + package for package in find_packages(where='cirq', exclude=['google', 'google.*'])
5942
]
6043

61-
# Sanity check
62-
assert __version__, 'Version string cannot be empty'
63-
6444
setup(
6545
name=name,
6646
version=__version__,

cirq-google/cirq_google/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828
'of cirq (e.g. "python -m pip install cirq==1.1.*")'
2929
)
3030

31-
__version__ = "1.5.0.dev"
31+
__version__ = "1.5.0.dev0"

cirq-google/cirq_google/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq_google.__version__ == "1.5.0.dev"
6+
assert cirq_google.__version__ == "1.5.0.dev0"

cirq-google/setup.py

+4-25
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
15+
import runpy
16+
1617
from setuptools import find_packages, setup
1718

1819
# This reads the __version__ variable from cirq_google/_version.py
19-
__version__ = ''
20-
exec(open('cirq_google/_version.py').read())
20+
__version__ = runpy.run_path('cirq_google/_version.py')['__version__']
21+
assert __version__, 'Version string cannot be empty'
2122

2223
name = 'cirq-google'
2324

@@ -28,31 +29,9 @@
2829
# README file as long_description.
2930
long_description = open('README.md', encoding='utf-8').read()
3031

31-
# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
32-
# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
33-
# it will be a pre-release version on PyPi. See
34-
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
35-
# for more details.
36-
if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
37-
__version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
38-
long_description = (
39-
"<div align='center' width='50%'>\n\n"
40-
"| ⚠️ WARNING |\n"
41-
"|:----------:|\n"
42-
"| **This is a development version of `cirq-google` and may be<br>"
43-
"unstable. For the latest stable release of `cirq-google`,<br>"
44-
"please visit** <https://pypi.org/project/cirq-google>.|\n"
45-
"\n</div>\n\n" + long_description
46-
)
47-
4832
# Read in requirements
4933
requirements = open('requirements.txt').readlines()
5034
requirements = [r.strip() for r in requirements]
51-
52-
# Sanity check
53-
assert __version__, 'Version string cannot be empty'
54-
55-
# This is a pure metapackage that installs all our packages
5635
requirements += [f'cirq-core=={__version__}']
5736

5837

cirq-ionq/cirq_ionq/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
"""Define version number here, read it from setup.py automatically"""
1616

17-
__version__ = "1.5.0.dev"
17+
__version__ = "1.5.0.dev0"

cirq-ionq/cirq_ionq/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq_ionq.__version__ == "1.5.0.dev"
6+
assert cirq_ionq.__version__ == "1.5.0.dev0"

cirq-ionq/setup.py

+7-27
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,30 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import io
16-
import os
15+
import runpy
16+
1717
from setuptools import find_packages, setup
1818

19-
# This reads the __version__ variable from cirq/_version.py
20-
__version__ = ''
21-
exec(open('cirq_ionq/_version.py').read())
19+
# This reads the __version__ variable from cirq_ionq/_version.py
20+
__version__ = runpy.run_path('cirq_ionq/_version.py')['__version__']
21+
assert __version__, 'Version string cannot be empty'
2222

2323
name = 'cirq-ionq'
2424

2525
description = 'A Cirq package to simulate and connect to IonQ quantum computers'
2626

2727
# README file as long_description.
28-
long_description = io.open('README.md', encoding='utf-8').read()
29-
30-
# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
31-
# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
32-
# it will be a pre-release version on PyPi. See
33-
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
34-
# for more details.
35-
if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
36-
__version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
37-
long_description = (
38-
"<div align='center' width='50%'>\n\n"
39-
"| ⚠️ WARNING |\n"
40-
"|:----------:|\n"
41-
"| **This is a development version of `cirq-ionq` and may be<br>"
42-
"unstable. For the latest stable release of `cirq-ionq`,<br>"
43-
"please visit** <https://pypi.org/project/cirq-ionq>.|\n"
44-
"\n</div>\n\n" + long_description
45-
)
28+
long_description = open('README.md', encoding='utf-8').read()
4629

4730
# Read in requirements
4831
requirements = open('requirements.txt').readlines()
4932
requirements = [r.strip() for r in requirements]
33+
requirements += [f'cirq-core=={__version__}']
5034

5135
cirq_packages = ['cirq_ionq'] + [
5236
'cirq_ionq.' + package for package in find_packages(where='cirq_ionq')
5337
]
5438

55-
# Sanity check
56-
assert __version__, 'Version string cannot be empty'
57-
58-
requirements += [f'cirq-core=={__version__}']
5939

6040
setup(
6141
name=name,

cirq-pasqal/cirq_pasqal/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
"""Define version number here, read it from setup.py automatically"""
1616

17-
__version__ = "1.5.0.dev"
17+
__version__ = "1.5.0.dev0"

cirq-pasqal/cirq_pasqal/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq_pasqal.__version__ == "1.5.0.dev"
6+
assert cirq_pasqal.__version__ == "1.5.0.dev0"

cirq-pasqal/setup.py

+6-26
Original file line numberDiff line numberDiff line change
@@ -12,44 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import io
16-
import os
15+
import runpy
16+
1717
from setuptools import find_packages, setup
1818

19-
# This reads the __version__ variable from cirq/_version.py
20-
__version__ = ''
21-
exec(open('cirq_pasqal/_version.py').read())
19+
# This reads the __version__ variable from cirq_pasqal/_version.py
20+
__version__ = runpy.run_path('cirq_pasqal/_version.py')['__version__']
21+
assert __version__, 'Version string cannot be empty'
2222

2323
name = 'cirq-pasqal'
2424

2525
description = 'A Cirq package to simulate and connect to Pasqal quantum computers'
2626

2727
# README file as long_description.
28-
long_description = io.open('README.md', encoding='utf-8').read()
29-
30-
# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
31-
# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
32-
# it will be a pre-release version on PyPi. See
33-
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
34-
# for more details.
35-
if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
36-
__version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
37-
long_description = (
38-
"<div align='center' width='50%'>\n\n"
39-
"| ⚠️ WARNING |\n"
40-
"|:----------:|\n"
41-
"| **This is a development version of `cirq-pasqal` and may be<br>"
42-
"unstable. For the latest stable release of `cirq-pasqal`,<br>"
43-
"please visit** <https://pypi.org/project/cirq-pasqal>.|\n"
44-
"\n</div>\n\n" + long_description
45-
)
28+
long_description = open('README.md', encoding='utf-8').read()
4629

4730
# Read in requirements
4831
requirements = open('requirements.txt').readlines()
4932
requirements = [r.strip() for r in requirements]
50-
# Sanity check
51-
assert __version__, 'Version string cannot be empty'
52-
5333
requirements += [f'cirq-core=={__version__}']
5434

5535
cirq_packages = ['cirq_pasqal'] + [

cirq-rigetti/cirq_rigetti/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
"""Define version number here, read it from setup.py automatically"""
1616

17-
__version__ = "1.5.0.dev"
17+
__version__ = "1.5.0.dev0"

cirq-rigetti/cirq_rigetti/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq_rigetti.__version__ == "1.5.0.dev"
6+
assert cirq_rigetti.__version__ == "1.5.0.dev0"

cirq-rigetti/setup.py

+6-18
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,24 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import io
16-
import os
15+
import runpy
16+
1717
from setuptools import find_packages, setup
1818

19-
# This reads the __version__ variable from cirq/_version.py
20-
__version__ = ''
21-
exec(open('cirq_rigetti/_version.py').read())
19+
# This reads the __version__ variable from cirq_rigetti/_version.py
20+
__version__ = runpy.run_path('cirq_rigetti/_version.py')['__version__']
21+
assert __version__, 'Version string cannot be empty'
2222

2323
name = 'cirq-rigetti'
2424

2525
description = 'A Cirq package to simulate and connect to Rigetti quantum computers and Quil QVM'
2626

2727
# README file as long_description.
28-
long_description = io.open('README.md', encoding='utf-8').read()
29-
30-
# If CIRQ_PRE_RELEASE_VERSION is set then we update the version to this value.
31-
# It is assumed that it ends with one of `.devN`, `.aN`, `.bN`, `.rcN` and hence
32-
# it will be a pre-release version on PyPi. See
33-
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#pre-release-versioning
34-
# for more details.
35-
if 'CIRQ_PRE_RELEASE_VERSION' in os.environ:
36-
__version__ = os.environ['CIRQ_PRE_RELEASE_VERSION']
28+
long_description = open('README.md', encoding='utf-8').read()
3729

3830
# Read in requirements
3931
requirements = open('requirements.txt').readlines()
4032
requirements = [r.strip() for r in requirements]
41-
42-
# Sanity check
43-
assert __version__, 'Version string cannot be empty'
44-
4533
requirements += [f'cirq-core=={__version__}']
4634

4735
cirq_packages = ['cirq_rigetti'] + [

cirq-web/cirq_web/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "1.5.0.dev"
15+
__version__ = "1.5.0.dev0"

cirq-web/cirq_web/_version_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def test_version():
6-
assert cirq_web.__version__ == "1.5.0.dev"
6+
assert cirq_web.__version__ == "1.5.0.dev0"

0 commit comments

Comments
 (0)