pipenv: Cannot install from a local wheel

I have a project where I want to install a package (cassiopeia) that depends on pycurl. I’m on Windows, and pycurl currently does not provide a binary wheel for Python 3.6, nor does it build without a prebuilt libcurl being available. I can however get a wheel from Christoph Gohlke’s website.

I’d like to hold the pycurl wheel in my project directory, under wheels/pycurl*.whl. I could then supply --find-links to pip and install pycurl from there.

Specifying an environment variable PIP_FIND_LINKS sort of works, but I can’t find any way to record the fact that I want to include the wheels directory in the search path permanently, so that I don’t have to (remember to) set an environment variable every time I rebuild the environmnent.

I found https://github.com/pypa/pipfile which gives examples of more complex ways of specifying things in a pipfile, but I can’t make this work.

Describe you environment
  1. Windows
  2. Python version: python 3.6.2
  3. Pipenv version: pipenv, version 8.2.6
Expected result

To be able to configure “find-links = ./wheels” somewhere, probably in the Pipenv file, and have it pick up wheels from that location. (I’d expect to be able to use a relative path, to mean “relative to the project directory”, or an absolute path for wheels I store globally).

Actual result

I need to manually set PIP_FIND_LINKS before installing via pipenv, and then unset it afterwards, so that it doesn’t affect other invocations of pip.

Steps to replicate

pipenv install. Pipfile is

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
cassiopeia = "*"
pycurl = {file = "./wheels/pycurl-7.43.0-cp36-cp36m-win_amd64.whl"}

[dev-packages]

Output is:

>pipenv install
Creating a virtualenv for this project…
Using real prefix 'C:\\Users\\pfmoore\\AppData\\Local\\Programs\\Python\\Python36'
New python executable in C:\Users\pfmoore\.virtualenvs\riot_data-4b7hkvZN\Scripts\python.exe
Installing setuptools, pip, wheel...done.

Virtualenv location: C:\Users\pfmoore\.virtualenvs\riot_data-4b7hkvZN
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (17f190)!
Installing dependencies from Pipfile.lock (17f190)…
An error occurred while installing pycurl==7.43.0! Will try again.
  ================================ 8/8 - 00:00:17
Installing initially–failed dependencies…
Collecting pycurl==7.43.0 ----------- 0/1 - 00:00:00

THESE PACKAGES DO NOT MATCH THE HASHES FROM Pipfile.lock!. If you have updated the package versions, please update the hashes. Othe
rwise, examine the package contents carefully; someone may have tampered with them.
    pycurl==7.43.0 from file:///C:/Work/Projects/riot_data/wheels/pycurl-7.43.0-cp36-cp36m-win_amd64.whl (from -r C:\Users\pfmoore\AppData\Local\Temp\pipenv-y27xl4s1-requirement.txt (line 1)):
        Expected sha256 de2980f2839029ffa2917fcc1eb84b2dc736f0a30a5413645e514a2b61df04ed
        Expected     or d6cb0917ce564c9edc377ae436bc0963ee72be8873c90bcce7470f1670c3baef
        Expected     or 1ba222eafcb740805d5c9fe778a47d2704bf764abe9a2546de90f159e4c3a116
        Expected     or f614c93422f31761764a002297b56a0c7f0aeaee7badb0fb43764bda13467697
        Expected     or b0af8badfda56b175e190cf0fb1a18d2bd600a677d3b5d9f7a579823eec74fa4
        Expected     or 9db493308f092b87d8113cea322886f07c2f1b64f9839dffd4a65c300f91244b
        Expected     or 26dcfb05ecbaa27ffaa71a4a3add217ec9e1cee2998b727e1b9e6eff7264d5f8
        Expected     or 413b82b25795dcd0656e2d254892a16f531d88eccabc3a97c9c9451781caf5e8
        Expected     or 89758f2375fe44b139fcc11e305a060c75a4a89178b5066a3894055fe069a80e
        Expected     or 991d221a59c5546370e618241ec05e7d85efd7c5126fb33387de0a12c2cfe8e4
        Expected     or 39a7399e7da031f4648bd6ea273b02c0cf203471b63fe3629d19ebfd13e5701f
        Expected     or 9997e9994860cc99f2622de4133e0dd1756797852645dc6942b58142014f2e59
        Expected     or aa975c19b79b6aa6c0518c0cc2ae33528900478f0b500531dbcdbf05beec584c
        Expected     or 7d1ffc138132a7dcb322d41b1f7d5ed7e2f9bb0dea3103ae5ca25fae2a1f689b
        Expected     or 074a565bc33cfc484fa87339136876f1d8176bd30bb214235e11382b363beef9
        Expected     or d6ac0f902cb82cab13bc9488fb5240cf86325bd24800dc5ab677f8044993f6fc
        Expected     or 61d4b1a2dc1ecdb3b6d4188d63ab884e8768cfc85f37f48c481935b784920137
        Expected     or 1339972f6faf9e7feb54e0d62b018dcea6c99fb5ca46fef4a8d20c2a810d1f2d
        Expected     or 30983ec2f88ee0d26d290f276563c26bc1d302f1f6fc447092368bce7a93f0ea
        Expected     or 9075d35c8bafb96a836a7558b37fe697ec04646f76239254b06e87eb360097c7
        Expected     or 36c3a2d6b4ca31f39ac84fe9b7616d338191f956710c7912c546ffef18600f2f
        Expected     or 024fba378134633694b7a64ec7cb8ef9a98e3ce6b5635247b51b7282b96f33de
        Expected     or 826866c43ef532b7633e24332b7f4bc6b309e72b33631c2b06258fdb284dd55b
        Expected     or 59f637ffe21a90b6155df34b9fdf3030b6453859110db8700bf17f569c6449d6
        Expected     or 614687bdc73246ce85f73b7199d533a222efdda954e84a6bd692fef25fa3b6ac
             Got        7b9443007238914a6cc7fb6c3442aa00f06868b141837097f249adf54add11b6


     ================================ 0/1 - 00:00:01

>pipenv run pip list
Package       Version
------------- -------
cassiopeia    3.0.13
datapipelines 1.0.2
decorator     4.1.2
merakicommons 1.0.2
networkx      2.0
olefile       0.44
Pillow        4.3.0
pip           9.0.1
setuptools    36.6.0
wheel         0.30.0

Note that pycurl is missing from the output of pip list.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 39 (36 by maintainers)

Commits related to this issue

Most upvoted comments

Hmm, I’m not sure it’s that niche. Needing to use prebuilt wheels is fairly common on Windows, and Christoph Gohlke maintains an extensive and well-known archive of such wheels, particularly for the scientific stack (although it is true that more and more projects now host wheels on PyPI). So while I’m OK with the idea that it’s an enhancement, I think it’s a fairly important use case.

Also, even if it’s not supported directly by pipenv yet, documentation on ways of working round the limitation would be useful (I assume that hosting the wheel in a local index like devpi would work, for example).

@erinxocon No problem. I completely understand.

My main question isn’t so much whether things work well/badly, or even if there’s a bug. My real question is whether this scenario is currently supported or not. If it’s not supported, that’s fine - I can raise a new feature request explaining my requirement and asking if it could be supported. If it is supported, then the docs don’t explain it very well. If someone can clarify how to set things up, I’m happy to try to write a doc PR to improve things. (There may also be bugs in the implementation, if it’s not a well-used feature - I’m happy to be a guinea pig in that case, and report any problems I hit).

My impression is that actually, this simply isn’t something anyone has thought through, so it might work, but more as a side-effect of how other features work than as a fully fleshed out use case. If that’s true, I’d be inclined to just treat it as a feature request, rather than struggle to try to make the existing features handle an unexpected corner case.

Actually, #909 doesn’t seem that related. What I’m specifically looking for is a way to specify that a directory within the project holds artifacts (probably wheels, but potentially sdists as well) that should be considered as a source. Something like

[[source]]
bundled_artifacts = "relative_path_within_repo"
name = "bundled"

which could then be referenced like any other source.

By limiting it to relative paths within the project, it avoids the possibility of depending on context that’s only available on the local system.

See the discussion on https://github.com/pypa/python-packaging-user-guide/issues/373 for more context.

Hmm. That seems to be about local files on the command line (pipenv install foo) where I can see that there’s a need to address the confusion between a package name and a local directory. My issue here is about manually editing Pipfile to explicitly state my intention.

To be frank, I think I’ve got a badly skewed mental model of how pipenv works, and that means I can’t see the connection you’re suggesting. My main priority should likely be to understand the correct approach to using pipenv before I try to work on solutions. But I’m not quite sure how to do that.

The way I got to where I now am is as follows - the docs start by showing how to use pipenv install foo in a new project directory to start setting up the working environment for your project. From there, “Basic Usage” shows what Pipfile looks like, but it still mostly talks in terms of a model where I use pipenv install to add packages, and don’t manually edit Pipfile.

My use case (where installing from PyPI fails due to a lack of a binary wheel) clearly dumps me into “Advanced Usage” territory. Here, “Specifying Package Indexes” sounds like exactly what I’d want, but it’s only for PyPI style URLs, not for local directories of packages. That’s where my suggestion of adding syntax to [[source]] came from.

There’s nothing else in the pipenv docs that looked relevant to me, but the example in https://github.com/pypa/pipfile includes a “file=” option for a package, but that uses a URL, not a path (and file: URLs are basically hopeless to use for relative files, or absolute Windows paths).

That’s the point I came here.

  1. The pipenv documentation implies I should be writing a [[source]] section, but doesn’t tell me how to do that for a local directory (it implies it’s more like --index-url than --find-links in pip terms).
  2. The pipfile documentation provides file= but it implies that only URLs are supported, and it doesn’t support having a set of wheels in a directory, with the correct one chosen based on compatibility with the platform.

The discussion here leads me to think that (1) is an enhancement request. And (2) in principle works but has bugs (and has the limitations I note above). But #939 doesn’t seem to relate to Pipfile syntax at all, but rather to command line usage, and I’m reluctant to add my confusion to that issue as well as to this one…

For my current project, I’ve (at least for now) abandoned pipenv, and reverted to pew plus a requirements file. I’m happy to help get pipenv to a point where it handles what I’m doing, but I’m struggling to understand how I can contribute usefully. Maybe I’m better, now that I’ve explained my use case, to step back and leave the experts here to consider it.

Sorry, I’m confused. As I understand it, it’s not possible to have file URLs for relative paths (and if it is, the rules for constructing them in a cross-platform manner seem obscure at best).

Can you explain the syntax I’d use to say “the file pycurl-7.43.0-cp36-cp36m-win_amd64.whl stored in the wheels directory that exists alongside the Pipfile file”?

I’m confused as to what’s being said here. Is this an existing, supported, capability in pipenv? @erinxocon seemed to be saying in https://github.com/kennethreitz/pipenv/issues/914#issuecomment-337439874 that it was a future enhancement…?

Don’t put anything in either file manually. pipenv install ./file.whl

@ncoghlan to clarify, I’m completely for relative paths to packages in the project. I stated that in other comments this evening, sorry it didn’t make it into this one.

What we have previously been against is allowing people to specify arbitrary paths to, for example, something the have in their downloads folder or desktop. These are the kinds of things I’d prefer we avoid and I think historically we have.

@nateprewitt “But reproducibility…” was my initial reaction as well, but then @pfmoore pointed out that the idea behind using a relative path is that it means you can easily bundle the relevant wheel files with the affected source project, similar to the way CPython handles bundling pip and setuptools for the sake of ensurepip.

That then actually ends up improving environmental reproducibility, since you get the otherwise-tricky-to-obtain dependencies right along with the source code.

The file specification requires real file URIs. Pipfiles ca man use path instead for relative locations

On Oct 19, 2017, at 3:44 AM, Paul Moore notifications@github.com wrote:

Only a local one at the moment, but I can put it on github. It’s nothing more than a directory with a subdirectory “wheels” and in there a wheel downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/

There’s no Pipfile precisely because I don’t know how to specify what I’m trying to achieve. Or I caould add the one from above:

[[source]] url = “https://pypi.python.org/simple” verify_ssl = true name = “pypi”

[packages] cassiopeia = “*” pycurl = {file = “./wheels/pycurl-7.43.0-cp36-cp36m-win_amd64.whl”}

[dev-packages] but that doesn’t do what I want, so I’m not sure how useful that would be to you?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

You can specify local paths in your pipfile already and you can specify project environment variables in a .env file per the documentation.

On Oct 18, 2017, at 8:58 AM, Paul Moore notifications@github.com wrote:

Actually, #909 doesn’t seem that related. What I’m specifically looking for is a way to specify that a directory within the project holds artifacts (probably wheels, but potentially sdists as well) that should be considered as a source. Something like

[[source]] bundled_artifacts = “relative_path_within_repo” name = “bundled” which could then be referenced like any other source.

By limiting it to relative paths within the project, it avoids the possibility of depending on context that’s only available on the local system.

See the discussion on pypa/python-packaging-user-guide#373 for more context.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.