-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Global configuration of custom sources #5958
Comments
I am also wondering why we need to put the private repo into We have to configure it in the actual Can't we just have a configuration for a repo to publish to and for repo(s) to download packages from without exposing any information in |
Any kind of response would be appreciated. |
If I can't get rid of the As a result, I can't use I think this is an important issue/feature request as other developers working in corporations will probably face comparable restrictions. |
Hey, to be honest I haven't used privat repos until now, so please forgive me if my question is might be naiv 😃 If the source of the package is not defined in the fin swimmer |
I'm facing the same issues... In this way @andreas-vester could install locally via |
@andreas-vester |
It is possible we could allow configuring the implicit PyPI URL, but authentication would get messy. I'm still not 100% sure on if this is a useful/desirable feature as it decreases the repeatability of Poetry installations and may have security/correctness implications. As far as configuring primary ( In short, what is desired here is something we could work towards, but I think we would want to think long and hard about Poetry fetching different code from different sources due to environmental factors (up to this point, everything Poetry fetches and installs is strictly defined in the lock file and pyproject.toml). |
@finswimmer To be honest, I haven't thought about a supply chain attack because the packages on our corporate private repo are exactly the same as on pypi. In fact, we are maintaining a pypi mirror for the sole reason that it is forbidden to download software from the internet. In this case, if I install, let's say, the pandas library from our private repo, it's the same package that you would install from pypi. You're right in demanding that the dependencies must be reachable for everybody. That's probably the task of the package maintainer. In my particular case, all the packages are freely available from pypi for those outside our corporate network. If this wouldn't be the case, it probably wouldn't make sense to take the project public in the first place. For example, you wouldn't publish a project that has dependencies from, let's say, a private GitHub repo, wouldn't you? |
@neersighted I am not saying that there is an easy solution to this problem. All I can say is that putting a private repo into pyproject.toml doesn't make any sense as soon as you want to publish your project. Let's assume I were allowed to place our private repo/server names in pyproject.toml and set it as the default source. As soon as you fork the repo from GitHub, you get a configuration that is not working on your end because you are technically not able to reach our internal server. You need pypi. At this point in this discussion it is firstly important to me that we are on the same page with respect to acknowledging the fact that some corporate circumstances are restricting the use of poetry when it comes to public open source projects. The next step would then be to find a suitable solution. At that point I can only make some suggestions and the poetry maintainers have to make a decision. Some suggestions that come to my mind could involve the following:
|
I did try the following without success:
When trying to add a package, poetry tries to reach pypi. |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨
This isn't technically accurate.
I'm not sure this needs to be handled by Poetry, though. All Poetry should care about is "Here are dependency requirements, here are the locked versions of all transitive dependencies, install those". If the user cares about supply chain attack, they should set the index url to a trusted url, but the point is that that trusted url should be swappable. Does it matter if user A's trusted url is different from user B's trusted url? To me, it seems like the issue with not hardcoding a source comes down to two scenarios:
While "repeatability of Poetry installations" is definitely a good thing, IMO that should only be vis a vis locking transitive deps. It shouldn't matter if My company's usecase is we have an Artifactory mirror that's externally facing, and an Artifactory mirror that is only exposed via our company VPN. The VPN mirror is useful for running installs within the AWS VPC (so requests can stay within the AWS region), but the external mirror is useful for devs, so we don't force devs to be on the VPN to install things. We also have a lot of Python projects in our monorepo, and it's a bit annoying to have to copy-paste the same IMO the ideal workflow here would be:
Authentication can be put directly into the url (e.g. |
It would be great if we could also set up this private repository for all users, rather than having to do it per-user. pip supports this with the |
I think there is certainly room for flexibility here, but any design is going to have to come after we first make the existing functionality more consistent/robust (e.g. as described in #5984 (comment), or an alternative). To add new sources of config here or new behaviors before first making the existing functionality better would be an own goal. It will be much easier to reason about a safe/consistent design after refactoring of what we already have. |
✨ This is an old work account. Please reference @brandonchinn178 for all future communication ✨ For people looking for a workaround while this issue is still open, this is what I'm doing at my company (only guaranteed to work for Poetry 1.2.1):
With these steps, you can now swap out the repo used for the source repo (replacing PyPI) without changing This is all very rough; you might have to tweak the diff to get it working for your specific use-case. But it should suffice until Poetry adds this functionality out of the box.
|
To add to the use cases here, currently in China, Pypi timeouts are extremely common so I use a devpi as proxy to prevent that. No point in publishing this in a |
Incidentally, I had the exact same problem with pipenv when I tested it. I added a bit more context on the why in that issue. |
This feature seems to be necessary to use poetry plugins when the company only allows private repositories. Poetry plugins are only loaded when installed globally, e.g. edit: # file: global-pyproject.toml
[tool.poetry]
name = "poetry-instance"
version = "1.4.1"
description = ""
authors = []
license = ""
[tool.poetry.dependencies]
python = "3.9.16"
poetry = "1.4.1"
# Force poetry to download global packages like Poetry plugins from our pypi mirror.
# CI firewall blocks normal pypi connection, which lead to connection errors.
[[tool.poetry.source]]
name = "<company>-pypi-mirror"
url = "<private repository url>/simple/"
default = true
secondary = false and
|
I wrote a plugin that aims to work around this issue by allowing package sources to be configured via the same To use @andreas-vester's example: [[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple/"
default = true would become: export POETRY_REPOSITORIES_FOO_URL=https://foo.bar/simple
export POETRY_REPOSITORIES_FOO_DEFAULT=true Poetry 1.2 or later is required as 1.2 is the earliest version that supports plugins. See it for yourself: https://github.com/celsiusnarhwal/poetry-source-env |
The PyPI mirror plugin might be of interest for users on this issue. https://github.com/arcesium/poetry-plugin-pypi-mirror/ |
I also ran into this issue (specifically in the context of two environments using different repos). While the aforementioned Would it be possible (as a first measure) to offer a setting akin to Though I am not entirely sure (and not very knowledgable with the design philosphy around separating the publish repos) if it makes sense to reuse the |
Feature Request
I am using private repositories to download dependencies as I am working behind a corporate firewall. According to the docs (https://python-poetry.org/docs/repositories/#install-dependencies-from-a-private-repository), I am supposed to put a private repo into
pyproject.toml
.If I do that, I am basically not able to commit
pyproject.toml
to GitHub as I don't want to reveal internal server names. Committing these information would be useless for others anyway, as they are not able to access our internal repos.I am wondering if it would make sense to define private repos in poetry's own configuration on my local machine? Or maybe I can set some environment variables?
The text was updated successfully, but these errors were encountered: