Skip to content

Commit

Permalink
Build and test python wheel with github actions (#687)
Browse files Browse the repository at this point in the history
* try to build with github actions
  • Loading branch information
lanpa committed Feb 12, 2023
1 parent da08432 commit d167c85
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 1 deletion.
126 changes: 126 additions & 0 deletions .github/workflows/build-pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Build and test the python package
on:
push:
branches:
- 'releases/**'
jobs:
build:
name: Build whl from source
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9

- name: Install pypa/build
run: >-
python -m
pip install
build wheel
--user
- name: Build a binary wheel and a source tarball
run: |
echo `pwd`
echo `git log|head -n 50`
python setup.py -q sdist bdist_wheel --universal
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: dist-pip-whl
path: |
dist
test-the-wheel:
name: Install whl and run demo
needs: build
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
id: github_context_step
run: echo '${{ toJSON(github) }}'

- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9

- name: Download the whl
uses: actions/download-artifact@v3
with:
name: dist-pip-whl

- name: Install tensorboardX from whl
run: pip install tensorboardX*.whl

- name: Install torch torchvision for demo
run: pip install torch torchvision

- name: Print version
run: python -c "import tensorboardX; print(tensorboardX.__version__)"

- name: Run examples
run: |
cd examples
python demo.py
- name: Archive demo artifacts
uses: actions/upload-artifact@v3
with:
name: demo-results
path: |
examples/runs
upload-to-pypi:
if: startsWith(github.ref, 'refs/tags/v')
name: Upload to pypi if tagged with version
needs: build
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
id: github_context_step
run: echo '${{ toJSON(github) }}'

# upload:
# if: startsWith('github.ref', 'refs/tags/v')
# name: Publish a Python distribution to PyPI test site
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python 3.9
# uses: actions/setup-python@v2
# with:
# python-version: 3.9
#
# - name: Install pypa/build
# run: >-
# python -m
# pip install
# build wheel
# --user
#
# - name: Build a binary wheel and a source tarball
# run: |
# echo `pwd`
# python setup.py -q sdist bdist_wheel --universal
#
# - name: Publish to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TESTSITE }}
# repository_url: https://test.pypi.org/legacy/


# - name: Publish to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.PYPI_API_TESTSITE }}
# repository_url: https://test.pypi.org/legacy/
#
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run(self):
history = history_file.read()

preparing_PyPI_package = 'sdist' in sys.argv or 'bdist_wheel' in sys.argv
version_git = version = '2.5.1'
version_git = version = subprocess.check_output(['git', 'describe', '--always']).decode('ascii').strip()

if not preparing_PyPI_package:
if os.path.exists('.git'):
Expand All @@ -43,6 +43,7 @@ def run(self):

requirements = [
'numpy',
'packaging',
'protobuf>=3.8.0,<4',
]

Expand Down

0 comments on commit d167c85

Please sign in to comment.