Skip to content

Commit

Permalink
Fix version attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed May 31, 2024
1 parent ab916d7 commit 080a6af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,32 @@ jobs:
run: |
python -m pip install --upgrade pip wheel build twine toml
pip install ultralytics --extra-index-url https://download.pytorch.org/whl/cpu
pip uninstall -y thop
pip install -e .
- name: Check PyPI version
shell: python
run: |
import os
import toml
import thop
import ultralytics
from ultralytics.utils.checks import check_latest_pypi_version
# Read version from pyproject.toml
with open('pyproject.toml', 'r') as file:
pyproject_version = toml.load(file)['project']['version']
v_local = tuple(map(int, pyproject_version.split('.')))
# Compare with version on PyPI
v_local = tuple(map(int, thop.__version__.split('.')))
v_pypi = tuple(map(int, check_latest_pypi_version('ultralytics-thop').split('.')))
print(f'Local version is {v_local}')
print(f'PyPI version is {v_pypi}')
d = [a - b for a, b in zip(v_local, v_pypi)] # diff
increment = True # (d[0] == d[1] == 0) and (0 < d[2] < 3) # only publish if patch version increments by 1 or 2
increment_patch = (d[0] == d[1] == 0) and (0 < d[2] < 3) # publish if patch version increments by 1 or 2
increment_minor = (d[0] == 0) and (d[1] == 1) and v_local[2] == 0 # publish if minor version increments
increment = increment_patch or increment_minor or True
os.system(f'echo "increment={increment}" >> $GITHUB_OUTPUT')
os.system(f'echo "version={pyproject_version}" >> $GITHUB_OUTPUT')
os.system(f'echo "version={thop.__version__}" >> $GITHUB_OUTPUT')
if increment:
print('Local version is higher than PyPI version. Publishing new version to PyPI ✅.')
id: check_pypi
Expand Down
4 changes: 2 additions & 2 deletions thop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# from .onnx_profile import OnnxProfile
__version__ = "0.2.3"

import torch

from .profile import profile, profile_origin
from .utils import clever_format

default_dtype = torch.float64

__version__ = "0.2.1"

0 comments on commit 080a6af

Please sign in to comment.