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

Adding private pip repo support for legacy pypi repos. #201

Merged
merged 4 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ The default category is `main`.
[environment.yml][envyaml], using [Poetry's][poetry] dependency solver, if
installed with the `pip_support` extra.

### private pip repositories
Right now `conda-lock` only supports [legacy](https://warehouse.pypa.io/api-reference/legacy.html) pypi repos with basic auth. Most self-hosted repositories like Nexus, Artifactory etc. use this. To use this feature, add your private repo into Poetry's config _including_ the basic auth in the url:

```bash
poetry config repositories.foo https://username:password@foo.repo/simple/
```

### --dev-dependencies/--no-dev-dependencies

By default conda-lock will include dev dependencies in the specification of the lock (if the files that the lock
Expand Down
12 changes: 11 additions & 1 deletion conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from clikit.io import ConsoleIO, NullIO
from packaging.tags import compatible_tags, cpython_tags
from poetry.core.packages import Dependency, Package, ProjectPackage, URLDependency
from poetry.factory import Factory
from poetry.installation.chooser import Chooser
from poetry.installation.operations.uninstall import Uninstall
from poetry.puzzle import Solver
Expand Down Expand Up @@ -197,8 +198,17 @@ def solve_pypi(
for dep in dependencies:
dummy_package.add_dependency(dep)

factory = Factory()
config = factory.create_config()
repos = [
factory.create_legacy_repository(
{"name": source[0], "url": source[1]["url"]}, config
)
for source in config.get("repositories", {}).items()
]

pypi = PyPiRepository()
pool = Pool(repositories=[pypi])
pool = Pool(repositories=[*repos, pypi])

installed = Repository()
locked = Repository()
Expand Down