Commit ca0a297 1 parent 3c26c8d commit ca0a297 Copy full SHA for ca0a297
File tree 6 files changed +53
-1
lines changed
6 files changed +53
-1
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,11 @@ with the `--username` and `--password` options.
54
54
Now that you can publish to your private repository, you need to be able to
55
55
install dependencies from it.
56
56
57
- For that, you have to edit your ` pyproject.toml ` file, like so
57
+ By default, Poetry uses all repositories configured as shown above for package
58
+ installation.
59
+
60
+ If you would like to use a repository that was not configured like above, you have to
61
+ edit your ` pyproject.toml ` file, like so
58
62
59
63
``` toml
60
64
[[tool .poetry .source ]]
Original file line number Diff line number Diff line change @@ -46,6 +46,17 @@ def __init__(
46
46
for source in self ._local_config .get ("source" , []):
47
47
self ._pool .add_repository (self .create_legacy_repository (source ))
48
48
49
+ # Add any additional repositories configured globally as source
50
+ # This is done after local config sources and before PyPI
51
+ extra_repositories = self ._config .setting ("repositories" , default = {})
52
+ for repository_name , repository_config in extra_repositories .items ():
53
+ if "url" in repository_config :
54
+ self ._pool .add_repository (
55
+ self .create_legacy_repository (
56
+ {"name" : repository_name , "url" : repository_config ["url" ]}
57
+ )
58
+ )
59
+
49
60
# Always put PyPI last to prefer private repositories
50
61
self ._pool .add_repository (PyPiRepository ())
51
62
Original file line number Diff line number Diff line change
1
+ [http-basic ]
Original file line number Diff line number Diff line change
1
+ [settings ]
2
+
3
+ [repositories ]
4
+ [repositories .foo ]
5
+ url = " https://baz.com"
Original file line number Diff line number Diff line change @@ -23,3 +23,8 @@ classifiers = [
23
23
# Requirements
24
24
[tool .poetry .dependencies ]
25
25
python = " ~2.7 || ^3.4"
26
+
27
+ # Extra Source
28
+ [[tool .poetry .source ]]
29
+ name = " foo"
30
+ url = " https://bar.com"
Original file line number Diff line number Diff line change 3
3
from __future__ import unicode_literals
4
4
5
5
from poetry .poetry import Poetry
6
+ from poetry .repositories .pypi_repository import PyPiRepository
6
7
from poetry .utils ._compat import PY2
7
8
from poetry .utils ._compat import Path
8
9
from poetry .utils .toml_file import TomlFile
9
10
11
+ if PY2 :
12
+ from mock import patch
13
+ else :
14
+ from unittest .mock import patch
15
+
10
16
11
17
fixtures_dir = Path (__file__ ).parent / "fixtures"
12
18
@@ -152,3 +158,23 @@ def test_check_fails():
152
158
)
153
159
154
160
assert Poetry .check (content ) == {"errors" : [expected ], "warnings" : []}
161
+
162
+
163
+ @patch ("poetry.config.CONFIG_DIR" , fixtures_dir / "config_with_repositories" )
164
+ def test_sources ():
165
+ poetry = Poetry .create (str (fixtures_dir / "simple_project" ))
166
+ repositories = [
167
+ r ._url for r in poetry .pool .repositories if isinstance (r , PyPiRepository )
168
+ ]
169
+
170
+ source_local = "https://bar.com"
171
+ source_global = "https://baz.com"
172
+ source_pypi = "https://pypi.org/"
173
+
174
+ assert source_local in repositories
175
+ assert source_global in repositories
176
+ assert source_pypi in repositories
177
+
178
+ assert repositories .index (source_local ) < repositories .index (source_global )
179
+ assert repositories .index (source_global ) < repositories .index (source_pypi )
180
+ assert repositories .index (source_pypi ) == len (repositories ) - 1
You can’t perform that action at this time.
0 commit comments