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

Upgrade pip/setuptools in venv to versions from base environment #740

Closed
wants to merge 4 commits into from

Conversation

asodeur
Copy link
Contributor

@asodeur asodeur commented Dec 14, 2018

Pull Request Check List

Pedestrian fix for #732.

This PR upgrades pip/setuptools to the versions found in the base environment during venv creation. Hence, if pip/setuptools versions in your base environment can install a package, poetry can install it into the created virtual environment.

No attempt is made to resolve any build requirements declared in either setup.py/setup_requires or pyproject.toml/[build-system].

  • Added tests for changed code.

@asodeur asodeur force-pushed the upgrade_pip_in_venv branch from 548fc81 to 3a67b0f Compare January 17, 2019 15:50
@Congee
Copy link

Congee commented Feb 8, 2019

Any reason it's not merged? @sdispater

@asodeur asodeur force-pushed the upgrade_pip_in_venv branch from 3a67b0f to 1900033 Compare February 11, 2019 13:24
@zyv
Copy link
Contributor

zyv commented May 17, 2019

We are having this problem right now, and are not sure what we can do at least as a stopgap fix. For some weird reason Poetry decided that from now on, it installs everything with pip==19.0.3, which doesn't work, whereas latest is 19.1.1 and the last known working is 18.1. We have pinned our system images to 19.1.1, but Poetry ignores that ATM.

@mm-matthias

@stevegore
Copy link

Also having this issue. Can this please be merged? @sdispater ?

@username-dot-com
Copy link

I could also use this fix. Is there any issue causing this to not be merged @sdispater ?

@stevegore
Copy link

stevegore commented Jun 6, 2019

Current helper script to resolve virtualenv issues:

#!/bin/bash

echo "--- Checking appropriate prerequisites are installed."

# Check correct version of Python
python -V | grep 3.
if [ $? -ne 0 ]
then
    echo "Please ensure you have Python 3.6 activated. Pyenv is recommended."
    exit 1
fi

# Check Poetry installed
poetry --version | grep 0.12
if [ $? -ne 0 ]
then
    echo "--- Poetry not detected, installing..."
    curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
fi

# Do dry run to create virtual environment
echo "--- Using Poetry to create virtual environment"
poetry install --dry-run -q

# Activate created virtual environment
echo "--- Activating virtual environment"
VIRTUAL_ENV=$(poetry run python  -c "import os; print(os.environ['VIRTUAL_ENV'])")
echo "Virtual environment path is $VIRTUAL_ENV"
source $VIRTUAL_ENV/bin/activate
if [ $? -ne 0 ]
then
    echo "Could not activate the virtual environment!"
    exit 2
fi

echo "--- Updating pip and setuptools"
pip install -q --upgrade pip setuptools
deactivate

# Do the final install
echo "--- Installing dependencies"
poetry install

Edit: since realised you can fix this just by running poetry run pip install -q --upgrade pip setuptools

@brycedrennan brycedrennan added the kind/bug Something isn't working as expected label Aug 17, 2019
Copy link
Contributor

@brycedrennan brycedrennan left a comment

Choose a reason for hiding this comment

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

@asodeur Thanks for contributing to poetry! Sorry for the delay in reviewing this.

Could you rebase this into one commit? I'll look at this soon.

# Requirements
[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
[tool.poetry]
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats changing in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There should not be any changes, looks like somehow Windows line endings slipped in. I'll revert this.

"python", "-m", "pip", "install", "--upgrade", "pip=={}".format(pip_version)
)
the_venv.run(
"python",
Copy link
Contributor

@brycedrennan brycedrennan Aug 21, 2019

Choose a reason for hiding this comment

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

This would mean that the creation of new environments would require internet access. I think we need to either

  • solve this in the ensurepip library in a way that works without internet or
  • have this be hidden behind a command line flag /setting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'll check what can be done. Since we are trying to update to the version available in the base environment there should be some way to get along w/o internet connection.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that it seems like there should be a way but the discussion on the python bug tracker seems to think its trickier than it sounds. I hope you find a way though! I wonder if you should be making a pull request into ensurepip instead though.

https://bugs.python.org/issue30628

@brycedrennan brycedrennan added the area/venv Related to virtualenv management label Sep 2, 2019
@stale
Copy link

stale bot commented Nov 13, 2019

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 13, 2019
@stevegore
Copy link

I believe this is still an issue for some dependencies. I have the use the following in my builds:

            if grep -q -E "(googleapis-common-protos|tensorboard|tensorflow)" poetry.lock
            then
              poetry run pip install -q --upgrade pip setuptools
            fi

Tensorflow, for example, has minimum pip requirements: https://www.tensorflow.org/install/pip

Understand however if this is beyond the scope of what poetry is attempting to resolve.

@sdispater sdispater added stale and removed wontfix labels Nov 14, 2019
@stale stale bot removed the stale label Nov 14, 2019
@finswimmer finswimmer added the kind/feature Feature requests/implementations label Feb 10, 2020
@finswimmer
Copy link
Member

In the meantime poetry has switched to virtualvenv for creating the venv's. This will make sure to get the latest pip.

Thanks a lot for your contribution anyway 👍

fin swimmer

@finswimmer finswimmer closed this Sep 28, 2020
@abn
Copy link
Member

abn commented Sep 28, 2020

Closed by #2666

Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/venv Related to virtualenv management kind/bug Something isn't working as expected kind/feature Feature requests/implementations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants