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

Support multiple poetry versions #1621

Closed
Closed
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
2 changes: 1 addition & 1 deletion python/helpers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pip-tools==4.3.0
hashin==0.14.6
pipenv==2018.11.26
pipfile==0.0.2
poetry==0.12.17
poetry==1.0.0

# Some dependencies will only install if Cython is present
Cython==0.29.14
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ def fetch_latest_resolvable_version_string(requirement:)
)
end

update_poetry_binary_version

# Shell out to Poetry, which handles everything for us.
run_poetry_command(poetry_update_command)

updated_lockfile =
if File.exist?("poetry.lock") then File.read("poetry.lock")
else File.read("pyproject.lock")
end
updated_lockfile = TomlRB.parse(updated_lockfile)
updated_lockfile = read_lockfile

fetch_version_from_parsed_lockfile(updated_lockfile)
rescue SharedHelpers::HelperSubprocessFailed => e
Expand All @@ -96,6 +94,30 @@ def fetch_latest_resolvable_version_string(requirement:)
end
end

def update_poetry_binary_version
# TODO: I'm not sure if the case where there's no lockfile is
# already handled by dependabot.
lockfile = read_lockfile

# Before version 1.0.0, poetry used a metadata.hashes to store
# package dependencies hashes. After 1.0.0, it is stored in
# metadata.files.
pre100 = lockfile.dig("metadata", "hashes")

return unless pre100

puts " => downgrading poetry to 0.12.17 due to pre-1.0.0 lockfile"
run_poetry_command("pyenv exec pip install poetry==0.12.17")
end

def read_lockfile
updated_lockfile =
if File.exist?("poetry.lock") then File.read("poetry.lock")
else File.read("pyproject.lock")
end
TomlRB.parse(updated_lockfile)
end

def fetch_version_from_parsed_lockfile(updated_lockfile)
version =
updated_lockfile.fetch("package", []).
Expand Down