Skip to content

Commit 60b50ee

Browse files
committed
Use setuptools-scm
1 parent 1ddcc6e commit 60b50ee

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

b2.spec

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# -*- mode: python ; coding: utf-8 -*-
22

3+
from PyInstaller.utils.hooks import copy_metadata
4+
35
block_cipher = None
46

57
a = Analysis(['b2/console_tool.py'],
68
pathex=['.'],
79
binaries=[],
8-
datas=[],
10+
datas=copy_metadata('b2'),
911
hiddenimports=['pkg_resources.py2_warn'],
1012
hookspath=[],
1113
runtime_hooks=[],

b2/version.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,9 @@
88
#
99
######################################################################
1010

11-
VERSION = '2.1.1'
11+
from importlib.metadata import version, PackageNotFoundError
12+
13+
try:
14+
VERSION = version('b2')
15+
except PackageNotFoundError:
16+
VERSION = '0.0.0'

noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ def build(session):
166166
@nox.session(python=PYTHON_DEFAULT_VERSION)
167167
def bundle(session):
168168
"""Bundle the distribution."""
169-
install_myself(session)
170169
session.install('pyinstaller')
171170
session.run('rm', '-rf', 'build', 'dist', 'b2.egg-info', external=True)
171+
install_myself(session)
172172
session.run('pyinstaller', '--onefile', *session.posargs, 'b2.spec')
173173

174174
# Set outputs for GitHub Actions

setup.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,9 @@
4646
if platform.system().lower().startswith('java'):
4747
requirements.append('idna>=2.2.0')
4848

49-
version = import_module('b2').__version__
5049

5150
setup(
5251
name='b2',
53-
54-
# Versions should comply with PEP440. For a discussion on single-sourcing
55-
# the version across setup.py and the project code, see
56-
# https://packaging.python.org/en/latest/single_source_version.html
57-
version=version,
5852
description='Command Line Tool for Backblaze B2',
5953
long_description=long_description,
6054
long_description_content_type='text/markdown',
@@ -123,6 +117,8 @@
123117
'sphinxcontrib-plantuml', 'sadisplay'
124118
],
125119
},
120+
setup_requires=['setuptools_scm'],
121+
use_scm_version=True,
126122

127123
# If there are data files included in your packages that need to be
128124
# installed, specify them here.
@@ -140,6 +136,6 @@
140136
# "scripts" keyword. Entry points provide cross-platform support and allow
141137
# pip to create the appropriate form of executable for the target platform.
142138
entry_points={
143-
'console_scripts': ['b2=b2.console_tool:main',],
139+
'console_scripts': ['b2=b2.console_tool:main'],
144140
},
145141
)

0 commit comments

Comments
 (0)