-
Notifications
You must be signed in to change notification settings - Fork 316
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
Publish precompiled wheels in Github release and add wheel index #365
Merged
liruilong940607
merged 175 commits into
nerfstudio-project:main
from
martinResearch:publish_precompiled_wheels
Sep 27, 2024
Merged
Changes from 162 commits
Commits
Show all changes
175 commits
Select commit
Hold shift + click to select a range
3d133ad
publish precompiled wheels
2258d4c
Update publish.yml
512d1b9
Update publish.yml
1539715
Update publish.yml
4ad0798
Update publish.yml
2007c3d
Update publish.yml
37c2541
Update publish.yml
f850459
Update publish.yml
046146e
Update publish.yml
91a66e2
Update publish.yml
f3dcd9e
Update publish.yml
a2cb89c
Update publish.yml
a7ae2cf
Update publish.yml
265a78e
Update publish.yml
c7a2b4b
Update publish.yml
8d42820
Update publish.yml
4f97fbd
Update publish.yml
236af2c
Update publish.yml
7ff4ea3
test on linux
041556f
Update building.yml
5c537b1
Update publish.yml
1ffe180
try to fix
ba76541
trying TORCH_CUDA_ARCH_LIST=7.5
444fc93
try to fix
d8d91a7
try fixing
a3db8b6
move export TORCH_CUDA_ARCH_LIST=8.2
d186c49
try fix
09c03cd
using export TORCH_CUDA_ARCH_LIST="8.0;8.6"
db71225
Update publish.yml
e3b8b81
using TORCH_CUDA_ARCH_LIST="8.0"
2a01f4d
TORCH_CUDA_ARCH_LIST="7.5"
ea3b1a1
Update publish.yml
72e7721
Update publish.yml
c5c2207
Update publish.yml
6fdd5e3
Update publish.yml
5dff781
Update publish.yml
f60c27f
Update publish.yml
db3753f
Update publish.yml
1d5af27
TORCH_CUDA_ARCH_LIST="6.2;7.2;7.5;8.7;8.9;9.0"
d416742
Update publish.yml
ee68bd1
Update publish.yml
03edc1e
Update building.yml
651c37b
TORCH_CUDA_ARCH_LIST="6.2"
755ade3
export TORCH_CUDA_ARCH_LIST="7.2;7.5"
e589d03
Update publish.yml
b4d5d31
Update publish.yml
8813791
Update building.yml
3281c6b
Update publish.yml
393980f
Update publish.yml
c8d992e
Update building.yml
4654fa8
Update publish.yml
af36e58
Update publish.yml
martinResearch b096bde
Update publish.yml
martinResearch e1f1cc5
Update publish.yml
martinResearch b2b38af
Update publish.yml
martinResearch ba1b9a0
trying to set TORCH_CUDA_ARCH_LIST in the setup.py file
e6fe7d0
Update setup.py
fec8707
test
5298a45
simplify
2c00ff7
use ORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;9.0" with cu118
ae0157b
trying wheel build with cuda 11.7
36e4c84
trying TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;9.0" with cuda 11.7
9974cd0
trying export TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;9.0" with cuda 11.6
7acfe00
trying export TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;9.0" with cuda 11.5
db65519
trying export TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;9.0" with cuda 11.3
f98defd
test TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6" with cuda 11.3
2289c5e
testing TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6" with cuda 11.5
882d84b
testing TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6" with cuda 11.6
4fd13af
testing TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6" with cuda 11.3
59e2862
testing TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6" with cuda 11.7
269ee37
trying python 3.9 and 3.11
martinResearch fc9687d
Update publish.yml
martinResearch 8734b4e
Update publish.yml
martinResearch 42b9f52
trying python 3.8
martinResearch 15c7870
trying python 3.7
martinResearch f10c66a
fix python3.7
martinResearch 59a8d47
test python 3.11
martinResearch a57ea6c
Update publish.yml
martinResearch 96bc5f9
Update publish.yml
martinResearch f7c39dd
testing python 3.7
martinResearch d6ad825
Update publish.yml
martinResearch 0da97ca
Update publish.yml
martinResearch 3964115
Update publish.yml
martinResearch ddd6417
Update publish.yml
martinResearch e87843e
test cu113
martinResearch 22faed6
test cu115
martinResearch b5a2d91
test cu116
martinResearch c1bb170
test cu117
martinResearch 507f25e
test cu118
martinResearch 8801c5d
Update publish.yml
martinResearch 7ea832f
Update publish.yml
martinResearch ce866d1
Update publish.yml
martinResearch d91af09
Update publish.yml
martinResearch bfa13ce
create 2 pipelines
15dc711
change pipeline names
e761101
Update publish_source_and_no_cuda_wheel.yml
0dd71b6
Update publish_precompiled_wheels.yml
6550b3e
Update publish_source_and_no_cuda_wheel.yml
8767eac
trying to upload in github release
a41f885
Update publish_precompiled_wheels.yml
f971f68
Update publish_precompiled_wheels.yml
0144a33
Update publish_precompiled_wheels.yml
7606924
Update publish_precompiled_wheels.yml
d8363f8
test BUILD_NO_CUDA=1
3f56477
test BUILD_NO_CUDA=1
f2d4f2c
Update publish_precompiled_wheels.yml
e90e3ff
Update publish_precompiled_wheels.yml
6c6b017
Update publish_precompiled_wheels.yml
82b4a55
Update publish_precompiled_wheels.yml
5b19930
trying to uploade the wheels to release
da9540e
Update publish_precompiled_wheels.yml
624ff43
Update publish_precompiled_wheels.yml
99830d8
Update publish_precompiled_wheels.yml
db93c4b
Update publish_precompiled_wheels.yml
eaa9b5c
Update publish_precompiled_wheels.yml
744a6bb
Update publish_precompiled_wheels.yml
3effb48
Update publish_precompiled_wheels.yml
6b6f367
back to single file
fbecdb5
Update publish.yml
3c39fa6
Update publish.yml
c9f87cf
Create wheels_index.html
dcd3204
Update wheels_index.html
67d5b97
deal with +
dcb1c0a
Update publish.yml
d798e40
Update publish.yml
ee6a0e6
Update publish.yml
d08da8b
adding links to packages
b6ef983
document installation using a precompiled wheel
31eebcb
Update packages.html
c1bbced
Create wheels_index.html
a20ba9e
Update wheels_index.html
508f558
trying using %2B in urls
a5dd753
moving index
3d9196e
trying to make it work with index url
c8be58c
Merge branch 'nerfstudio-project:main' into publish_precompiled_wheels
martinResearch 1e09ff8
add ptXcuX subpages
4a691ed
Merge branch 'publish_precompiled_wheels' of https://github.com/marti…
57e94ee
Update INSTALL_WIN.md
3a13a96
Merge branch 'main' into publish_precompiled_wheels
dbc13ce
trying to reuse the build workflow
ec694a9
try publish on manual release
58ba0ad
Update publish.yml
e425ab6
Update publish.yml
331bcea
trying reusable workflow
eb1dc61
trying to make it work
1020c7b
try reusable workflow
1e9ef3f
Update publish.yml
836367f
Update publish.yml
6bcc4c5
testing with few wheels
18031ab
Update building.yml
101fb32
Update building.yml
1ce0231
Update building.yml
8cee0a8
Update publish.yml
bf5d79d
Update building.yml
27ab7be
Merge branch 'main' into publish_precompiled_wheels
5117c84
add script and github steps to generate the simple index pages
d8d03f0
remove the html pages from the PR
6723f91
Merge remote-tracking branch 'original/main' into publish_precompiled…
53e2539
remove wheels for python 3.8 and 3.9 from the releases
78b097d
ruff format
9a80923
Update publish.yml
df7de2e
fixing typos
e2bcff4
Update generate_simple_index_pages.py
martinResearch 9446369
wheels -> whl
09e0454
test
4817516
test
819605a
fix
8469c0b
some updates
5e4e883
fix
1c72ddb
ninja-build
bc2950c
revert
62076f9
fix
fce307e
artifact v3
f5eabf9
all version with python3.10
f55f2e3
wheels -> whl
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import requests | ||
import os | ||
import argparse | ||
from jinja2 import Template | ||
import re | ||
|
||
# Automatically get the repository name in the format "owner/repo" from the GitHub workflow environment | ||
GITHUB_REPO = os.getenv("GITHUB_REPOSITORY") | ||
|
||
|
||
def list_python_wheels(): | ||
# GitHub API URL for releases | ||
releases_url = f"https://api.github.com/repos/{GITHUB_REPO}/releases" | ||
|
||
response = requests.get(releases_url) | ||
|
||
if response.status_code != 200: | ||
raise Exception( | ||
f"Failed to fetch releases: {response.status_code} {response.text}" | ||
) | ||
|
||
releases = response.json() | ||
|
||
wheel_files = [] | ||
|
||
# Iterate through releases and assets | ||
for release in releases: | ||
assets = release.get("assets", []) | ||
for asset in assets: | ||
filename = asset["name"] | ||
if filename.endswith(".whl"): | ||
pattern = r"^(?P<name>[\w\d_.]+)-(?P<version>[\d.]+)(?P<local>\+[\w\d.]+)?-(?P<python_tag>[\w]+)-(?P<abi_tag>[\w]+)-(?P<platform_tag>[\w]+)\.whl" | ||
|
||
match = re.match(pattern, filename) | ||
|
||
if match: | ||
local_version = match.group("local") | ||
if local_version: | ||
local_version = local_version.lstrip( | ||
"+" | ||
) # Return the local version without the '+' sign | ||
else: | ||
local_version = None | ||
else: | ||
raise ValueError(f"Invalid wheel filename: {filename}") | ||
wheel_files.append( | ||
{ | ||
"release_name": release["name"], | ||
"wheel_name": asset["name"], | ||
"download_url": asset["browser_download_url"], | ||
"package_name": match.group("name"), | ||
"local_version": local_version, | ||
} | ||
) | ||
|
||
return wheel_files | ||
|
||
|
||
def generate_simple_index_htmls(wheels, outdir): | ||
# Jinja2 template as a string | ||
template_versions_str = """ | ||
<!DOCTYPE html> | ||
<html> | ||
<head><title>Python wheels links for {{ repo_name }}</title></head> | ||
<body> | ||
<h1>Python wheels for {{ repo_name }}</h1> | ||
|
||
{% for wheel in wheels %} | ||
<a href="{{ wheel.download_url }}">{{ wheel.wheel_name }}</a><br/> | ||
{% endfor %} | ||
|
||
</body> | ||
</html> | ||
""" | ||
|
||
template_packages_str = """ | ||
<html> | ||
<body> | ||
{% for package_name in package_names %} | ||
<a href="{{package_name}}/">{{package_name}}</a><br/> | ||
{% endfor %} | ||
</body> | ||
</html> | ||
""" | ||
|
||
# Create a Jinja2 Template object from the string | ||
template_versions = Template(template_versions_str) | ||
template_packages = Template(template_packages_str) | ||
|
||
# group the wheels by package name | ||
packages = {} | ||
for wheel in wheels: | ||
package_name = wheel["package_name"] | ||
if package_name not in packages: | ||
packages[package_name] = [] | ||
packages[package_name].append(wheel) | ||
|
||
# Render the HTML the list the package names | ||
html_content = template_packages.render( | ||
package_names=[str(k) for k in packages.keys()] | ||
) | ||
os.makedirs(outdir, exist_ok=True) | ||
with open(os.path.join(outdir, "index.html"), "w") as file: | ||
file.write(html_content) | ||
|
||
# for each package, render the HTML to list the wheels | ||
for package_name, wheels in packages.items(): | ||
html_page = template_versions.render(repo_name=GITHUB_REPO, wheels=wheels) | ||
os.makedirs(os.path.join(outdir, package_name), exist_ok=True) | ||
with open(os.path.join(outdir, package_name, "index.html"), "w") as file: | ||
file.write(html_page) | ||
|
||
|
||
def generate_all_pages(): | ||
wheels = list_python_wheels() | ||
if wheels: | ||
print("Python Wheels found in releases:") | ||
for wheel in wheels: | ||
print( | ||
f"Release: {wheel['release_name']}, Wheel: {wheel['wheel_name']}, URL: {wheel['download_url']}" | ||
) | ||
else: | ||
print("No Python wheels found in the releases.") | ||
|
||
# Generate Simple Index HTML pages the wheel with all local versions | ||
generate_simple_index_htmls(wheels, outdir=args.outdir) | ||
|
||
# group wheels per local version | ||
wheels_per_local_version = {} | ||
for wheel in wheels: | ||
local_version = wheel["local_version"] | ||
if local_version not in wheels_per_local_version: | ||
wheels_per_local_version[local_version] = [] | ||
wheels_per_local_version[local_version].append(wheel) | ||
|
||
# create a subdirectory for each local version | ||
for local_version, wheels in wheels_per_local_version.items(): | ||
os.makedirs(os.path.join(args.outdir, local_version), exist_ok=True) | ||
generate_simple_index_htmls( | ||
wheels, outdir=os.path.join(args.outdir, local_version) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
argparser = argparse.ArgumentParser( | ||
description="Generate Python Wheels Index Pages" | ||
) | ||
argparser.add_argument( | ||
"--outdir", help="Output directory for the index pages", default="." | ||
) | ||
args = argparser.parse_args() | ||
generate_all_pages() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflows will upload a Python Package using twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Update wheels index pages | ||
|
||
# trigger manually on github interface | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: [generate_wheels_simple_index_pages] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install requests jinja2 | ||
# call the script to generate the simple index pages | ||
- name: Generate Simple Index Pages | ||
run: python .github/workflows/generate_simple_index_pages.py --outdir ./whl | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
|
||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./whl # Directory where the simple index pages are located | ||
destination_dir: whl # The 'wh' folder in the GitHub Pages root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,94 @@ | ||
# This workflows will upload a Python Package using twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Upload Python Package | ||
name: Build and Release Wheels | ||
|
||
on: | ||
release: | ||
types: [created] | ||
branches: [main] | ||
|
||
jobs: | ||
deploy: | ||
|
||
# Build the wheels using reusable_building.yml | ||
build_wheels: | ||
name: Call reusable building workflow | ||
uses: ./.github/workflows/building.yml | ||
|
||
create_release_and_upload_packages: | ||
name: Uplodad to Github Release | ||
needs: [build_wheels] | ||
runs-on: ubuntu-latest | ||
environment: production | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['3.10', '3.11', '3.12'] | ||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download packages | ||
id: download_artifacts | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: compiled_wheels_python${{ matrix.python-version }} | ||
path: dist | ||
|
||
- name: Upload packages to GitHub Release | ||
id: upload_assets | ||
run: | | ||
for file in $(ls ./dist/*.*); do | ||
echo "Uploading $file..." | ||
filename=$(basename "$file") | ||
encoded_filename=$(echo "$filename" | sed 's/+/%2B/g') | ||
curl -X POST \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Content-Type: application/zip" \ | ||
--data-binary @"$file" \ | ||
"${{ github.event.release.upload_url }}=$encoded_filename" | ||
done | ||
|
||
generate_simple_index_pages: | ||
name: Generate Simple Index Pages | ||
needs: [create_release_and_upload_packages] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: 'recursive' | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.7' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install build twine | ||
- name: Strip unsupported tags in README | ||
run: | | ||
sed -i '/<!-- pypi-strip -->/,/<!-- \/pypi-strip -->/d' README.md | ||
- name: Build and publish | ||
env: | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
- name: Generate Simple Index Pages | ||
run: python .github/workflows/generate_simple_index_pages.py --outdir ./wheels | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./wheels # Directory where the simple index pages are located | ||
destination_dir: wheels # The 'wh' folder in the GitHub Pages root | ||
|
||
upload_pypi: | ||
name: Upload to PyPi | ||
needs: [build_wheels] | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: pypi_packages | ||
path: dist | ||
|
||
- name: Publish package to Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository-url: https://test.pypi.org/legacy/ | ||
liruilong940607 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Publish package to PyPI | ||
env: | ||
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | ||
run: | | ||
twine upload --username __token__ --password $PYPI_TOKEN dist/* | ||
|
||
- name: Install dependencies | ||
run: | | ||
BUILD_NO_CUDA=1 python -m build | ||
twine upload --username __token__ --password $PYPI_TOKEN dist/* | ||
python -m pip install requests jinja2 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if local_version is not and and local_version not in wheels_per_local_version: