Skip to content

Commit d31c9a2

Browse files
committed
auto version using setuptools_scm
1 parent eb3627e commit d31c9a2

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ sphinxcontrib-htmlhelp
1010
sphinxcontrib-jsmath
1111
nbsphinx==0.9
1212
graphviz==0.20
13+
setuptools-scm # 自动从git tag中构建版本
1314
git+https://github.com/Dengda98/PyFMM.git # 包本身

docs/source/conf.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import sys, os, pathlib
1010
import subprocess
11+
import setuptools_scm
1112

1213
read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True'
1314

@@ -17,21 +18,16 @@
1718

1819
html_last_updated_fmt = '%b %d, %Y'
1920

20-
# 引入版本信息
21-
version = os.getenv('READTHEDOCS_VERSION', 'local')
22-
release = version
23-
# version = "0.1"
24-
25-
2621
def setup(app):
2722
app.add_css_file('my_theme.css')
2823

2924

3025
project = 'PyFMM'
3126
copyright = '2023, Zhu Dengda'
3227
author = 'Zhu Dengda'
33-
release = 'v0.1'
34-
28+
# 引入版本信息
29+
version = setuptools_scm.get_version(root='../..', relative_to=__file__)
30+
release = version
3531

3632
# -- General configuration ---------------------------------------------------
3733
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def run(self):
3131

3232
setup(
3333
name='pyfmm',
34-
version='0.1',
34+
use_scm_version=True, # 自动使用 Git 标签作为版本号
35+
setup_requires=['setuptools-scm'],
3536
description='Your package description',
3637
author='Zhu Dengda',
3738
author_email='[email protected]',

0 commit comments

Comments
 (0)