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

env: make pip/setuptools/wheel configurable #3920

Closed
wants to merge 6 commits into from

Conversation

abn
Copy link
Member

@abn abn commented Apr 11, 2021

This change introduces the following configuration options:

  • virtualenvs.options.no-pip (Default: false)
  • virtualenvs.options.no-wheel (Default: false)
  • virtualenvs.options.no-setuptools (Default: false)

With these options, we allow, the user to control the inclusion of
pip, wheel and setuptools packages in new virtual environments.
The defaults used retain existing behaviour as of 1.1.5.

In addition the following now holds true.

  • projects can define pip, wheel and setuptools as dependencies
  • if any of these packages are in the project's dependency tree, poetry
    will manage their versions
  • all poetry internal commands will use pip embedded in virtualenv
    irrespective of pip beig available in the environment
  • if poetry run pip is executed, pip installed in the virtualenv will
    be prioritsed
  • poetry install --remove-untracked will ignore these packages if
    they are not present in the project's and the options are not set to true dependency tree

Relates-to: #2826
Relates-to: #3916

Testing

Using pipx

pipx install --suffix=@3920 'poetry @ git+https://github.com/python-poetry/poetry.git@refs/pull/3920/head'
alias poetry=poetry@3920
poetry config virtualenvs.options.no-setuptools false
poetry lock
poetry run pip list
poetry add -D setuptools
poetry config virtualenvs.options.no-setuptools true
poetry install --remove-untracked
poetry run pip list

Using a container (podman | docker)

podman run --rm -i --entrypoint bash python:3.8 <<EOF
set -x
python -m pip install -q git+https://github.com/python-poetry/poetry.git@refs/pull/3920/head
poetry new foobar
pushd foobar
sed -i /pytest/d pyproject.toml
poetry config virtualenvs.options.no-setuptools false
poetry lock
poetry run pip list
poetry add -D setuptools
poetry config virtualenvs.options.no-setuptools true
poetry install --remove-untracked
poetry run pip list
EOF

@abn abn requested a review from a team April 11, 2021 22:12
@abn abn marked this pull request as ready for review April 12, 2021 20:54
@abn abn force-pushed the env/config-without-pip branch 2 times, most recently from 981b5ca to ce9ced2 Compare April 28, 2021 00:36
@sdispater
Copy link
Member

I am on the fence here since we are starting to leak implementation details in our own config which I don't necessarily like. The fact that we use virtual environments internally – and more precisely virtualenv – was always an implementation detail in my mind and the fact that we are exposing it is not the right direction, I think.

abn added 4 commits April 30, 2021 01:03
This change introduces the following configuration options:

- `virtualenvs.options.no-pip` (Default: `false`)
- `virtualenvs.options.no-wheel` (Default: `false`)
- `virtualenvs.options.no-setuptools` (Default: `false`)

With these options, we allow, the user to control the inclusion of
`pip`, `wheel` and `setuptools` packages in new virtual environments.
The defaults used retain existing behaviour as of `1.1.5`.

In addition the following now holds true.

- projects can define `pip`, `wheel` and `setuptools` as dependencies
- if any of these packages are in the project's dependency tree, poetry
  will manage their versions
- all poetry internal commands will use pip embedded in virtualenv
  irrespective of pip beig available in the environment
- if `poetry run pip` is executed, pip installed in the virtualenv will
  be prioritsed
- `poetry install --remove-untracked` will ignore these packages if
  they are not present in the project's dependency tree

Relates-to: python-poetry#2826
Relates-to: python-poetry#3916
Replace updates of os.environ with explicit passing of `env` to
subprocess calls in `Env.execute()`.

Relates-to: python-poetry#3199
Previously, pytest execution was influenced by poetry user
configuration. This change ensures that a new config.toml is used each
test case.
@abn
Copy link
Member Author

abn commented Apr 29, 2021

I had to chew on this one a bit myself. I would have prefered this was not required and we used empty virtual environments by default. That works well, however we hit an issue IDEs start having issues since they expect setuptools to be available at the very least. Until that assumption is broken in the ecosystem we might be stuck with having to allow config to do this.

The way I see it, we do manage virtual environments whether it is via virtualenv, venv or something else in the future. This is not somehting that we can/will get away from. The configuration is quite generic in that it is disabling default packages (pip, setuptools, wheel). While the functionality maps direct to internals, it is still a poetry functionality.

The other option is to expose this in the poetry env use command or similar. Either way, I do not think we can get away from exposing these options. Happy to hear suggestions, if you have any in mind.

@abn
Copy link
Member Author

abn commented Apr 30, 2021

Based on the conversation above we might revisit this later and instead move some of the changes into #4011. This will mean the current behavriour is not altered, however reserved packages are still allowed to be managed as a project dependency when required. If a user requires an empty virtual envrionment, they will be expected to create one themselves or remove these packages manually after creation.

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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants