Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix version attribute #15

Merged
merged 5 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"