Skip to content

Commit

Permalink
dist: use separate data files for version and commit information
Browse files Browse the repository at this point in the history
  • Loading branch information
pfps committed Nov 23, 2022
1 parent fe65ce9 commit 8765089
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ __pycache__/

/lib/Solaar.egg-info/
/lib/solaar.egg-info/
/lib/solaar/commit
/build/
/sdist/
/dist/
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include COPYRIGHT COPYING README.md ChangeLog.md
include COPYRIGHT COPYING README.md ChangeLog.md lib/solaar/version lib/solaar/commit
recursive-include rules.d *
recursive-include share/locale *
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ candidates (ex. `1.0.0rc1`). Release candidates must have a `rcX` suffix.

Release routine:

- Update `lib/solaar/__init__.py` to the new release
- Update version in `lib/solaar/version`
- Add release changes to `ChangeLog.md`
- Add release information to `share/solaar/io.github.pwr_solaar.solaar.metainfo.xml`
- Create a commit that starts with `release VERSION`
Expand Down
10 changes: 6 additions & 4 deletions lib/solaar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import pkgutil as _pkgutil
import subprocess as _subprocess
import sys as _sys

from solaar.version import NAME as _NAME
from solaar.version import version as _version
NAME = 'solaar'

try:
__version__ = _subprocess.check_output(['git', 'describe', '--always'], cwd=_sys.path[0],
stderr=_subprocess.DEVNULL).strip().decode()
except Exception:
__version__ = _version
NAME = _NAME
try:
__version__ = _pkgutil.get_data('solaar', 'commit').strip().decode()
except Exception:
__version__ = _pkgutil.get_data('solaar', 'version').strip().decode()
1 change: 1 addition & 0 deletions lib/solaar/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1.7
2 changes: 0 additions & 2 deletions lib/solaar/version.py

This file was deleted.

15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3

import subprocess

from glob import glob as _glob
Expand All @@ -10,15 +9,16 @@
from distutils.core import setup

NAME = 'Solaar'
version = '1.1.7'

with open('lib/solaar/version', 'r') as vfile:
version = vfile.read().strip()

try:
cver = max(version, subprocess.check_output(['git', 'describe', '--always'], stderr=subprocess.DEVNULL).strip().decode())
commit = subprocess.check_output(['git', 'describe', '--always'], stderr=subprocess.DEVNULL).strip().decode()
with open('lib/solaar/commit', 'w') as vfile:
vfile.write(f'{commit}\n')
except Exception:
cver = version
with open('lib/solaar/version.py', 'w') as vfile:
vfile.write(f'NAME = \'{NAME}\'\n')
vfile.write(f'version = \'{cver}\'\n')
pass


def _data_files():
Expand Down Expand Up @@ -84,5 +84,6 @@ def _data_files():
package_dir={'': 'lib'},
packages=['keysyms', 'hidapi', 'logitech_receiver', 'solaar', 'solaar.ui', 'solaar.cli'],
data_files=list(_data_files()),
include_package_data=True,
scripts=_glob('bin/*'),
)

0 comments on commit 8765089

Please sign in to comment.