-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Questions about cherry-picker from Windows never-venv user #113
Comments
Thanks for these questions, @terryjreedy I don't have experience using venv in Windows, perhaps others can help answer these questions?
Correct. Setup lines are 1 time only. You should activate venv before using
Use example:
I guess it should be mentioned in the readme that when using eg if you do
It only creates the backport branch for 3.6. |
|
https://github.com/python/core-workflow/blob/master/cherry_picker/readme.rst still has line 7 "$ git remote... with (venv) missing. Anyway, I now know to not deactivate before entering this. I am trying, initially, to backport PR 1641 of https://bugs.python.org/issue30303 to 3.6. I called the clone 'back' instead of 'core-workflow. f:\dev>git clone https://github.com/python/core-workflow.git back f:\dev\back>py -3.6 -m venv venv f:\dev\back>venv\Scripts\activate.bat (venv) f:\dev\back>python -m pip install wheel (venv) f:\dev\back>python -m pip install --upgrade . (venv) f:\dev\back>git remote add upstream https://github.com/python/cpython.git At step 8, cherry_picker, I got an exception. (venv) f:\dev\back>cherry_picker 295304d412700cc6621bb592109fa42249a9dcdb 3.6 I have no idea why there should be a cpython here. Here is part of what there is. (venv) f:\dev\back>dir 06/08/2017 07:46 PM .. 06/08/2017 07:45 PM 1,106 .gitignore 06/08/2017 07:45 PM 166 .travis.yml 06/08/2017 07:45 PM cherry_picker 06/08/2017 07:45 PM 11,356 LICENSE 06/08/2017 07:45 PM 459 README.md 06/08/2017 07:45 PM 28 setup.cfg 06/08/2017 07:45 PM 960 setup.py 06/08/2017 07:47 PM venv 6 File(s) 14,075 bytes 4 Dir(s) 1,561,688,424,448 bytes free (venv) f:\dev\back>dir venv 06/08/2017 07:47 PM .. 06/08/2017 07:46 PM Include 06/08/2017 07:46 PM Lib 06/08/2017 07:47 PM 60 pip-selfcheck.json 06/08/2017 07:46 PM 84 pyvenv.cfg 06/08/2017 07:48 PM Scripts 2 File(s) 144 bytes 5 Dir(s) 1,561,688,424,448 bytes free (venv) f:\dev\back>dir cherry_picker 06/08/2017 07:45 PM .. 06/08/2017 07:45 PM 11,631 cherry_picker.py 06/08/2017 07:45 PM 6,739 readme.rst 06/08/2017 07:45 PM 166 requirements.txt 06/08/2017 07:45 PM 3,930 test.py 06/08/2017 07:45 PM 0 init.py 06/08/2017 07:45 PM 93 main.py 6 File(s) 22,559 bytes 2 Dir(s) 1,561,688,424,448 bytes free As near as I can tell, I followed readme. |
Sorry for all the confusion with cherry_picker.
Adding the upstream should be done in the cloned After activating the venv, Here's an asciicast showing how I set up cherry_picker and then backport a PR. Hope this helps. |
So the readme needs a patch ;-). Anyone running cherry_picker should already have an upstream remote in their local clone, so I would just remove that command and add a cd command. For ease of repetitive typing, my local clone of remote 'cpython' is '3x', not 'cpython'. |
@terryjreedy there is a line about the or I didn't understand your requirement. |
Yes, if everyone follows CPython devguide then they would have origin/upstream setup already :) However, people are still free to choose their own workflow, for example @ncoghlan uses The readme can definitely be improved, especially with instructions for Windows users. |
Yeah, for me, its 'cd ../3x', not 'cd/cpython' ;-). When I have a bit more experience, I will post here the Setup instructions that I wish I had been able to read. |
Next attempt failed. Aside from this, I realized that cherry_picker is flawed in that it is trying to work with multiple version branches in one worktree, whereas one should have separate worktrees for each version branch one works with. The code for each version must be tested with binary for that version, which should live in the worktree for that version. A backport for 3.6 should be prepared in the 3.6 worktree, etc. Upon seeing I decided to try making a PR. The result is the horribly wrong |
I edited your PR by changing the base branch from |
I followed "What this will do:" in the readme.
I then created python/cpython#2070 f:\dev\36>git status Since I already pushed to origin, I presume this is suggesting git push (to upstream), which is the last thing I should do. f:\dev\36>git status How do I get the worktree synchronized with origin without pushing to origin? |
As far as the testing question goes: one of the assumptions of That does mean there are certain cases where it won't be appropriate (e.g. those which need to regenerate some checked in files), but it's sufficient for most documentation and pure Python changes, and even most C level changes (as long as you're not modifying inputs to Argument Clinic). |
The assumption if a backport merges and CI passes, then the result is okay does not always work. For instance, bpo-30303 has two patches to idlelib's At minimum, checking out 3.6 and then master in the master (3.7) worktree touches a large number of .c files. They then get uselessly re-compiled on the next rebuild, wasting yet more of my time. In my view, checkouts in each version worktree should only be for feature branches for that version and never other version branches. |
@terryjreedy Aye, that's the point I was making - it's up to the developer doing the backport to decide if we need to test the backport locally before submitting the PR. Sometimes we're going to make mistakes (e.g. I merged a PR and backport recently that updated some Argument Clinic inputs without regenerating the affected outputs: https://bugs.python.org/issue19180#msg295524), but those mistakes then become a hint that our pre-merge CI checks could stand be improved: #118 As we iterate on those improvements, we'll eventually get to a point where our only direct involvement in backports is for us to set the label requesting the backport, and then to check the resulting PR looks sensible. |
For the "every file gets touched" problem, that sounds unusual, as I would expect the file modification dates to get set back to what they were on the original branch. If git behaves differently on Windows by default, that's useful information, and potentially a config setting folks may want to adjust if they plan to use |
So far, cherry_picker has failed for me more often than not. I mentioned the problem with --continue above. For pr 2089, the problem was that there was no merge conflict to stop the commit, to allow editing. And cherry_picker, unlike git cherrypick, lacks a no-commit option. It needs one. No-push is too late. (When I did the backport without cherry_picker, I made pr 2091, but that has its own problem. I will ask about the problem with backport 2090 on core mentorship.) |
@terryjreedy does this command line work on windows? It's used in |
Without trying it, the answer is maybe, if cherry_picker is run from Git Bash. Otherwise, |
Thanks @zware |
I'd be inclined to rewrite it using Python (which I assume we are allowed to expect to be available?) There's no guaranteed-available equivalent to sed on Windows that I know of, and while git comes with an implementation of sed, it's not guaranteed to be on out = subprocess.run(['git', 'symbolic-ref', 'HEAD'], check=True, stdout=PIPE).stdout
out = out.replace('refs/heads/', '')
print(out) |
What Zach said. Git bash requires some adjustment. It runs in a symbolic MINGW64 directory, and one has to know to turn drive letters to directory names, as in /f/dev/3x. Then shortcut keys for cut/copy/paste do not work. When I retyped your command in bash, the result was 'master' in /3x and '3.6' in /3x. So 'git checkout ' would do the right thing in each directory. I concur with Paul Moore that cherry-picker.py should be written in Python as much as possible. Having successfully done over 5 backports Saturday without venv, I wonder why bother with it. If cherry_picker were pip installed in installed 3.6 (which one must have anyway), then 'python3/py -3.6 -m cherry_picker' would be the way to run it. If cherry_picker were a package, so that the above ran Most of the backports I did were partial 3.6 backports of idlelib changes in other people's 3.7 PRs. So I learned something about how to do them and how to cleanup and what steps might be automated. Ask if you want to add no-commit and continue after edit to cherry_picker. |
The whole point of the venv suggestion is to simply avoid installing it globally. It's always optional but it can simplify things (e.g. on Linux they are cracking down on people installing globally to the system Python install and so a venv is important in that instance). |
So at this point, @terryjreedy , are you just after a comment saying that the venv is optional? |
In #123 I replaced the command line This is used to get the name of the current git branch. |
I have gotten the information I need to continue working on IDLE. Thank you. The next thing I would like is an option to request an automated backport. I know when the merge will work, and a passing test extremely likely: any backport of a idlelib code patch (there remains only one code line difference between 3.6 and 3.7). I know not to request an automated news backport (merges can be wrong even if there is no conflict). Partial backports are rare. |
@terryjreedy The dream is to get it so once a PR is merged that the backport PR is automatically done for you based on the "needs backport to *" labels on the merged PR. |
Reading the readme.rst displayed on https://github.com/python/core-workflow/tree/master/cherry_picker, I have questions and comments that I hope lead to improved instructions. I am on Windows and have never used venv.
A. The instructions are for *nix/bash and will not work as given on Windows. Has cherry-picker been successfully run on Windows?
Comments on individual setup lines:
1,2: okay.
Replace the non-existent 'python3' with 'py -3.6'. (Unlike 'python3', this is guaranteed to run 3.6 or fail.) I gather that this creates a venv directory called 'venv', which I presume is git-ignored.
Replace 'source ...' with 'venv\Scripts\activate.bat'. The venv doc says that 'activate' is not necessary but add the 'binary' directory (venv/bin or venv/Scripts) to the the path. It appears to also change the shell prompt.
This does not have the (venv) prompt. Is it just missing? Or is there a missing deactivate command? In other words, is line 7 supposed to be executed in or out of the venv. If the latter, should it not be moved up before line 3?
C. Am I correct in thinking that the setup lines (other than activate) are 1-time only, or do any have to be repeated to do further cherry-picks?
D. How does one cherry-pick multiple PRs for an issue into one backport PR? This should usually be much easier than doing multiple backports, as the backport for each dependent PR needs to wait for the previous one to be tested and merged.
The text was updated successfully, but these errors were encountered: