Skip to content

Commit fc4ef2f

Browse files
authored
Update pyproject.toml (ultralytics#7)
1 parent b861e44 commit fc4ef2f

File tree

3 files changed

+140
-18
lines changed

3 files changed

+140
-18
lines changed

.github/workflows/publish.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Ultralytics YOLO 🚀, AGPL-3.0 license
2+
# Publish pip package to PyPI https://pypi.org/project/ultralytics-thop/
3+
4+
name: Publish to PyPI
5+
6+
on:
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
inputs:
11+
pypi:
12+
type: boolean
13+
description: Publish to PyPI
14+
15+
jobs:
16+
publish:
17+
if: github.repository == 'ultralytics/thop' && github.actor == 'glenn-jocher'
18+
name: Publish
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: "0" # pulls all commits (needed correct last updated dates in Docs)
25+
- name: Set up Python environment
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.11"
29+
cache: "pip" # caching pip dependencies
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip wheel build twine toml
33+
pip install ultralytics --extra-index-url https://download.pytorch.org/whl/cpu
34+
- name: Check PyPI version
35+
shell: python
36+
run: |
37+
import os
38+
import toml
39+
from ultralytics.utils.checks import check_latest_pypi_version
40+
41+
# Read version from pyproject.toml
42+
with open('pyproject.toml', 'r') as file:
43+
pyproject_version = toml.load(file)['project']['version']
44+
v_local = tuple(map(int, pyproject_version.split('.')))
45+
46+
# Compare with version on PyPI
47+
v_pypi = tuple(map(int, check_latest_pypi_version('ultralytics-thop').split('.')))
48+
print(f'Local version is {v_local}')
49+
print(f'PyPI version is {v_pypi}')
50+
d = [a - b for a, b in zip(v_local, v_pypi)] # diff
51+
increment = (d[0] == d[1] == 0) and (0 < d[2] < 3) # only publish if patch version increments by 1 or 2
52+
os.system(f'echo "increment={increment}" >> $GITHUB_OUTPUT')
53+
os.system(f'echo "version={pyproject_version}" >> $GITHUB_OUTPUT')
54+
if increment:
55+
print('Local version is higher than PyPI version. Publishing new version to PyPI ✅.')
56+
id: check_pypi
57+
- name: Publish to PyPI
58+
continue-on-error: true
59+
if: (github.event_name == 'push' || github.event.inputs.pypi == 'true') && steps.check_pypi.outputs.increment == 'True'
60+
env:
61+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
62+
run: |
63+
python -m build
64+
python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN

.gitignore

+74-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
.DS_Store
2-
fx_explore/
3-
# *test*
4-
*.t7
5-
*.pth
6-
# only keep the setup.py under root folder
7-
./*.py
8-
!./setup.py
9-
10-
.idea/
111
# Byte-compiled / optimized / DLL files
122
__pycache__/
133
*.py[cod]
@@ -18,7 +8,6 @@ __pycache__/
188

199
# Distribution / packaging
2010
.Python
21-
env/
2211
build/
2312
develop-eggs/
2413
dist/
@@ -31,13 +20,16 @@ parts/
3120
sdist/
3221
var/
3322
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
3425
*.egg-info/
3526
.installed.cfg
3627
*.egg
28+
MANIFEST
3729

3830
# PyInstaller
3931
# Usually these files are written by a python script from a template
40-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
# before PyInstaller builds the exe, so as to inject date/other info into it.
4133
*.manifest
4234
*.spec
4335

@@ -48,13 +40,17 @@ pip-delete-this-directory.txt
4840
# Unit test / coverage reports
4941
htmlcov/
5042
.tox/
43+
.nox/
5144
.coverage
5245
.coverage.*
5346
.cache
5447
nosetests.xml
5548
coverage.xml
5649
*.cover
50+
*.py,cover
5751
.hypothesis/
52+
.pytest_cache/
53+
mlruns/
5854

5955
# Translations
6056
*.mo
@@ -63,6 +59,8 @@ coverage.xml
6359
# Django stuff:
6460
*.log
6561
local_settings.py
62+
db.sqlite3
63+
db.sqlite3-journal
6664

6765
# Flask stuff:
6866
instance/
@@ -80,32 +78,92 @@ target/
8078
# Jupyter Notebook
8179
.ipynb_checkpoints
8280

81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# Profiling
86+
*.pclprof
87+
8388
# pyenv
8489
.python-version
8590

86-
# celery beat schedule file
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
99+
__pypackages__/
100+
101+
# Celery stuff
87102
celerybeat-schedule
103+
celerybeat.pid
88104

89105
# SageMath parsed files
90106
*.sage.py
91107

92-
# dotenv
108+
# Environments
93109
.env
94-
95-
# virtualenv
96110
.venv
111+
.idea
112+
env/
97113
venv/
98114
ENV/
115+
env.bak/
116+
venv.bak/
99117

100118
# Spyder project settings
101119
.spyderproject
102120
.spyproject
103121

122+
# VSCode project settings
123+
.vscode/
124+
104125
# Rope project settings
105126
.ropeproject
106127

107128
# mkdocs documentation
108129
/site
130+
mkdocs_github_authors.yaml
109131

110132
# mypy
111133
.mypy_cache/
134+
.dmypy.json
135+
dmypy.json
136+
137+
# Pyre type checker
138+
.pyre/
139+
140+
# datasets and projects
141+
datasets/
142+
runs/
143+
wandb/
144+
.DS_Store
145+
146+
# Neural Network weights -----------------------------------------------------------------------------------------------
147+
weights/
148+
*.weights
149+
*.pt
150+
*.pb
151+
*.onnx
152+
*.engine
153+
*.mlmodel
154+
*.mlpackage
155+
*.torchscript
156+
*.tflite
157+
*.h5
158+
*_saved_model/
159+
*_web_model/
160+
*_openvino_model/
161+
*_paddle_model/
162+
*_ncnn_model/
163+
pnnx*
164+
165+
# Autogenerated files for tests
166+
/ultralytics/assets/
167+
168+
# calibration image
169+
calibration_*.npy

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# - `[tool.setuptools]`: Configures settings specific to the `setuptools` build backend.
1313
#
1414
# Installation:
15-
# The `thop` library can be installed using the command: `pip install thop`
15+
# The `thop` library can be installed using the command: `pip install ultralytics-thop`
1616
# For development purposes, you can install the package in editable mode with: `pip install -e .`
1717
# This approach allows for real-time code modifications without the need for re-installation.
1818
#
@@ -24,7 +24,7 @@ requires = ["setuptools>=57.0.0", "wheel"]
2424
build-backend = "setuptools.build_meta"
2525

2626
[project]
27-
name = "thop"
27+
name = "ultralytics-thop"
2828
version = "0.0.1" # Placeholder version, needs to be dynamically set
2929
description = "A tool to count the FLOPs of PyTorch model."
3030
readme = "README.md"

0 commit comments

Comments
 (0)