Clash 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?
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.
;
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.
Why not set up a private PyPI index to serve those wheels?
– Martijn Pieters♦
yesterday