Skip to content

Commit

Permalink
Features: DEV-3305 Migrate to Poetry, Python 3.9, PyTorch 1.12 (#22)
Browse files Browse the repository at this point in the history
* Use poetry

* Only use Python >= 3.9

* Moved to PyTorch 1.12

* Bump version

* PyTorch 1.11.0 compatibility updates (ultralytics#6932)

Resolves `AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'` first raised in ultralytics#5499

* Bump beta version

* Fix torch `long` to `float` tensor on HUB macOS (ultralytics#8067)

* Bump beta version

* Updated Makefile

* Added README

* Added missing VERSION

* Final major version

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
Mindstan and glenn-jocher committed Sep 15, 2022
1 parent e942902 commit d9f1cd8
Show file tree
Hide file tree
Showing 10 changed files with 1,276 additions and 119 deletions.
35 changes: 17 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
PYTHON_VERSION = 3.6.9
PYTHON_VERSION = 3.9.13

PIP = env/bin/pip
PYTHON = env/bin/python
VIRTUALENV = $(PYENV_ROOT)/versions/$(PYTHON_VERSION)/bin/virtualenv
PIP = poetry run pip
PYTHON = poetry run python

VERSION := $(shell sed -rn 's/^__version__\s*=\s*"(.+)"/\1/p' yolov5/__init__.py)

env:
pyenv install -s $(PYTHON_VERSION) # make sure expected python version is available
$(PYENV_ROOT)/versions/$(PYTHON_VERSION)/bin/pip install virtualenv # ensure virtualenv is installed for given python
if [ ! "$(shell $(PYTHON) -V)" = "Python $(PYTHON_VERSION)" ]; then \
echo "WARNING: python version mismatch => reset virtualenv" && rm -rf env/; \
fi
if [ ! -d env/ ]; then \
$(VIRTUALENV) env/; \
fi
# make sure expected python version is available
PYTHON_CONFIGURE_OPTS=--enable-shared pyenv install -s $(PYTHON_VERSION)
pyenv local $(PYTHON_VERSION)
poetry install --with dev
$(PIP) install -qU pip


init:
$(PIP) install -Ur requirements-dev.txt

Expand All @@ -34,17 +32,18 @@ test:
env/bin/pytest

dist: clean
#check-manifest
$(PYTHON) setup.py sdist bdist_wheel
ls -l dist
env/bin/twine check dist/*
poetry check
ifneq ($(VERSION),$(strip $(shell poetry version | cut -d " " -f 2 )))
$(error Package and code versions mismatch, please try poetry install)
endif
poetry build

tag:
git tag -f -a -m "Auto-generated tag" `sed -rn 's/^__version__\s*=\s*"(.+)"/\1/p' yolov5/__init__.py`
git tag -f -a -m "Auto-generated tag" $(VERSION)
git push --tags --force

release: clean dist tag
env/bin/twine upload dist/* --repository-url https://pypi.psycle.dev/
poetry publish -r psycle

lint:
env/bin/black . --exclude '/(env)/'
Expand Down
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Fork of YOLOv5

## About the package

\# TODO

## Package management

### Makefile

Poetry `~1.2` is required to run the Makefile.

Install the environment:

```bash
make env
```

Build the source and wheel distribution:

```bash
make dist
```

Build and release the package to the private PyPI (requires to setup Poetry auth), and tag this commit:
```bash
make release
```

Remove all temporary files (cached Python code)
```bash
make clean
```

### Poetry

This package is using Poetry. Here are some usefull commands.

```bash
# Install current package environment
poetry install

# Install current package environment with dev dependencies
poetry install --with dev

# Run a command inside the virtualenv
poetry run my_command

# Enter the virtualenv (exit with exit command or <CTRL+D>)
poetry shell

# Update dependances
poetry lock

# Refresh lock file without looking for updated packages
poetry lock --no-update
```
Loading

0 comments on commit d9f1cd8

Please sign in to comment.