Skip to content

Commit b46f05b

Browse files
authored
Allow specifying a branch to switch to when setting up a dev environment from the wheels (#1406)
**Context:** Switching to a different branch after setting up the dev wheel environment would break the latter. **Description of the Change:** Accept a branch to switch to as an optional argument, and switch to it before hard-linking the frontend source code files. **Benefits:** Start working directly on an existing branch. **Possible Drawbacks:** Switching to another branch using git would keep breaking the installation.
1 parent b741618 commit b46f05b

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

doc/dev/installation.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,12 @@ If you require the Catalyst repository with all its submodules, clone it this wa
481481
482482
git clone --recurse-submodules --shallow-submodules git@github.com:PennyLaneAI/catalyst.git
483483
484+
If you need to work on an existing branch, provide its name as a second argument:
485+
486+
.. code-block:: console
487+
488+
bash ./setup_dev_from_wheel.sh /path/to/virtual/env branch-name
489+
484490
How Does it Work?
485491
^^^^^^^^^^^^^^^^^
486492

@@ -495,8 +501,7 @@ using the installed Catalyst wheel libraries, hence avoiding compilation.
495501
Further Steps
496502
^^^^^^^^^^^^^
497503

498-
If everything goes well, ``git status`` should not report any changed files.
499-
504+
``git status`` should not report any changed files when a branch name is not specified.
500505
Before making changes to the frontend, make sure you create a new branch:
501506

502507
.. code-block:: console
@@ -505,6 +510,9 @@ Before making changes to the frontend, make sure you create a new branch:
505510
506511
Once in the new branch, make the wanted changes. Use the IDE of your preference.
507512

513+
When specifying a branch to switch to, ``git status`` might report changes in some files.
514+
This is normal. Proceed to make changes in the selected branch.
515+
508516
You can test the changes by executing your sample code under the same virtual environment you used
509517
with the scripts. As files in the repository are hard-linked to the Wheel code, you are actually
510518
changing the code stored at the Python ``site-packages`` folder as well, and you will be automatically

doc/releases/changelog-dev.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373

7474
The algorithm is taken from [Relaxed Peephole Optimization: A Novel Compiler Optimization for Quantum Circuits, by Ji Liu, Luciano Bello, and Huiyang Zhou](https://arxiv.org/abs/2012.07711).
7575

76+
* Allow specifying a branch to switch to when setting up a dev environment from the wheels.
77+
[(#1406)](https://github.com/PennyLaneAI/catalyst/pull/1406)
78+
7679
<h3>Breaking changes 💔</h3>
7780

7881
* The `sample` and `counts` measurement primitives now support dynamic shot values across catalyst, although at the PennyLane side, the device shots still is constrained to a static integer literal.

setup_dev_from_wheel.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# Python environment path
44
PYTHON_ENV_PATH=$1
55

6+
# Branch to switch to
7+
BRANCH=$2
8+
69
# Exit on any error
710
set -e
811

@@ -69,6 +72,11 @@ checkout_nightly_build(){
6972

7073
link_repo_to_wheel(){
7174
echo "Linking Catalyst repository to Catalyst Wheel..."
75+
76+
# switch to branch if given
77+
if [ ! -z "${BRANCH}" ]; then
78+
git switch $BRANCH
79+
fi
7280

7381
export SITEPKGS=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')
7482
export CATALYST_WHEEL=$SITEPKGS/catalyst
@@ -81,7 +89,7 @@ restore_catalyst_config(){
8189
# After linking the Wheel sources, _configuration.py will contain the entry: 'INSTALLED=True'.
8290
# Hence, we restore the file from the repository.
8391
cd $CATALYST_DIR
84-
git checkout frontend/catalyst/_configuration.py
92+
git checkout frontend/catalyst/_configuration.py frontend/catalyst/_version.py
8593
}
8694

8795
report_changed_files(){

0 commit comments

Comments
 (0)