Skip to content

Python: add ensurepip variant#28205

Merged
adamjstewart merged 1 commit intospack:developfrom
adamjstewart:packages/ensurepip
Jan 15, 2022
Merged

Python: add ensurepip variant#28205
adamjstewart merged 1 commit intospack:developfrom
adamjstewart:packages/ensurepip

Conversation

@adamjstewart
Copy link
Copy Markdown
Member

Many users are surprised that spack install python does not install pip (#2065). Some packages actually require a version of Python built with --ensurepip (pypa/build#266). This PR adds an +ensurepip variant to the Python package.

I think the only thing we should think about is whether to default to +ensurepip or ~ensurepip. I'm also a bit concerned with how this will interact with #27798. We may need to make the dependency on py-pip in PythonPackage conditional on the Python variant.

Note that the ensurepip module is available in Python even if --without-ensurepip is used. The module seems to work fine, but when you create a venv it doesn't contain pip. This causes tools like build to fail.

Closes #2065

Copy link
Copy Markdown
Contributor

@cosmicexplorer cosmicexplorer left a comment

Choose a reason for hiding this comment

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

I think the only thing we should think about is whether to default to +ensurepip or ~ensurepip.

Regarding whether users expect pip to be made available: on Alpine and Ubuntu I both have to ensure I apk add python3{,-pip} or apt install python3{,-pip} in order to get pip installed, so while I think it's a great thing to expose ensurepip in spack, I think it makes some sense to not have it on by default? Unclear if I'm missing something.

I'm also a bit concerned with how this will interact with #27798. We may need to make the dependency on py-pip in PythonPackage conditional on the Python variant.

Will try to review that one asap to get more context on this then!

variant('virtualenv', default=False, description='Install optional virtualenv dependency')

depends_on('[email protected]:', type=('build', 'run'))
depends_on('[email protected]:+ensurepip', type=('build', 'run'))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How would we add a test case for this functionality? I could add it in a followup if it's too tedious here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You could create a fake package following the instructions at https://packaging.python.org/en/latest/tutorials/packaging-projects/ and try to build it. I think it would need at least one dependency? It would also need internet access.

@alalazo
Copy link
Copy Markdown
Member

alalazo commented Jan 12, 2022

We may need to make the dependency on py-pip in PythonPackage conditional on the Python variant.

This or we can have a pip virtual that is provided by both python+ensure-pip and py-pip. Not sure which paradigm would be better.

@adamjstewart adamjstewart merged commit a2181e9 into spack:develop Jan 15, 2022
@adamjstewart adamjstewart deleted the packages/ensurepip branch January 15, 2022 02:09
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Feb 1, 2022
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Feb 1, 2022
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Feb 8, 2022
EthanS94 pushed a commit to EthanS94/spack that referenced this pull request Feb 17, 2022
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3 does not install pip

3 participants