-
Notifications
You must be signed in to change notification settings - Fork 304
Add patch pypi.sh #3412
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
Open
mitchdz
wants to merge
14
commits into
NVIDIA:main
Choose a base branch
from
mitchdz:add-patch-pypi.sh
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add patch pypi.sh #3412
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4668ab
init add patch-pypi.sh
mitchdz 0688610
handle cuda-quantum-cu*
mitchdz 0def3b1
properly cd back so can transfer to wheels_new
mitchdz 505cd0e
use /tmp/ instead of mktemp
mitchdz ebee9f8
fix script
mitchdz 376683c
make it work on non-mac
mitchdz 7f466c8
add set -eu
mitchdz 48da169
set pipefail
mitchdz f3fefbc
update logs
mitchdz 62f0e2b
set to post0
mitchdz 6e961f8
Merge remote-tracking branch 'origin/main' into add-patch-pypi.sh
mitchdz 3489216
use post1
mitchdz c239db4
Merge branch 'main' into add-patch-pypi.sh
mitchdz 537fda2
Merge branch 'main' into add-patch-pypi.sh
mitchdz 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 hidden or 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,104 @@ | ||
| # copyright (c) 2025 NVIDIA Corporation & Affiliates. # | ||
| # All rights reserved. # | ||
| # # | ||
| # This source code and the accompanying materials are made available under # | ||
| # the terms of the Apache License 2.0 which accompanies this distribution. # | ||
| # ============================================================================ # | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # This script is used to patch the cudaq pypi published packages. For now, | ||
| # it is anticipated that one would use this script as a reference and update the | ||
| # MODIFY_ME{1,2,3} sections before using it. | ||
|
|
||
| # Note: you may need to run "python3 -m pip install -U wheel" first. | ||
|
|
||
| # MODIFY_ME1 - review and modify the following variables | ||
| PACKAGE_NAME=cudaq | ||
| ORIG_VER=0.12.0 | ||
| NEW_VER=0.12.0.post0 | ||
|
|
||
| # Ensure required commands are available | ||
| missing=() | ||
|
|
||
| for cmd in curl jq python3 wget; do | ||
| if ! command -v "$cmd" >/dev/null 2>&1; then | ||
| missing+=("$cmd") | ||
| fi | ||
| done | ||
|
|
||
| if [ ${#missing[@]} -ne 0 ]; then | ||
| echo "[ERROR] the following required commands are missing:" | ||
| echo " - ${missing[*]}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Make a temporary directory to work in | ||
| TMP_DIR="/tmp/cudaq-scratch" | ||
| mkdir -p ${TMP_DIR} | ||
| echo "Building TMP_DIR in $TMP_DIR" | ||
| echo "Using temporary directory: $TMP_DIR" | ||
| mkdir -p wheels_new | ||
|
|
||
| # Be sure to clean up the temporary directory on exit | ||
| trap "rm -rf $TMP_DIR" EXIT | ||
|
|
||
| ### ------------------------------------------------- ### | ||
| # Update cudaq metapackage | ||
| CUDAQ_METAPACKAGE_ORIG="wheels_orig_${PACKAGE_NAME}" | ||
| echo "Downloading the original cudaq wheels into ${CUDAQ_METAPACKAGE_ORIG}..." | ||
| mkdir -p ${CUDAQ_METAPACKAGE_ORIG} && \ | ||
| curl -fsSL "https://pypi.org/pypi/${PACKAGE_NAME}/${ORIG_VER}/json" \ | ||
| | jq -r '.urls[] | select(.packagetype=="sdist") | .url' \ | ||
| | xargs -n1 -P4 -I{} wget -c -P ${CUDAQ_METAPACKAGE_ORIG} {} | ||
|
|
||
| tar -xvzf ${CUDAQ_METAPACKAGE_ORIG}/*.tar.gz -C ${TMP_DIR} | ||
| echo ${NEW_VER} > ${TMP_DIR}/*/_version.txt | ||
| cd ${TMP_DIR}/*/ | ||
|
|
||
| # MODIFY_ME2 - review and modify the source code here | ||
| sed -i 's/elif cuda_version < 13000:/elif cuda_version <= 13000:/' setup.py | ||
|
|
||
| CUDAQ_META_WHEEL_BUILD=1 python3 -m build . --sdist | ||
| cd - | ||
|
|
||
| mv -v ${TMP_DIR}/*/dist/cudaq-*.tar.gz wheels_new | ||
|
|
||
| # upload cudaq metapackage with: | ||
| # python3 -m twine upload --repository testpypi wheels_new/*/dist/cudaq-0.12.0.post2.tar.gz --verbose | ||
|
|
||
|
|
||
| ### ------------------------------------------------- ### | ||
| # modify cuda-quantum-cu* packages | ||
|
|
||
| # cuda-quantum-cu* ships actual wheels, so we need to modify them | ||
| for package in cuda-quantum-cu12 cuda-quantum-cu11; do | ||
| PACKAGE_NAME_UNDER="${package//-/_}" | ||
| orig_dir=wheels_orig_${PACKAGE_NAME_UNDER} | ||
|
|
||
| # download wheels for this dist/version | ||
| curl -fsSL "https://pypi.org/pypi/${package}/${ORIG_VER}/json" \ | ||
| | jq -r '.urls[] | select(.packagetype=="bdist_wheel") | .url' \ | ||
| | xargs -n1 -P4 -I{} wget -c -P "$orig_dir" {} | ||
|
|
||
| for f in ${orig_dir}/*.whl; do | ||
| python3 -m wheel unpack $f -d $TMP_DIR | ||
|
|
||
| # --- Begin modifications | ||
| # Update the version | ||
| sed -i "s/^Version: ${ORIG_VER}/Version: ${NEW_VER}/" $TMP_DIR/${PACKAGE_NAME_UNDER}-${ORIG_VER}/${PACKAGE_NAME_UNDER}-${ORIG_VER}.dist-info/METADATA | ||
| # MODIFY_ME3 - review and modify the METADATA file here | ||
| # ... | ||
| # --- End modifications | ||
|
|
||
| # Re-package into a new whl file now | ||
| cd $TMP_DIR | ||
| mv ${PACKAGE_NAME_UNDER}-${ORIG_VER}/${PACKAGE_NAME_UNDER}-${ORIG_VER}.dist-info ${PACKAGE_NAME_UNDER}-${ORIG_VER}/${PACKAGE_NAME_UNDER}-${NEW_VER}.dist-info | ||
| python3 -m wheel pack ${PACKAGE_NAME_UNDER}-${ORIG_VER} -d . | ||
| cd - | ||
| mv $TMP_DIR/${PACKAGE_NAME_UNDER}-${NEW_VER}*.whl wheels_new | ||
| rm -rf $TMP_DIR | ||
| done | ||
| done | ||
|
|
||
| # python3 -m twine upload --repository testpypi wheels_new/* --verbose | ||
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.
Uh oh!
There was an error while loading. Please reload this page.