Skip to content

Commit

Permalink
Merge master into develop (#2070)
Browse files Browse the repository at this point in the history
* Fix Github actions cache issues (#1908)

* Fix case of `-f` flag

* Make it clearer what options to pass to `--format`

* fix (masonry.api): `get_requires_for_build_wheel` must return additional list of requirements for building a package, not listed in `pyproject.toml` and not dependencies for the package itself (#1875)

fix (tests): adopted tests

* Lazy Keyring intialization for PasswordManager (#1892)

* Fix Github Actions cache issues (#1928)

* Avoid nested quantifiers with overlapping character space on git url parsing (#1902 (#1913)

* fix (git): match for `\w` instead of `.` for getting user

* change (vcs.git): hold pattern of the regex parts in a dictionary to be consistent over all regexs

* new (vcs.git): test for `parse_url` and some fixes for the regex pattern

* new (vcs.git): test for `parse_url` with string that should fail

* fix (test.vcs.git): make flake8 happy

* fix: correct parsing of wheel version with regex. (#1932)

The previous regexp was only taking the first integer of the version number,
this presented problems when the major version number reached double digits.

Poetry would determine that the version of the dependency is '1', rather than,
ie: '14'. This caused failures to solve versions.

* Fix errors when using the --help option (#1910)

* Fix how repository credentials are retrieved from env vars (#1909)

# Conflicts:
#	poetry/utils/password_manager.py

* Fix downloading packages from Simplepypi (#1851)

* fix downloading packages from simplepypi

* unused code removed

* remove unused imports

* Upgrade dependencies for the 1.0.3 release (#1965)

* Bump version to 1.0.3 (#1966)

* Fix non-compliant Git URL matching

RFC 3986 § 2.3 permits more characters in a URL than were matched. This
corrects that, though there may be other deficiencies. This was a
regression from v1.0.2, where at least “.” was matched without error.

* Update README.md "Updating Poetry"

Currently the note in "Updating Poetry" is different from the one below in "Enable tab completion for Bash, Fish, or Zsh". This MR is to make them more consistent.

* init: change dev dependency prompt

* Fix CI issues (#2069)

Co-authored-by: brandonaut <brandon@hubermx.com>
Co-authored-by: finswimmer <finswimmer77@gmail.com>
Co-authored-by: Yannick PÉROUX <yannick.peroux@gmail.com>
Co-authored-by: Edward George <edwardgeorge@gmail.com>
Co-authored-by: Jan Škoda <skoda@jskoda.cz>
Co-authored-by: Andrew Marshall <andrew@johnandrewmarshall.com>
Co-authored-by: Andrew Selzer <andrewfselzer@gmail.com>
Co-authored-by: Andrii Maletskyi <andrii.maletskyi@gmail.com>
  • Loading branch information
9 people authored Feb 21, 2020
1 parent 4d05c15 commit 7b1fd0c
Show file tree
Hide file tree
Showing 22 changed files with 477 additions and 172 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Get full python version
id: full-python-version
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and set up Poetry
run: |
python get-poetry.py --preview -y
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Get full python version
id: full-python-version
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and set up Poetry
run: |
python get-poetry.py --preview -y
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Test
run: |
source $HOME/.poetry/env
poetry run pytest -q tests
.venv/bin/pytest -q tests
Windows:
needs: Linting
Expand All @@ -106,7 +106,7 @@ jobs:
id: full-python-version
shell: bash
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and setup Poetry
run: |
python get-poetry.py --preview -y
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Change Log

## [1.0.3] - 2020-01-31

### Fixed

- Fixed an error which caused the configuration environment variables (like `POETRY_HTTP_BASIC_XXX_PASSWORD`) to not be used ([#1909](https://github.com/python-poetry/poetry/pull/1909)).
- Fixed an error where the `--help` option was not working ([#1910](https://github.com/python-poetry/poetry/pull/1910)).
- Fixed an error where packages from private indices were not decompressed properly ([#1851](https://github.com/python-poetry/poetry/pull/1851)).
- Fixed an error where the version of some PEP-508-formatted wheel dependencies was not properly retrieved ([#1932](https://github.com/python-poetry/poetry/pull/1932)).
- Fixed internal regexps to avoid potential catastrophic backtracking errors ([#1913](https://github.com/python-poetry/poetry/pull/1913)).
- Fixed performance issues when custom indices were defined in the `pyproject.toml` file ([#1892](https://github.com/python-poetry/poetry/pull/1892)).
- Fixed the `get_requires_for_build_wheel()` function of `masonry.api` which wasn't returning the proper result ([#1875](https://github.com/python-poetry/poetry/pull/1875)).


## [1.0.2] - 2020-01-10

### Fixed
Expand Down Expand Up @@ -783,7 +796,8 @@ Initial release



[Unreleased]: https://github.com/python-poetry/poetry/compare/1.0.2...master
[Unreleased]: https://github.com/python-poetry/poetry/compare/1.0.3...master
[1.0.3]: https://github.com/python-poetry/poetry/releases/tag/1.0.3
[1.0.2]: https://github.com/python-poetry/poetry/releases/tag/1.0.2
[1.0.1]: https://github.com/python-poetry/poetry/releases/tag/1.0.1
[1.0.0]: https://github.com/python-poetry/poetry/releases/tag/1.0.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ to `self update`.
poetry self update 1.0.0
```

!!!note
*Note:*

If you are still on poetry version < 1.0 use `poetry self:update` instead.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ Note that, at the moment, only pure python wheels are supported.

### Options

* `--format (-F)`: Limit the format to either wheel or sdist.
* `--format (-f)`: Limit the format to either `wheel` or `sdist`.

## publish

Expand Down
190 changes: 105 additions & 85 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion poetry/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.2"
__version__ = "1.0.3"
3 changes: 1 addition & 2 deletions poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ def handle(self):
dev_requirements = {}

question = (
"Would you like to define your dev dependencies"
" (require-dev) interactively"
"Would you like to define your development dependencies interactively?"
)
if self.confirm(question, True):
if not help_displayed:
Expand Down
12 changes: 11 additions & 1 deletion poetry/console/config/application_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from clikit.api.event import PreHandleEvent
from clikit.api.event import PreResolveEvent
from clikit.api.event.event_dispatcher import EventDispatcher
from clikit.api.exceptions import CliKitException
from clikit.api.formatter import Style
from clikit.api.io import Input
from clikit.api.io import InputStream
Expand Down Expand Up @@ -101,7 +102,16 @@ def resolve_help_command(
if args.has_option_token("-h") or args.has_option_token("--help"):
from clikit.api.resolver import ResolvedCommand

resolved_command = self.command_resolver.resolve(args, application)
try:
resolved_command = self.command_resolver.resolve(args, application)
except CliKitException:
# We weren't able to resolve the command,
# due to a parse error most likely,
# so we fall back on the default behavior
return super(ApplicationConfig, self).resolve_help_command(
event, event_name, dispatcher
)

# If the current command is the run one, skip option
# check and interpret them as part of the executed command
if resolved_command.command.name == "run":
Expand Down
11 changes: 6 additions & 5 deletions poetry/masonry/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@

def get_requires_for_build_wheel(config_settings=None):
"""
Returns a list of requirements for building, as strings
"""
poetry = Factory().create_poetry(Path("."))
Returns an additional list of requirements for building, as PEP508 strings,
above and beyond those specified in the pyproject.toml file.
main, _ = SdistBuilder.convert_dependencies(poetry.package, poetry.package.requires)
This implementation is optional. At the moment it only returns an empty list, which would be the same as if
not define. So this is just for completeness for future implementation.
"""

return main
return []


# For now, we require all dependencies to build either a wheel or an sdist.
Expand Down
3 changes: 2 additions & 1 deletion poetry/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re

from poetry.semver import Version
from poetry.utils.patterns import wheel_file_re
from poetry.version.requirements import Requirement

from .dependency import Dependency
Expand Down Expand Up @@ -70,7 +71,7 @@ def dependency_from_pep_508(name):
link = Link(path_to_url(os.path.normpath(os.path.abspath(link.path))))
# wheel file
if link.is_wheel:
m = re.match(r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))", link.filename)
m = wheel_file_re.match(link.filename)
if not m:
raise ValueError("Invalid wheel name: {}".format(link.filename))

Expand Down
10 changes: 1 addition & 9 deletions poetry/utils/inspector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import tarfile
import zipfile

from bz2 import BZ2File
from gzip import GzipFile
from typing import Dict
from typing import List
from typing import Union
Expand Down Expand Up @@ -114,27 +112,21 @@ def inspect_sdist(
# Still not dependencies found
# So, we unpack and introspect
suffix = file_path.suffix
gz = None
if suffix == ".zip":
tar = zipfile.ZipFile(str(file_path))
else:
if suffix == ".bz2":
gz = BZ2File(str(file_path))
suffixes = file_path.suffixes
if len(suffixes) > 1 and suffixes[-2] == ".tar":
suffix = ".tar.bz2"
else:
gz = GzipFile(str(file_path))
suffix = ".tar.gz"

tar = tarfile.TarFile(str(file_path), fileobj=gz)
tar = tarfile.open(str(file_path))

try:
tar.extractall(os.path.join(str(file_path.parent), "unpacked"))
finally:
if gz:
gz.close()

tar.close()

unpacked = file_path.parent / "unpacked"
Expand Down
42 changes: 25 additions & 17 deletions poetry/utils/password_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,44 +117,52 @@ def _check(self):
class PasswordManager:
def __init__(self, config):
self._config = config
self._keyring = KeyRing("poetry-repository")
if not self._keyring.is_available():
logger.warning("Using a plaintext file to store and retrieve credentials")
self._keyring = None

@property
def keyring(self):
if self._keyring is None:
self._keyring = KeyRing("poetry-repository")
if not self._keyring.is_available():
logger.warning(
"Using a plaintext file to store and retrieve credentials"
)

return self._keyring

def set_pypi_token(self, name, token):
if not self._keyring.is_available():
if not self.keyring.is_available():
self._config.auth_config_source.add_property(
"pypi-token.{}".format(name), token
)
else:
self._keyring.set_password(name, "__token__", token)
self.keyring.set_password(name, "__token__", token)

def get_pypi_token(self, name):
if not self._keyring.is_available():
if not self.keyring.is_available():
return self._config.get("pypi-token.{}".format(name))

return self._keyring.get_password(name, "__token__")
return self.keyring.get_password(name, "__token__")

def delete_pypi_token(self, name):
if not self._keyring.is_available():
if not self.keyring.is_available():
return self._config.auth_config_source.remove_property(
"pypi-token.{}".format(name)
)

self._keyring.delete_password(name, "__token__")
self.keyring.delete_password(name, "__token__")

def get_http_auth(self, name):
auth = self._config.get("http-basic.{}".format(name))
if not auth:
return None

username, password = auth["username"], auth.get("password")
if password is None:
password = self._keyring.get_password(name, username)
username = self._config.get("http-basic.{}.username".format(name))
password = self._config.get("http-basic.{}.password".format(name))
if not username and not password:
return None
else:
username, password = auth["username"], auth.get("password")
if password is None:
password = self.keyring.get_password(name, username)

return {
"username": username,
Expand All @@ -164,10 +172,10 @@ def get_http_auth(self, name):
def set_http_password(self, name, username, password):
auth = {"username": username}

if not self._keyring.is_available():
if not self.keyring.is_available():
auth["password"] = password
else:
self._keyring.set_password(name, username, password)
self.keyring.set_password(name, username, password)

self._config.auth_config_source.add_property("http-basic.{}".format(name), auth)

Expand All @@ -177,7 +185,7 @@ def delete_http_password(self, name):
return

try:
self._keyring.delete_password(name, auth["username"])
self.keyring.delete_password(name, auth["username"])
except KeyRingError:
pass

Expand Down
Loading

0 comments on commit 7b1fd0c

Please sign in to comment.