Skip to content

Commit

Permalink
ver: bump version to 0.4.2 (#31)
Browse files Browse the repository at this point in the history
* ver: bump version to 0.4.2

* docs(CHANGELOG): add CHANGELOG.md

* docs: update dictionary

* docs: update authors

* feat(workflows): test wheels before release

* fix(workflows): remove single-quotes in env files

* chore(workflows): update triggers

* chore: install torchopt in conda environment

* chore(.gitignore): ignore wheelhouse

* style: update pylint magic comments

* chore(conda-recipe): add patchelf

* chore(workflows): update triggers

* feat: manylinux wheels

* docs: update install instruction

* chore(workflows): list wheels with size

* chore(workflows): use pypa/gh-action-pypi-publish to upload packages

* docs: add badges

* fix(workflows): show wheels one-by-one

* docs: update contribution guide line

* chore(pyproject): use pyproject.toml

* chore: support str for accelerated_op_available

* chore(workflows): test wheels with CPU build of torch

* docs: update CHANGELOG

* fix(accelerated_op): skip checking op on cuda devices when CUDA is not available

* chore: update conda-recipe.yaml

* docs: update CHANGELOG

* docs: update badges

* chore: remove pip edit install in conda recipe
  • Loading branch information
XuehaiPan authored Jul 26, 2022
1 parent bdf1558 commit e0bb3cd
Show file tree
Hide file tree
Showing 21 changed files with 475 additions and 220 deletions.
202 changes: 202 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Build

on:
push:
branches:
- main # allow to trigger the workflow with tag push event
pull_request:
paths:
- setup.py
- setup.cfg
- pyproject.toml
- MANIFEST.in
- CMakeLists.txt
- include/**
- src/**
- torchopt/version.py
- .github/workflow/build.yml
release:
types:
- published
# Allow to trigger the workflow manually
workflow_dispatch:

permissions:
contents: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
runs-on: ubuntu-18.04
if: github.repository == 'metaopt/TorchOpt' && (github.event_name != 'push' || startsWith(github.ref, 'refs/tags/'))
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 1

- name: Set up Python 3.7
id: py37
uses: actions/setup-python@v4
with:
python-version: "3.7"
update-environment: false

- name: Set up Python 3.8
id: py38
uses: actions/setup-python@v4
with:
python-version: "3.8"
update-environment: false

- name: Set up Python 3.9
id: py39
uses: actions/setup-python@v4
with:
python-version: "3.9"
update-environment: false

- name: Set up Python 3.10
id: py310
uses: actions/setup-python@v4
with:
python-version: "3.10"
update-environment: false

- name: Set up Python executable paths
run: |
echo "${{ steps.py37.outputs.python-path }}" > .python-paths
echo "${{ steps.py38.outputs.python-path }}" >> .python-paths
echo "${{ steps.py39.outputs.python-path }}" >> .python-paths
echo "${{ steps.py310.outputs.python-path }}" >> .python-paths
- name: Setup CUDA Toolkit
uses: Jimver/cuda-toolkit@v0.2.7
id: cuda-toolkit
with:
cuda: "11.6.2"
method: network
sub-packages: '["nvcc"]'
- run: |
CUDA_VERSION="${{steps.cuda-toolkit.outputs.cuda}}"
echo "CUDA_VERSION=${CUDA_VERSION}" >> "${GITHUB_ENV}"
TORCH_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr -d '.')"
echo "TORCH_INDEX_URL=${TORCH_INDEX_URL}" >> "${GITHUB_ENV}"
echo "Installed CUDA version is: ${CUDA_VERSION}"
echo "CUDA install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
nvcc -V
echo "Torch index URL: ${TORCH_INDEX_URL}"
- name: Build sdist and wheels
run: |
DEFAULT_PYTHON="$(head -n 1 .python-paths)"
while read -r PYTHON; do
echo "Building wheel with Python: ${PYTHON} ($("${PYTHON}" --version))"
"${PYTHON}" -m pip install --upgrade pip setuptools wheel build
"${PYTHON}" -m pip install --extra-index-url "${TORCH_INDEX_URL}" \
-r requirements.txt
if [[ "${PYTHON}" == "${DEFAULT_PYTHON}" ]]; then
"${PYTHON}" -m build
else
"${PYTHON}" -m build --wheel
fi
done < .python-paths
- name: List built sdist and wheels
run: |
if [[ -n "$(find dist -maxdepth 0 -not -empty -print 2>/dev/null)" ]]; then
echo "Built sdist and wheels:"
ls -lh dist/
else
echo "No sdist and wheels are built."
exit 1
fi
- name: Audit and repair wheels
run: |
while read -r PYTHON; do
PYVER="cp$("${PYTHON}" --version | cut -d ' ' -f2 | cut -d '.' -f-2 | tr -d '.')"
echo "Audit and repair wheel for Python: ${PYTHON} (${PYVER})"
LIBTORCH_PATH="$("${PYTHON}" -c 'import os, site; print(os.path.join(site.getsitepackages()[0], "torch", "lib"))')"
"${PYTHON}" -m pip install --upgrade git+https://github.com/XuehaiPan/auditwheel.git@torchopt
(
export LD_LIBRARY_PATH="${LIBTORCH_PATH}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
"${PYTHON}" -m auditwheel show dist/torchopt-*-${PYVER}-*.whl &&
"${PYTHON}" -m auditwheel repair --plat manylinux2014_x86_64 --wheel-dir wheelhouse dist/torchopt-*-${PYVER}-*.whl
)
done < .python-paths
rm dist/torchopt-*.whl
mv wheelhouse/torchopt-*manylinux*.whl dist/
- name: List built sdist and wheels
run: |
if [[ -n "$(find dist -maxdepth 0 -not -empty -print 2>/dev/null)" ]]; then
echo "Built sdist and wheels:"
ls -lh dist/
else
echo "No sdist and wheels are built."
exit 1
fi
- name: Test sdist and wheels
run: |
DEFAULT_PYTHON="$(head -n 1 .python-paths)"
while read -r PYTHON; do
PYVER="cp$("${PYTHON}" --version | cut -d ' ' -f2 | cut -d '.' -f-2 | tr -d '.')"
mkdir -p "temp-${PYVER}"
pushd "temp-${PYVER}"
if [[ "${PYTHON}" == "${DEFAULT_PYTHON}" ]]; then
echo "Testing sdist with Python: ${PYTHON} (${PYVER})"
"${PYTHON}" -m pip uninstall torch torchopt -y
"${PYTHON}" -m pip install --extra-index-url https://download.pytorch.org/whl/cpu \
../dist/torchopt-*.tar.gz
"${PYTHON}" -c 'import torchopt'
fi
echo "Testing wheel with Python: ${PYTHON} (${PYVER})"
"${PYTHON}" -m pip uninstall torch torchopt -y
"${PYTHON}" -m pip install --extra-index-url https://download.pytorch.org/whl/cpu \
../dist/torchopt-*-${PYVER}-*.whl
"${PYTHON}" -c 'import torchopt'
"${PYTHON}" -m pip uninstall torch torchopt -y
popd
done < .python-paths
- name: Check consistency between the package version and release tag
if: startsWith(github.ref, 'refs/tags/')
run: |
RELEASE_TAG="${GITHUB_REF#refs/*/}"
PACKAGE_VER="v$(python setup.py --version)"
if [[ "${PACKAGE_VER}" != "${RELEASE_TAG}" ]]; then
echo "package ver. (${PACKAGE_VER}) != release tag. (${RELEASE_TAG})"
exit 1
fi
- name: Publish to TestPyPI
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.TESTPYPI_UPLOAD_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
print_hash: true
skip_existing: true

- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.PYPI_UPLOAD_TOKEN }}
verbose: true
print_hash: true
skip_existing: true
13 changes: 6 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ on:
permissions:
contents: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Cancel previous run
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
with:
Expand All @@ -40,9 +39,9 @@ jobs:
sub-packages: '["nvcc"]'
- run: |
CUDA_VERSION="${{steps.cuda-toolkit.outputs.cuda}}"
echo "CUDA_VERSION='${CUDA_VERSION}'" >> "${GITHUB_ENV}"
echo "CUDA_VERSION=${CUDA_VERSION}" >> "${GITHUB_ENV}"
TORCH_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr -d '.')"
echo "TORCH_INDEX_URL='${TORCH_INDEX_URL}'" >> "${GITHUB_ENV}"
echo "TORCH_INDEX_URL=${TORCH_INDEX_URL}" >> "${GITHUB_ENV}"
echo "Installed CUDA version is: ${CUDA_VERSION}"
echo "CUDA install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
Expand Down
98 changes: 0 additions & 98 deletions .github/workflows/release.yml

This file was deleted.

24 changes: 17 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,30 @@ on:
branches:
- main
pull_request:
paths:
- setup.py
- setup.cfg
- pyproject.toml
- MANIFEST.in
- CMakeLists.txt
- include/**
- src/**
- tests/**
- torchopt/**
- .github/workflows/tests.yml

permissions:
contents: read

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Cancel previous run
uses: styfle/cancel-workflow-action@0.10.0
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
with:
Expand All @@ -40,9 +50,9 @@ jobs:
sub-packages: '["nvcc"]'
- run: |
CUDA_VERSION="${{steps.cuda-toolkit.outputs.cuda}}"
echo "CUDA_VERSION='${CUDA_VERSION}'" >> "${GITHUB_ENV}"
echo "CUDA_VERSION=${CUDA_VERSION}" >> "${GITHUB_ENV}"
TORCH_INDEX_URL="https://download.pytorch.org/whl/cu$(echo "${CUDA_VERSION}" | cut -d'.' -f-2 | tr -d '.')"
echo "TORCH_INDEX_URL='${TORCH_INDEX_URL}'" >> "${GITHUB_ENV}"
echo "TORCH_INDEX_URL=${TORCH_INDEX_URL}" >> "${GITHUB_ENV}"
echo "Installed CUDA version is: ${CUDA_VERSION}"
echo "CUDA install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ parts/
sdist/
var/
wheels/
wheelhouse/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down Expand Up @@ -169,7 +170,7 @@ cython_debug/
.LSOverride

# Icon must end with two \r
Icon
Icon

# Thumbnails
._*
Expand Down
Loading

0 comments on commit e0bb3cd

Please sign in to comment.