Unverified Commit ed104cd0 authored by Sébastien Eustace's avatar Sébastien Eustace
Browse files

Add a fallback mechanism for missing dependencies

parent 81c6fdfb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
### Added

- Added support for Python 2.7.
- Added a fallback mechanism (opt-in) for missing dependencies.

### Changes

+21 −0
Original line number Diff line number Diff line
@@ -61,6 +61,27 @@ $ poetry add pendulum

It will automatically find a suitable version constraint.

!!!warning

    `poetry` uses the PyPI JSON API to retrieve package information.
    
    However, some packages (like `boto3` for example) have missing dependency
    information due to bad packaging/publishing which means that `poetry` won't
    be able to properly resolve dependencies.
    
    To workaround it you can set the missing dependencies yourself in your `pyproject.toml`
    or you can tell `poetry` to use a fallback mechanism by setting the
    `settings.pypi.fallback` setting to `true`.
    
    ```bash
    poetry config settings.pypi.fallback true
    ```
    
    Note that this is temporary and should be avoided as much as possible since
    it increases the dependency resolution time drastically (up to 30 minutes in some cases).
    
    Any case of missing dependencies should be reported to https://github.com/sdispater/poetry/issues

### Version constraints

In our example, we are requesting the `pendulum` package with the version constraint `^1.4`.
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class Config:
    def content(self):
        return self._content

    def setting(self, setting_name):  # type: (str) -> Any
    def setting(self, setting_name, default=None):  # type: (str) -> Any
        """
        Retrieve a setting value.
        """
@@ -42,7 +42,7 @@ class Config:
        config = self._raw_content
        for key in keys:
            if key not in config:
                return None
                return default

            config = config[key]

+1 −1
Original line number Diff line number Diff line
@@ -10,6 +10,6 @@ class CheckCommand(Command):

    def handle(self):
        # Load poetry and display errors, if any
        self.poetry.check(self.poetry.config, strict=True)
        self.poetry.check(self.poetry.local_config, strict=True)

        self.info('All set!')
+7 −4
Original line number Diff line number Diff line
@@ -49,11 +49,13 @@ To remove a repository (repo is a short alias for repositories):
        # Create config file if it does not exist
        if not self._config.file.exists():
            self._config.file.parent.mkdir(parents=True, exist_ok=True)
            self._config.file.write_text(TEMPLATE)
            with self._config.file.open() as f:
                f.write(TEMPLATE)

        if not self._auth_config.file.exists():
            self._auth_config.file.parent.mkdir(parents=True, exist_ok=True)
            self._auth_config.file.write_text(AUTH_TEMPLATE)
            with self._auth_config.file.open() as f:
                f.write(AUTH_TEMPLATE)

    def handle(self):
        if self.option('list'):
@@ -98,7 +100,8 @@ To remove a repository (repo is a short alias for repositories):
        boolean_normalizer = lambda val: True if val in ['true', '1'] else False

        unique_config_values = {
            'settings.virtualenvs.create': (boolean_validator, boolean_normalizer)
            'settings.virtualenvs.create': (boolean_validator, boolean_normalizer),
            'settings.pypi.fallback': (boolean_validator, boolean_normalizer),
        }

        if setting_key in unique_config_values:
@@ -216,7 +219,7 @@ To remove a repository (repo is a short alias for repositories):
        orig_k = k

        for key, value in contents.items():
            if k is None and key not in ['config', 'repositories']:
            if k is None and key not in ['config', 'repositories', 'settings']:
                continue

            if isinstance(value, dict) or key == 'repositories' and k is None:
Loading