From 070af677db433e7c33a157b032982a98425139ea Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 15:54:05 +0900 Subject: [PATCH 1/8] [ci] test release CI --- .github/workflows/gardener.yml | 12 --- .github/workflows/persubmit.yml | 154 -------------------------------- .github/workflows/release.yml | 13 +-- python/build.py | 78 ++++++++-------- 4 files changed, 42 insertions(+), 215 deletions(-) delete mode 100644 .github/workflows/gardener.yml delete mode 100644 .github/workflows/persubmit.yml diff --git a/.github/workflows/gardener.yml b/.github/workflows/gardener.yml deleted file mode 100644 index 19c266a94..000000000 --- a/.github/workflows/gardener.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Taichi Gardener -on: - pull_request: - types: [review_requested, synchronize] - -jobs: - format: - name: Trigger Format Server - runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.requested_reviewers.*.login, 'taichi-gardener') && github.event.sender.login != 'taichi-gardener' }} - steps: - - run: curl http://kun.csail.mit.edu:31415/${{ github.event.pull_request.number }} -LO diff --git a/.github/workflows/persubmit.yml b/.github/workflows/persubmit.yml deleted file mode 100644 index 6f9b1dc64..000000000 --- a/.github/workflows/persubmit.yml +++ /dev/null @@ -1,154 +0,0 @@ -name: Persubmit Checks -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - build_and_test_cpu: - name: Build and Test (CPU) - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip ci') && github.event.sender.login != 'taichi-gardener' }} - strategy: - matrix: - include: - - os: ubuntu-latest - python: 3.6 - with_cc: OFF - - os: macos-latest - python: 3.7 - with_cc: OFF - - os: ubuntu-latest - python: 3.9 - with_cc: OFF - - os: ubuntu-latest - python: 3.8 - with_cc: ON - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - - - name: Download Pre-Built LLVM 10.0.0 - run: | - python misc/ci_download.py - mkdir taichi-llvm - cd taichi-llvm - unzip ../taichi-llvm.zip - env: - CI_PLATFORM: ${{ matrix.os }} - - - name: Build - run: | - export TAICHI_REPO_DIR=`pwd` - export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH - export CXX=clang++ - python misc/ci_setup.py ci - env: - CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=OFF -DTI_WITH_CC:BOOL=${{ matrix.with_cc }} - - - name: Test - run: | - export TAICHI_REPO_DIR=`pwd` - export PATH=$TAICHI_REPO_DIR/bin:$PATH - export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH - export PYTHONPATH=$TAICHI_REPO_DIR/python - python examples/laplace.py - ti diagnose - ti test -vr2 -t2 - - build_and_test_gpu: - name: Build and Test (GPU) - if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip ci') && github.event.sender.login != 'taichi-gardener' }} - runs-on: [zhen] - steps: - - uses: actions/checkout@v2 - - - name: Build - run: | - git --version - export TAICHI_REPO_DIR=`pwd` - export PATH=/home/github/taichi-llvm/bin/:$PATH - export CXX=clang++-8 - export PYTHON=/usr/bin/python3.7 - $PYTHON misc/ci_setup.py ci - env: - CI_SETUP_CMAKE_ARGS: -DTI_WITH_OPENGL:BOOL=ON -DTI_WITH_CC:BOOL=OFF - - - name: Test - run: | - export PYTHON=/usr/bin/python3.7 - export TAICHI_REPO_DIR=`pwd` - export PATH=$TAICHI_REPO_DIR/bin:$PATH - export PATH=/home/github/taichi-llvm/bin/:$PATH - export PYTHONPATH=$TAICHI_REPO_DIR/python - export DISPLAY=:1 - glewinfo - $PYTHON examples/laplace.py - ti diagnose - ti test -vr2 -t2 - - check_previous_run: - name: Checks the Workflow Run of the Previous Commit - runs-on: ubuntu-latest - if: ${{ contains(github.event.pull_request.labels.*.name, 'skip ci') || github.event.sender.login == 'taichi-gardener' }} - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Check the previous run - env: - PR: ${{ github.event.pull_request.number }} - SHA: ${{ github.event.pull_request.head.sha }} - # https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token - # https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets - # Do not leak the secret - OAUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - python misc/ci_check_previous_run.py --pr "${PR}" --sha "${SHA}" --token "${OAUTH_TOKEN}" - - code_format: - name: Code Format - runs-on: ubuntu-latest - # Run this job unconditionally -- it is a required check for merging. - # if: ${{ !contains(github.event.pull_request.requested_reviewers.*.login, 'taichi-gardener') }} - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Check code format - run: | - git fetch https://github.com/taichi-dev/taichi.git refs/heads/master - git reset FETCH_HEAD - git add . - git config user.email "taichigardener@gmail.com" - git config user.name "Taichi Gardener" - git commit -m "fake squash commit" || true - git checkout -b _last_squash - git checkout -b _enforced_format - git reset FETCH_HEAD - python3 -m pip install --user yapf gitpython colorama - python3 python/taichi/code_format.py - git add . - git commit -m "enforce code format" || true - # exit with 1 if there were differences: - git diff _last_squash _enforced_format --exit-code - - title_format: - name: Check PR Title - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Run PR Title Checker - run: | - pip install semver GitPython - python misc/ci_check_pr_title.py "$PR_TITLE" - env: - PR_TITLE: ${{ github.event.pull_request.title }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e0d27106..d89e3382e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,7 @@ name: Publishing Release on: - release: - # https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#release - types: [published] + pull_request: + types: [opened, synchronize, reopened] jobs: build_and_test_cpu: @@ -10,12 +9,6 @@ jobs: strategy: matrix: include: - - os: macos-latest - python: 3.6 - with_cc: OFF - - os: macos-latest - python: 3.7 - with_cc: OFF - os: macos-latest python: 3.8 with_cc: OFF @@ -63,4 +56,4 @@ jobs: export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH export PYTHONPATH=$TAICHI_REPO_DIR/python cd python - python build.py try_upload && bash <(curl -s https://codecov.io/bash) + python build.py try_upload diff --git a/python/build.py b/python/build.py index d0ea9b4c2..2b3bfe098 100644 --- a/python/build.py +++ b/python/build.py @@ -15,15 +15,15 @@ env_pypi_pwd = os.environ.get('PYPI_PWD', '') -if mode == 'try_upload': - if env_pypi_pwd == '': - print("Missing environment variable PYPI_PWD") - print("Giving up and exiting 0 [try_upload mode]") - exit(0) - mode = 'upload' +# if mode == 'try_upload': +# if env_pypi_pwd == '': +# print("Missing environment variable PYPI_PWD") +# print("Giving up and exiting 0 [try_upload mode]") +# exit(0) +# mode = 'upload' -if mode == 'upload' and env_pypi_pwd == '': - assert False, "Missing environment variable PYPI_PWD" +# if mode == 'upload' and env_pypi_pwd == '': +# assert False, "Missing environment variable PYPI_PWD" def get_os_name(): @@ -132,34 +132,34 @@ def get_python_executable(): pass shutil.rmtree('./build') -if mode == 'upload': - os.system( - '{} -m twine upload dist/* --verbose -u yuanming-hu -p {}'.format( - get_python_executable(), - '%PYPI_PWD%' if get_os_name() == 'win' else '$PYPI_PWD')) -elif mode == 'test': - print('Uninstalling old taichi packages...') - os.system(f'{get_python_executable()} -m pip uninstall taichi-nightly') - os.system(f'{get_python_executable()} -m pip uninstall taichi') - dists = os.listdir('dist') - assert len(dists) == 1 - dist = dists[0] - print('Installing ', dist) - os.environ['PYTHONPATH'] = '' - os.makedirs('test_env', exist_ok=True) - os.system('cd test_env && {} -m pip install ../dist/{} --user'.format( - get_python_executable(), dist)) - print('Entering test environment...') - if get_os_name() == 'win': - os.system( - 'cmd /V /C "set PYTHONPATH=&& set TAICHI_REPO_DIR=&& cd test_env && cmd"' - ) - else: - os.system( - 'cd test_env && PYTHONPATH= TAICHI_REPO_DIR= bash --noprofile --norc ' - ) -elif mode == '': - pass -else: - print("Unknown mode: ", mode) - exit(-1) +# if mode == 'upload': +# os.system( +# '{} -m twine upload dist/* --verbose -u yuanming-hu -p {}'.format( +# get_python_executable(), +# '%PYPI_PWD%' if get_os_name() == 'win' else '$PYPI_PWD')) +# elif mode == 'test': +# print('Uninstalling old taichi packages...') +# os.system(f'{get_python_executable()} -m pip uninstall taichi-nightly') +# os.system(f'{get_python_executable()} -m pip uninstall taichi') +# dists = os.listdir('dist') +# assert len(dists) == 1 +# dist = dists[0] +# print('Installing ', dist) +# os.environ['PYTHONPATH'] = '' +# os.makedirs('test_env', exist_ok=True) +# os.system('cd test_env && {} -m pip install ../dist/{} --user'.format( +# get_python_executable(), dist)) +# print('Entering test environment...') +# if get_os_name() == 'win': +# os.system( +# 'cmd /V /C "set PYTHONPATH=&& set TAICHI_REPO_DIR=&& cd test_env && cmd"' +# ) +# else: +# os.system( +# 'cd test_env && PYTHONPATH= TAICHI_REPO_DIR= bash --noprofile --norc ' +# ) +# elif mode == '': +# pass +# else: +# print("Unknown mode: ", mode) +# exit(-1) From b970c2761c8d8a5d92161ab9bcbfb4805f8d5065 Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 16:55:13 +0900 Subject: [PATCH 2/8] rm test --- .github/workflows/release.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d89e3382e..c260514c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,16 +35,6 @@ jobs: export CXX=clang++ python misc/ci_setup.py ci - - name: Test - run: | - export TAICHI_REPO_DIR=`pwd` - export PATH=$TAICHI_REPO_DIR/bin:$PATH - export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH - export PYTHONPATH=$TAICHI_REPO_DIR/python - python examples/laplace.py - ti diagnose - ti test -vr2 -t2 - # TODO(#1580): Upload to PyPI. Need to set up PYPI_PWD in the secrets first. - name: Upload PyPI env: From bf849ad939a5eb810e719173e90cc0c5111c09bd Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 17:19:46 +0900 Subject: [PATCH 3/8] archive wheels --- .github/workflows/release.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c260514c2..fa0157a34 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,6 +9,12 @@ jobs: strategy: matrix: include: + - os: macos-latest + python: 3.6 + with_cc: OFF + - os: macos-latest + python: 3.7 + with_cc: OFF - os: macos-latest python: 3.8 with_cc: OFF @@ -47,3 +53,9 @@ jobs: export PYTHONPATH=$TAICHI_REPO_DIR/python cd python python build.py try_upload + + - name: Archive Wheel Artifacts + uses: actions/upload-artifact@v2 + with: + name: taichi-${{ matrix.python }}-${{ matrix.os }}.whl + path: python/dist/*.whl From b257968a1e7d3d371c62209969c74fe2a2ca9bdc Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 20:05:33 +0900 Subject: [PATCH 4/8] build.py --- python/build.py | 302 ++++++++++++++++++++++++++---------------------- 1 file changed, 162 insertions(+), 140 deletions(-) diff --git a/python/build.py b/python/build.py index 2b3bfe098..4f812da47 100644 --- a/python/build.py +++ b/python/build.py @@ -5,26 +5,6 @@ import shutil import taichi as ti -if len(sys.argv) != 2: - print("Usage: python3 build.py [upload/try_upload/test]") - exit(-1) - -version = ti.core.get_version_string() -gpu = ti.core.with_cuda() -mode = sys.argv[1] - -env_pypi_pwd = os.environ.get('PYPI_PWD', '') - -# if mode == 'try_upload': -# if env_pypi_pwd == '': -# print("Missing environment variable PYPI_PWD") -# print("Giving up and exiting 0 [try_upload mode]") -# exit(0) -# mode = 'upload' - -# if mode == 'upload' and env_pypi_pwd == '': -# assert False, "Missing environment variable PYPI_PWD" - def get_os_name(): name = platform.platform() @@ -43,123 +23,165 @@ def get_python_executable(): return '"' + sys.executable.replace('\\', '/') + '"' -if platform.system() == 'Linux': - if os.environ.get('CXX', - 'clang++') not in ['clang++-8', 'clang++-7', 'clang++']: - print('Only the wheel with clang will be released to PyPI.') - sys.exit(-1) - -with open('../setup.py') as fin: - with open('setup.py', 'w') as fout: - project_name = 'taichi' - print("project_name = '{}'".format(project_name), file=fout) - print("version = '{}'".format(version), file=fout) - for l in fin: - print(l, file=fout, end='') - -print("*** project_name = '{}'".format(project_name)) - -try: - os.remove('taichi/CHANGELOG.md') -except FileNotFoundError: - pass -shutil.rmtree('taichi/lib', ignore_errors=True) -shutil.rmtree('taichi/tests', ignore_errors=True) -shutil.rmtree('taichi/examples', ignore_errors=True) -shutil.rmtree('taichi/assets', ignore_errors=True) -os.makedirs('taichi/lib', exist_ok=True) -shutil.rmtree('build', ignore_errors=True) -shutil.rmtree('dist', ignore_errors=True) -shutil.rmtree('taichi/include', ignore_errors=True) -# shutil.copytree('../include/', 'taichi/include') -build_dir = '../build' - -if get_os_name() == 'linux': - shutil.copy('../build/libtaichi_core.so', 'taichi/lib/taichi_core.so') -elif get_os_name() == 'osx': - shutil.copy('../build/libtaichi_core.dylib', 'taichi/lib/taichi_core.so') -else: - shutil.copy('../runtimes/RelWithDebInfo/taichi_core.dll', - 'taichi/lib/taichi_core.pyd') - -os.system(f'cd .. && {get_python_executable()} -m taichi changelog --save') - -try: - with open('../CHANGELOG.md') as f: - print(f.read()) -except FileNotFoundError: - print('CHANGELOG.md not found') - pass - -try: - shutil.copy('../CHANGELOG.md', './taichi/CHANGELOG.md') -except FileNotFoundError: - pass -shutil.copytree('../tests/python', './taichi/tests') -shutil.copytree('../examples', './taichi/examples') -shutil.copytree('../external/assets', './taichi/assets') - -if get_os_name() != 'osx': - libdevice_path = ti.core.libdevice_path() - print("copying libdevice:", libdevice_path) - assert os.path.exists(libdevice_path) - shutil.copy(libdevice_path, 'taichi/lib/slim_libdevice.10.bc') - -ti.core.compile_runtimes() -runtime_dir = ti.core.get_runtime_dir() -for f in os.listdir(runtime_dir): - if f.startswith('runtime_') and f.endswith('.bc'): - print(f"Fetching runtime file {f}") - shutil.copy(os.path.join(runtime_dir, f), 'taichi/lib') - -print("Using python executable", get_python_executable()) -os.system('{} -m pip install --user --upgrade twine setuptools wheel'.format( - get_python_executable())) - -if get_os_name() == 'linux': - os.system('{} setup.py bdist_wheel -p manylinux1_x86_64'.format( - get_python_executable())) -else: - os.system('{} setup.py bdist_wheel'.format(get_python_executable())) - -shutil.rmtree('taichi/lib') -shutil.rmtree('taichi/tests') -shutil.rmtree('taichi/examples') -shutil.rmtree('taichi/assets') -try: - os.remove('taichi/CHANGELOG.md') -except FileNotFoundError: - pass -shutil.rmtree('./build') - -# if mode == 'upload': -# os.system( -# '{} -m twine upload dist/* --verbose -u yuanming-hu -p {}'.format( -# get_python_executable(), -# '%PYPI_PWD%' if get_os_name() == 'win' else '$PYPI_PWD')) -# elif mode == 'test': -# print('Uninstalling old taichi packages...') -# os.system(f'{get_python_executable()} -m pip uninstall taichi-nightly') -# os.system(f'{get_python_executable()} -m pip uninstall taichi') -# dists = os.listdir('dist') -# assert len(dists) == 1 -# dist = dists[0] -# print('Installing ', dist) -# os.environ['PYTHONPATH'] = '' -# os.makedirs('test_env', exist_ok=True) -# os.system('cd test_env && {} -m pip install ../dist/{} --user'.format( -# get_python_executable(), dist)) -# print('Entering test environment...') -# if get_os_name() == 'win': -# os.system( -# 'cmd /V /C "set PYTHONPATH=&& set TAICHI_REPO_DIR=&& cd test_env && cmd"' -# ) -# else: -# os.system( -# 'cd test_env && PYTHONPATH= TAICHI_REPO_DIR= bash --noprofile --norc ' -# ) -# elif mode == '': -# pass -# else: -# print("Unknown mode: ", mode) -# exit(-1) +def build(): + """Build and package the wheel file in `python/dist`""" + if platform.system() == 'Linux': + if os.environ.get( + 'CXX', 'clang++') not in ['clang++-8', 'clang++-7', 'clang++']: + raise RuntimeError( + 'Only the wheel with clang will be released to PyPI') + + version = ti.core.get_version_string() + with open('../setup.py') as fin: + with open('setup.py', 'w') as fout: + project_name = 'taichi' + print("project_name = '{}'".format(project_name), file=fout) + print("version = '{}'".format(version), file=fout) + for l in fin: + print(l, file=fout, end='') + + print("*** project_name = '{}'".format(project_name)) + + try: + os.remove('taichi/CHANGELOG.md') + except FileNotFoundError: + pass + shutil.rmtree('taichi/lib', ignore_errors=True) + shutil.rmtree('taichi/tests', ignore_errors=True) + shutil.rmtree('taichi/examples', ignore_errors=True) + shutil.rmtree('taichi/assets', ignore_errors=True) + os.makedirs('taichi/lib', exist_ok=True) + shutil.rmtree('build', ignore_errors=True) + shutil.rmtree('dist', ignore_errors=True) + shutil.rmtree('taichi/include', ignore_errors=True) + # shutil.copytree('../include/', 'taichi/include') + build_dir = '../build' + + if get_os_name() == 'linux': + shutil.copy('../build/libtaichi_core.so', 'taichi/lib/taichi_core.so') + elif get_os_name() == 'osx': + shutil.copy('../build/libtaichi_core.dylib', + 'taichi/lib/taichi_core.so') + else: + shutil.copy('../runtimes/RelWithDebInfo/taichi_core.dll', + 'taichi/lib/taichi_core.pyd') + + os.system(f'cd .. && {get_python_executable()} -m taichi changelog --save') + + try: + with open('../CHANGELOG.md') as f: + print(f.read()) + except FileNotFoundError: + print('CHANGELOG.md not found') + pass + + try: + shutil.copy('../CHANGELOG.md', './taichi/CHANGELOG.md') + except FileNotFoundError: + pass + shutil.copytree('../tests/python', './taichi/tests') + shutil.copytree('../examples', './taichi/examples') + shutil.copytree('../external/assets', './taichi/assets') + + if get_os_name() != 'osx': + libdevice_path = ti.core.libdevice_path() + print("copying libdevice:", libdevice_path) + assert os.path.exists(libdevice_path) + shutil.copy(libdevice_path, 'taichi/lib/slim_libdevice.10.bc') + + ti.core.compile_runtimes() + runtime_dir = ti.core.get_runtime_dir() + for f in os.listdir(runtime_dir): + if f.startswith('runtime_') and f.endswith('.bc'): + print(f"Fetching runtime file {f}") + shutil.copy(os.path.join(runtime_dir, f), 'taichi/lib') + + print("Using python executable", get_python_executable()) + os.system( + '{} -m pip install --user --upgrade twine setuptools wheel'.format( + get_python_executable())) + + if get_os_name() == 'linux': + os.system('{} setup.py bdist_wheel -p manylinux1_x86_64'.format( + get_python_executable())) + else: + os.system('{} setup.py bdist_wheel'.format(get_python_executable())) + + shutil.rmtree('taichi/lib') + shutil.rmtree('taichi/tests') + shutil.rmtree('taichi/examples') + shutil.rmtree('taichi/assets') + try: + os.remove('taichi/CHANGELOG.md') + except FileNotFoundError: + pass + shutil.rmtree('./build') + + +def parse_args(): + parser = argparse.ArgumentParser(description=( + 'Build and uploads wheels to PyPI. Make sure to run this script ' + 'inside `python/`')) + parser.add_argument('mode', + type=str, + default='', + help=('Choose one of the modes: ' + '[build, test, try_upload, upload]')) + parser.add_argument('--skip_build', + action='store_true', + help=('Skip the build process if this is enabled')) + return parser.parse_args() + + +def main(): + args = parse_args() + mode = args.mode + + env_pypi_pwd = os.environ.get('PYPI_PWD', '') + if mode == 'try_upload': + if env_pypi_pwd == '': + print("Missing environment variable PYPI_PWD") + print("Giving up and exiting 0 [try_upload mode]") + exit(0) + mode = 'upload' + + if mode == 'upload' and env_pypi_pwd == '': + raise RuntimeError("Missing environment variable PYPI_PWD") + + if not args.skip_build: + build() + + if mode == 'build': + return + elif mode == 'upload': + os.system( + '{} -m twine upload dist/* --verbose -u yuanming-hu -p {}'.format( + get_python_executable(), + '%PYPI_PWD%' if get_os_name() == 'win' else '$PYPI_PWD')) + elif mode == 'test': + print('Uninstalling old taichi packages...') + os.system(f'{get_python_executable()} -m pip uninstall taichi-nightly') + os.system(f'{get_python_executable()} -m pip uninstall taichi') + dists = os.listdir('dist') + assert len(dists) == 1 + dist = dists[0] + print('Installing ', dist) + os.environ['PYTHONPATH'] = '' + os.makedirs('test_env', exist_ok=True) + os.system('cd test_env && {} -m pip install ../dist/{} --user'.format( + get_python_executable(), dist)) + print('Entering test environment...') + if get_os_name() == 'win': + os.system( + 'cmd /V /C "set PYTHONPATH=&& set TAICHI_REPO_DIR=&& cd test_env && cmd"' + ) + else: + os.system( + 'cd test_env && PYTHONPATH= TAICHI_REPO_DIR= bash --noprofile --norc ' + ) + else: + raise ValueError("Unknown mode: %s" % mode) + + +if __name__ == '__main__': + main() From b58bd1a3f048c65725935ada636a1dc19e52e97d Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 20:08:05 +0900 Subject: [PATCH 5/8] separate build and upload --- .github/workflows/release.yml | 20 ++++++++++++++------ python/build.py | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa0157a34..ec9a4730b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,21 +41,29 @@ jobs: export CXX=clang++ python misc/ci_setup.py ci - # TODO(#1580): Upload to PyPI. Need to set up PYPI_PWD in the secrets first. - - name: Upload PyPI - env: - # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#using-encrypted-secrets-in-a-workflow - PYPI_PWD: ${{ secrets.PYPI_PWD }} + - name: Build Python Wheel run: | export TAICHI_REPO_DIR=`pwd` export PATH=$TAICHI_REPO_DIR/bin:$PATH export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH export PYTHONPATH=$TAICHI_REPO_DIR/python cd python - python build.py try_upload + python build.py build - name: Archive Wheel Artifacts uses: actions/upload-artifact@v2 with: name: taichi-${{ matrix.python }}-${{ matrix.os }}.whl path: python/dist/*.whl + + # TODO(#1580): Upload to PyPI. Need to set up PYPI_PWD in the secrets first. + - name: Fake PyPI Upload + env: + PYPI_PWD: "fakefakefake" + run: | + export TAICHI_REPO_DIR=`pwd` + export PATH=$TAICHI_REPO_DIR/bin:$PATH + export PATH=$TAICHI_REPO_DIR/taichi-llvm/bin/:$PATH + export PYTHONPATH=$TAICHI_REPO_DIR/python + cd python + python build.py try_upload --skip_build diff --git a/python/build.py b/python/build.py index 4f812da47..84220a54f 100644 --- a/python/build.py +++ b/python/build.py @@ -154,7 +154,7 @@ def main(): if mode == 'build': return elif mode == 'upload': - os.system( + print( '{} -m twine upload dist/* --verbose -u yuanming-hu -p {}'.format( get_python_executable(), '%PYPI_PWD%' if get_os_name() == 'win' else '$PYPI_PWD')) From 828559b41a6df890fd679e4afe799db077ae7e3b Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 20:47:02 +0900 Subject: [PATCH 6/8] use GITHUB_REF as part of the artifact name --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec9a4730b..5ca061574 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,8 @@ name: Publishing Release on: pull_request: types: [opened, synchronize, reopened] + release: + types: [published] jobs: build_and_test_cpu: @@ -53,7 +55,7 @@ jobs: - name: Archive Wheel Artifacts uses: actions/upload-artifact@v2 with: - name: taichi-${{ matrix.python }}-${{ matrix.os }}.whl + name: taichi-${{ env.GITHUB_REF }}-${{ matrix.python }}-${{ matrix.os }}.whl path: python/dist/*.whl # TODO(#1580): Upload to PyPI. Need to set up PYPI_PWD in the secrets first. From 9f72b7436d21b34d8bbbd5f04742d3fb95e86315 Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 22:54:05 +0900 Subject: [PATCH 7/8] github_ref doesn't work --- .github/workflows/release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ca061574..b3051d540 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,7 +55,9 @@ jobs: - name: Archive Wheel Artifacts uses: actions/upload-artifact@v2 with: - name: taichi-${{ env.GITHUB_REF }}-${{ matrix.python }}-${{ matrix.os }}.whl + # While ${{ github.ref }} does provide the release tag, it is of + # format `refs/tags/`, which isn't a valid file path. + name: taichi-py${{ matrix.python }}-${{ matrix.os }}.whl path: python/dist/*.whl # TODO(#1580): Upload to PyPI. Need to set up PYPI_PWD in the secrets first. From 2d6a05b1e2c176d607ebbc7a42a064551789d403 Mon Sep 17 00:00:00 2001 From: Ye Kuang Date: Thu, 11 Feb 2021 22:55:38 +0900 Subject: [PATCH 8/8] touch license --- python/LICENSE.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/LICENSE.txt b/python/LICENSE.txt index d12904d94..3cfa6fed8 100644 --- a/python/LICENSE.txt +++ b/python/LICENSE.txt @@ -12,6 +12,7 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE