Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore PyPI if local/private PI available? #331

Closed
2 tasks done
golyalpha opened this issue Jul 24, 2018 · 10 comments
Closed
2 tasks done

Ignore PyPI if local/private PI available? #331

golyalpha opened this issue Jul 24, 2018 · 10 comments
Labels
kind/feature Feature requests/implementations
Milestone

Comments

@golyalpha
Copy link

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Question

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?

@golyalpha
Copy link
Author

golyalpha commented Jul 25, 2018

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?

@sdispater
Copy link
Member

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.

@golyalpha
Copy link
Author

@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).

@nackjicholson
Copy link

nackjicholson commented Aug 7, 2018

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.

@rominf
Copy link

rominf commented Nov 7, 2018

@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.

@sdispater sdispater added the kind/feature Feature requests/implementations label Mar 2, 2019
@sdispater sdispater added this to the 1.0 milestone Mar 2, 2019
@HolgerPeters
Copy link

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.

@sdispater
Copy link
Member

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.

@marco-silva0000
Copy link

marco-silva0000 commented May 15, 2019

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"

@sdispater
Copy link
Member

PR #908 has been merged and is available in the 1.0.0a4 release

Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

6 participants