Skip to content
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

bpo-34556: Add --upgrade-deps to venv module #13100

Merged
merged 6 commits into from
Jun 17, 2019
Merged

bpo-34556: Add --upgrade-deps to venv module #13100

merged 6 commits into from
Jun 17, 2019

Conversation

cooperlees
Copy link
Contributor

@cooperlees cooperlees commented May 5, 2019

  • This allows for pip + setuptools to be automatically upgraded to the latest version on PyPI
  • Update documentation to represent this change

bpo-34556: Add --upgrade to venv module

https://bugs.python.org/issue34556

@cooperlees cooperlees changed the title Add --upgrade-deps to venv module bpo-34556: Add --upgrade-deps to venv module May 5, 2019
Copy link
Member

@matrixise matrixise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Thank you so much for your contribution but I am going to ask you to remove the unnecessary blank lines and formatting. We have to be focused on the main modification, your new feature and not on a new line or a new space in a comment. It's useful in some cases, but not really here. just go to the essential thing but for your new code, you can format it, no problem.

I hope you will understand.

Thank you again for your contrib, I think it could be really useful with ./python -m venv --upgrade-deps

PS: I have not checked but you could add yourself into the Misc/ACKS file

@@ -250,7 +256,7 @@ def setup_python(self, context):

if sysconfig.is_python_build(True):
# copy init.tcl
for root, dirs, files in os.walk(context.python_dir):
for root, _dirs, files in os.walk(context.python_dir):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dirs is not used in the loop, this is a flake recommended way to indicate that. Will revert so I get my feature landed :)

@@ -0,0 +1 @@
Add --upgrade-deps to venv module
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the ReST markup like --upgrade-deps. Add "Patch by ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing.

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@cooperlees
Copy link
Contributor Author

No problems, thanks for the review.
I will revert the style things and apply your suggestions. I would love to come and talk to you about reformatting a lot of this module. Is there a goal that the stdlib is PEP8?

p.s. I am already in ACKs for a previous change. Thanks for asking.

@matrixise
Copy link
Member

in fact, there is no plan for the stdlib PEP8 compliant excepted for the new code, not for the former and there is a reason for that. if we migrate the stdlib to PEP8, we will have a lot of conflicts for a backport :/

for the new Python code, you can be PEP8 compliant.

Copy link
Member

@matrixise matrixise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change with the f-string. thank you

@cooperlees
Copy link
Contributor Author

Do you all need anything else from me? Would love to see this merge :)

cooperlees and others added 6 commits June 17, 2019 10:08
Sync with upstream cpython
- This allows for pip + setuptools to be automatically upgraded to the latest version on PyPI
- Update documentation to represent this change

bpo-34556: Add --upgrade to venv module
- Revert documentation fixes
- Add update_deps param to create() function
- Update NEWS file correctly
@cooperlees
Copy link
Contributor Author

Rebased my fork and force pushed the update so merge conflicts should go away.

@ambv ambv merged commit 4acdbf1 into python:master Jun 17, 2019
@bedevere-bot
Copy link

@ambv: Please replace # with GH- in the commit message next time. Thanks!

@ambv
Copy link
Contributor

ambv commented Jun 17, 2019

Thanks! ✨ 🍰 ✨

@cooperlees cooperlees deleted the venv_update branch June 17, 2019 18:35
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
Add --upgrade-deps to venv module
- This allows for pip + setuptools to be automatically upgraded to the latest version on PyPI
- Update documentation to represent this change

bpo-34556: Add --upgrade to venv module
@wimglenn
Copy link
Contributor

wimglenn commented Nov 8, 2019

It looks like this didn't land in 3.8.0. I was hoping the implementation could be improved before being released in any 3.8.x.

Personally, I'd never use python3 -m venv .venv --upgrade-deps as written because it will be significantly slower than writing my own shell alias to do python3 -m venv .venv --without-pip and then installing pip directly (say with get-pip.py or even just executing the bundled .whl file).

So, rather than install the bundled pip, and then use that pip installation to uninstall itself and install latest version of pip, wouldn't it be better just to plumb through to ensurepip directly and add ability to fetch latest from index in the first place?

Upsides:

  • cleaner
  • faster
  • less convoluted

Downsides:
?

Pinging @ncoghlan and @vsajip - thoughts?

@wimglenn
Copy link
Contributor

wimglenn commented Nov 8, 2019

FWIW, this is the kind of shell function I had in mind:

function ve() {
    if [ ! -d ./.venv ]; then
        echo "creating venv..."
        if ! python3.8 -m venv .venv --prompt=$(basename $PWD) --without-pip; then
            echo "ERROR: Problem creating venv" >&2
            return 1
        else
            .venv/bin/python /usr/local/lib/python3.8/ensurepip/_bundled/pip-19.2.3-py2.py3-none-any.whl/pip install --upgrade pip setuptools
            source .venv/bin/activate
        fi
    else
        source .venv/bin/activate
    fi
}

Obviously you don't have to hardcode the path to the whl file, you can build it off of ensurepip._bundled.__path__ if you want (for now, importlib.resources doesn't make this easy because there is no __init__.py in the _bundled subdirectory for 3.8.0)

@cooperlees
Copy link
Contributor Author

Thanks for looking into this. All for the more efficient way to avoid the double install and passing this into ensurepip is definitely the way, but I was not sure if it could handle remote fetches to PyPI if it was needed.

I admit I went the easier route that introduced less change so I had something as performance of the creation was not a high priority for me (and it's optional) and in scripts I was already effectively doing it.

DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
Add --upgrade-deps to venv module
- This allows for pip + setuptools to be automatically upgraded to the latest version on PyPI
- Update documentation to represent this change

bpo-34556: Add --upgrade to venv module
miss-islington pushed a commit that referenced this pull request Sep 5, 2020
Fixes incorrect Python version added for `venv` `--upgrade-deps` in #13100. This feature was added in Python 3.9 not 3.8.

Relates to:

- 
- 1cba1c9

Automerge-Triggered-By: @vsajip
xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
Fixes incorrect Python version added for `venv` `--upgrade-deps` in python#13100. This feature was added in Python 3.9 not 3.8.

Relates to:

- 
- python@1cba1c9

Automerge-Triggered-By: @vsajip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants