mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use declarative metadata
- Move to pyproject.toml metadata - Update references to `setup.py` - Use pypa/build - Update workflows and tooling
This commit is contained in:
@@ -23,19 +23,23 @@ def stringify_version(version_info, in_develop=True):
|
||||
|
||||
def bump_version(path, version_info, in_develop=True):
|
||||
version = stringify_version(version_info, in_develop)
|
||||
release = version
|
||||
if in_develop:
|
||||
version += '+'
|
||||
|
||||
with open(path, 'r+', encoding='utf-8') as f:
|
||||
body = f.read()
|
||||
body = re.sub(r"(?<=__version__ = ')[^']+", version, body)
|
||||
body = re.sub(r"(?<=__released__ = ')[^']+", release, body)
|
||||
body = re.sub(r"(?<=version_info = )\(.*\)", str(version_info), body)
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
lines = f.read().splitlines()
|
||||
|
||||
f.seek(0)
|
||||
f.truncate(0)
|
||||
f.write(body)
|
||||
for i, line in enumerate(lines):
|
||||
if line.startswith('__version__ = '):
|
||||
lines[i] = f"__version__ = '{version}'"
|
||||
continue
|
||||
if line.startswith('version_info = '):
|
||||
lines[i] = f'version_info = {version_info}'
|
||||
continue
|
||||
if line.startswith('_in_development = '):
|
||||
lines[i] = f'_in_development = {in_develop}'
|
||||
continue
|
||||
|
||||
with open(path, 'w', encoding='utf-8') as f:
|
||||
f.write('\n'.join(lines) + '\n')
|
||||
|
||||
|
||||
def parse_version(version):
|
||||
|
Reference in New Issue
Block a user