Skip to content

Commit 53d3331

Browse files
authoredMar 26, 2025··
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"

‎cirq-web/setup.py

+5-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

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

2223
name = 'cirq-web'
2324

@@ -26,30 +27,9 @@
2627
# README file as long_description.
2728
long_description = open('README.md', encoding='utf-8').read()
2829

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

5535
# Gather all packages from cirq_web, and the dist/ folder from cirq_ts

‎dev_tools/modules.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
- Python: get_version and replace_version
2828
- CLI:
2929
- python3 dev_tools/modules.py print_version
30-
- python3 dev_tools/modules.py replace_version --old v0.12.0.dev --new v0.12.1.dev
30+
- python3 dev_tools/modules.py replace_version --old v1.5.0.dev0 --new v1.5.1.dev0
3131
3232
optional arguments:
3333
-h, --help show this help message and exit

‎dev_tools/packaging/generate-dev-version-id.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ PROJECT_NAME=cirq-core/cirq
4444
ACTUAL_VERSION_LINE=$(tail -n 1 "${PROJECT_NAME}/_version.py")
4545
ACTUAL_VERSION=$(echo "$ACTUAL_VERSION_LINE" | cut -d'"' -f 2)
4646

47-
if [[ ${ACTUAL_VERSION} == *"dev" ]]; then
48-
echo "${ACTUAL_VERSION}$(date "+%Y%m%d%H%M%S")"
47+
if [[ ${ACTUAL_VERSION} == *"dev0" ]]; then
48+
echo "${ACTUAL_VERSION%0}$(date "+%Y%m%d%H%M%S")"
4949
else
50-
echo "Version doesn't end in dev: ${ACTUAL_VERSION_LINE}" >&2
50+
echo "Version doesn't end in dev0: ${ACTUAL_VERSION_LINE}" >&2
5151
exit 1
5252
fi

‎dev_tools/packaging/packaging_test.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,19 @@ echo =======================================
5050
echo Testing that all modules are installed
5151
echo =======================================
5252

53+
python_test_template="\
54+
import @p
55+
print(@p)
56+
assert '${tmp_dir}' in @p.__file__, 'Package path seems invalid.'
57+
assert (
58+
'@p' == 'cirq_ts' or
59+
'${CIRQ_PRE_RELEASE_VERSION}' == @p.__version__
60+
), 'Package version is invalid'
61+
"
62+
5363
CIRQ_PACKAGES=$(env PYTHONPATH=. python dev_tools/modules.py list --mode package)
5464
for p in $CIRQ_PACKAGES; do
5565
echo "--- Testing $p -----"
56-
python_test="import $p; print($p); assert '${tmp_dir}' in $p.__file__, 'Package path seems invalid.'"
66+
python_test="${python_test_template//@p/$p}"
5767
env PYTHONPATH='' "${tmp_dir}/env/bin/python" -c "$python_test" && echo -e "\033[32mPASS\033[0m" || echo -e "\033[31mFAIL\033[0m"
5868
done

‎release.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ numbers. The following guarantees are provided:
2121
ever becomes necessary to allow packages to have different version numbers,
2222
this policy will be updated.)
2323

24-
1. Libraries in the `cirq-core` directory (with the exception of
24+
2. Libraries in the `cirq-core` directory (with the exception of
2525
`cirq-core/cirq/contrib`) adhere to the guarantees outlined in the Semantic
2626
Versioning specification. In summary:
2727

@@ -34,14 +34,14 @@ numbers. The following guarantees are provided:
3434
* Additions and/or changes that affect the API in a
3535
backwards-_incompatible_ way will increment the MAJOR version.
3636

37-
1. The contrib directory (at `cirq-core/cirq/contrib`) currently follows
37+
3. The contrib directory (at `cirq-core/cirq/contrib`) currently follows
3838
Semantic Versioning except for the MINOR version increment policy: releases
3939
with MINOR version increments may contain backward-incompatible
4040
functionality changes to its public API. (They may be changed to strictly
4141
follow Semantic Versioning in the future, at which point this policy will
4242
be updated.)
4343

44-
1. Cirq vendor directories (`cirq-aqt`, `cirq-google`, `cirq-ionq`, etc.) follow
44+
4. Cirq vendor directories (`cirq-aqt`, `cirq-google`, `cirq-ionq`, etc.) follow
4545
Semantic Versioning except the MINOR version increment policy: each vendor
4646
directory has a separate policy on whether MINOR version increments provide
4747
backward-compatibility guarantees, as described in `version_policy.md` in the
@@ -54,7 +54,7 @@ numbers. The following guarantees are provided:
5454
1. For each vendor directory, version policies may be modified to strictly
5555
follow Semantic Versioning in the future.
5656

57-
1. Versions based on unreleased branches of `main` will be suffixed with `.dev`.
57+
5. Versions based on unreleased branches of `main` will be suffixed with `.dev0`.
5858

5959
The rules for version changes are:
6060

@@ -76,7 +76,7 @@ We use GitHub's release system for creating releases. Release are listed
7676

7777
Our development process uses the branch named `main` for development. This
7878
branch will always use the next unreleased minor version number with the suffix
79-
of `.dev`. When a release is performed, the `.dev` will be removed and tagged
79+
of `.dev0`. When a release is performed, the `.dev0` will be removed and tagged
8080
in a release branch with a version tag (vX.X.X). Then, `main` will be updated
8181
to the next minor version. The version number of `main` can always be found in
8282
the [version file](./cirq-core/cirq/_version.py).
@@ -158,9 +158,9 @@ git cherry-pick <commit>
158158
Bump the version number on the release branch:
159159

160160
```bash
161-
python dev_tools/modules.py replace_version --old ${VER}.dev --new ${VER}
161+
python dev_tools/modules.py replace_version --old ${VER}.dev0 --new ${VER}
162162
git add .
163-
git commit -m "Removing ${VER}.dev -> ${VER}"
163+
git commit -m "Removing ${VER}.dev0 -> ${VER}"
164164
git push origin "v${VER}-dev"
165165
```
166166

@@ -171,7 +171,7 @@ updates, leave it as it is.
171171

172172
```bash
173173
git checkout main -b "version_bump_${NEXT_VER}"
174-
python dev_tools/modules.py replace_version --old ${VER}.dev --new ${NEXT_VER}.dev
174+
python dev_tools/modules.py replace_version --old ${VER}.dev0 --new ${NEXT_VER}.dev0
175175
git add .
176176
git commit -m "Bump cirq version to ${NEXT_VER}"
177177
git push origin "version_bump_${NEXT_VER}"

‎setup.py

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

15-
import os
16-
from setuptools import setup
15+
import runpy
1716

18-
# This reads the __version__ variable from cirq/_version.py
19-
__version__ = ''
17+
from setuptools import setup
2018

2119
from dev_tools import modules
2220
from dev_tools.requirements import explode
2321

24-
exec(open('cirq-core/cirq/_version.py').read())
22+
# This reads the __version__ variable from cirq-core/cirq/_version.py
23+
__version__ = runpy.run_path('cirq-core/cirq/_version.py')['__version__']
24+
assert __version__, 'Version string cannot be empty'
2525

2626
name = 'cirq'
2727

@@ -33,26 +33,6 @@
3333
# README file as long_description.
3434
long_description = open('README.md', encoding='utf-8').read()
3535

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

0 commit comments

Comments
 (0)
Please sign in to comment.