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

Update pyproject.toml #7

Merged
merged 4 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
64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Ultralytics YOLO πŸš€, AGPL-3.0 license
# Publish pip package to PyPI https://pypi.org/project/ultralytics-thop/

name: Publish to PyPI

on:
push:
branches: [main]
workflow_dispatch:
inputs:
pypi:
type: boolean
description: Publish to PyPI

jobs:
publish:
if: github.repository == 'ultralytics/thop' && github.actor == 'glenn-jocher'
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: "0" # pulls all commits (needed correct last updated dates in Docs)
- name: Set up Python environment
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip" # caching pip dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel build twine toml
pip install ultralytics --extra-index-url https://download.pytorch.org/whl/cpu
- name: Check PyPI version
shell: python
run: |
import os
import toml
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_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 = (d[0] == d[1] == 0) and (0 < d[2] < 3) # only publish if patch version increments by 1 or 2
os.system(f'echo "increment={increment}" >> $GITHUB_OUTPUT')
os.system(f'echo "version={pyproject_version}" >> $GITHUB_OUTPUT')
if increment:
print('Local version is higher than PyPI version. Publishing new version to PyPI βœ….')
id: check_pypi
- name: Publish to PyPI
continue-on-error: true
if: (github.event_name == 'push' || github.event.inputs.pypi == 'true') && steps.check_pypi.outputs.increment == 'True'
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
run: |
python -m build
python -m twine upload dist/* -u __token__ -p $PYPI_TOKEN
90 changes: 74 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
.DS_Store
fx_explore/
# *test*
*.t7
*.pth
# only keep the setup.py under root folder
./*.py
!./setup.py

.idea/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -18,7 +8,6 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -31,13 +20,16 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
# before PyInstaller builds the exe, so as to inject date/other info into it.
*.manifest
*.spec

Expand All @@ -48,13 +40,17 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
mlruns/

# Translations
*.mo
Expand All @@ -63,6 +59,8 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -80,32 +78,92 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# Profiling
*.pclprof

# pyenv
.python-version

# celery beat schedule file
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# dotenv
# Environments
.env

# virtualenv
.venv
.idea
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# VSCode project settings
.vscode/

# Rope project settings
.ropeproject

# mkdocs documentation
/site
mkdocs_github_authors.yaml

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# datasets and projects
datasets/
runs/
wandb/
.DS_Store

# Neural Network weights -----------------------------------------------------------------------------------------------
weights/
*.weights
*.pt
*.pb
*.onnx
*.engine
*.mlmodel
*.mlpackage
*.torchscript
*.tflite
*.h5
*_saved_model/
*_web_model/
*_openvino_model/
*_paddle_model/
*_ncnn_model/
pnnx*

# Autogenerated files for tests
/ultralytics/assets/

# calibration image
calibration_*.npy
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# - `[tool.setuptools]`: Configures settings specific to the `setuptools` build backend.
#
# Installation:
# The `thop` library can be installed using the command: `pip install thop`
# The `thop` library can be installed using the command: `pip install ultralytics-thop`
# For development purposes, you can install the package in editable mode with: `pip install -e .`
# This approach allows for real-time code modifications without the need for re-installation.
#
Expand All @@ -24,7 +24,7 @@ requires = ["setuptools>=57.0.0", "wheel"]
build-backend = "setuptools.build_meta"

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