Skip to content

Commit

Permalink
Fix version attribute (#15)
Browse files Browse the repository at this point in the history
Co-authored-by: UltralyticsAssistant <[email protected]>
  • Loading branch information
glenn-jocher and UltralyticsAssistant committed May 31, 2024
1 parent 579d26d commit 13e65a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 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
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ authors = [
{ name = "Ligeng Zhu", email = "[email protected]" }
]
maintainers = [
{ name = "Ligeng Zhu", email = "[email protected]" }
{ name = "Glenn Jocher" },
]
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -57,6 +57,7 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
]
dependencies = [
"numpy",
"torch",
]

Expand Down
5 changes: 2 additions & 3 deletions thop/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# 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 13e65a1

Please sign in to comment.