I have a local PyPI cache, and I'd like all my python projects to pull packages through it by default, instead of the public PI.
The general idea is, that while I'm connected to my network (local PI is available), Poetry will pull packages from/through the local PI, but as soon as I lose connection to the local network, or to the local PI, Poetry would fall back onto pulling packages directly from PyPI.
What I'm wondering about is, if specifying a local PI in the Poetry config and in the project configuration already encompasses that, and if it does, if there's a way to tell Poetry to use the local PI on every project by default. Maybe even, if you have multiple private PIs, let the user specify in which order to query them?
To extend:
If a project has a private repository specified, does Poetry require the same repository to be configured in the local poetry config, or will it use the private repository defined in the project? Or is the local config just for publishing?
The private repositories used to find and install packages must be specified in each pyproject.toml file.
The config command sets settings globally and, for repositories, the configuration is only used for publishing (and soon to retrieve credentials when searching and installing packages, see #306).
Also, the private repositories will always have priority when looking for packages but Poetry will also fallback on PyPI when a package can't be found in the private repos.
@sdispater Thank you, that is what I think is best with the current setup. It would probably be good if that was in the documentation, because the way the documentation for custom repositories is written, it gave me the impression of having to have a repository configured both locally (poetry config) and in the project (pyproject.toml file).
What if I had a package in my private repository, but I wanted to specify explicitly for one dependency I wanted to install the one from PyPi?
# Let's say libx is in my private repo and it's used by other projects, but for this
# project I want to use the one that is publicly available on pypi for some reason.
libx = {version="^1.0.0", repository="pypi"}
That could be nice in my opinion.
@sdispater, for me it doesn't work. I have following section in my pyproject.toml file:
[[tool.poetry.source]]
name = "kama"
url = "https://pypi.kama.gs/tech/index"
I add a dependency with poetry add command, but instead of the desired package, it installs it from PyPI. The only possible reason I see is that version of a package if greater in PyPI than in private repository.
I would like to have a way to disable poetry using Pypi as a fallback. To make that use case a bit more clear, suppose you use devpi as a local artifact store, I worked in a company that selectively copied packages from pypi to the devpi index. This allowed for principally ruling out the installation of certain packages (due to license, security or stability conerns).
Then, individual projects would configure to pull from the local repository and would not have to worry about license issues, etc. This workflow works with pure pip by providing the --index-url and pipenv IIRC also uses the remote repository configured only.
So to me it seems what poetry does is to configure local mirrors to pypi, a valid use case. I would like to configure repositories.
Just to give an update on this. There is currently a work in progress (#908) that will make it possible to deactivate the fallback on PyPI by declaring a source as the default one.
[[tool.poetry.source]]
name = "custom"
url = "http://example.com/simple/"
default = true
This new feature will be available in the 1.0.0聽release.
I have a question regarding this.
I didn't find anywhere in the docs about what happens when you put multiple [[tool.poetry.source]] sections.
My specific use case is also with a devpi as a local artifact store, I would like to use the LAN address as a default (what #908 will allow), the remote address as a first fallback, and pypi after.
what is the expected behavior with:
[[tool.poetry.source]]
name = "devpy-local"
url = "http://192.168.1.2:4041/foo/bar/+simple/"
[[tool.poetry.source]]
name = "devpy-remote"
url = "http://foo.bar.org:4041/foo/bar/+simple/"
[[tool.poetry.source]]
name = "fallback"
url = "https://pypi.python.org/simple"
PR https://github.com/sdispater/poetry/pull/908 has been merged and is available in the 1.0.0a4聽release
Most helpful comment
Just to give an update on this. There is currently a work in progress (#908) that will make it possible to deactivate the fallback on PyPI by declaring a source as the default one.
This new feature will be available in the
1.0.0聽release.