PipEnv: How to handle locally installed .whl packages

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


PipEnv: How to handle locally installed .whl packages



I'm using PipEnv to set up a project, and some packages I'm needing to install from precompiled binaries. In a previous project I just pipenv installed the .whl files from some local folder into my environment, but this seems to cause issues with the lock file throwing an error if someone else tries to install from the repository since the pipfile tracks the local path. What are best practices for this? Should I create a packages repository as part of the project and install from that?





Why not set up a private PyPI index to serve those wheels?
– Martijn Pieters
yesterday





@MartijnPieters, I think this could reasonably be a viable solution, especially if I was creating these .whl files myself. But given that I'm working with packages that are already published (and downloaded from this wonderful resource), it feels unnecessary to create a wrapper repository. What would the benefits of this be compared to storing the .whl files in the project itself?
– Brendan
yesterday







That wonderful resource does not provide a PyPI compatible index. Defining your own index would save everyone from having to download the wheels manually.
– Martijn Pieters
yesterday







And if you are working with team members that do not use Windows, you can save those members from having to download your wheel files entirely.
– Martijn Pieters
yesterday





Ah, alternative: install the direct URL for the wheel.
– Martijn Pieters
yesterday




1 Answer
1



You should set up a private PyPI index server, and configure Pipenv to use that server.



Setting up a private PyPI server is trivial with a project like pypiserver:


pypiserver


$ mkdir private_pypi && cd mkdir private_pypi
$ pipenv install # create pipenv files
$ pipenv install pypiserver
$ mkdir packages
$ pipenv run pypi-server -p 8080 ./packages &



and put your wheels into their projectname subdirectry of the packages directory, or use twine to publish your package to the server.


projectname


packages


twine



Then add a [[source]] section in your projects Pipfile to points to the server (the url to use ends in /simple, so http://hostname:8080/simple):


[[source]]


Pipfile


/simple


http://hostname:8080/simple


[[source]]
url = "http://hostname:8080/simple"
verify_ssl = false
name = "some_logical_name"



You can use the default name = "pypi" section as a guide.


name = "pypi"



In the [packages] section, specify the index to use for those private wheels:


[packages]


[packages]
wheel1 = {version="*", index="some_logical_name"}
wheel2 = {version="0.41.1", index="some_logical_name"}
some_public_project = "*"



Again, you can explicitly name any of the named indices, including index="pypi". Not adding a index="..." restriction lets Pipenv search all indexes for possible distributions.


index="pypi"


index="..."


Pipenv



For binary wheels published outside of an index (such as those built by Christoph Gohlke), you could consider just installing the full wheel URL:


pipenv install https://download.lfd.uci.edu/pythonlibs/l8ulg3xw/aiohttp-3.3.2-cp36-cp36m-win_amd64.whl



This does force everyone using your Pipfile to a specific platform.





This is an excellent response, and thank you for providing multiple options and examples. Minor side question, how did you get the download link from Gohlke's site? Trying to copy link path doesn't seem to work for me (I get ;)
– Brendan
yesterday


;





I used the developer console; in the network tab a new entry appears when you click a link, as the browser asks where to save the file. I took the URL from that.
– Martijn Pieters
yesterday





Perfect, thank you!
– Brendan
yesterday






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP