mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-04 16:51:40 -05:00
poetry: Rewrite updater in Python
This commit is contained in:
parent
d60de8ff3a
commit
40e361d53b
5 changed files with 142 additions and 19 deletions
46
pkgs/poetry/poetry.lock
generated
46
pkgs/poetry/poetry.lock
generated
|
@ -417,6 +417,14 @@ zipp = {version = ">=0.4", markers = "python_version < \"3.8\""}
|
||||||
[package.extras]
|
[package.extras]
|
||||||
docs = ["sphinx", "rst.linker", "jaraco.packaging"]
|
docs = ["sphinx", "rst.linker", "jaraco.packaging"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iniconfig"
|
||||||
|
version = "1.1.1"
|
||||||
|
description = "iniconfig: brain-dead simple config-ini parsing"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipaddress"
|
name = "ipaddress"
|
||||||
version = "1.0.23"
|
version = "1.0.23"
|
||||||
|
@ -484,7 +492,7 @@ testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "keyring"
|
name = "keyring"
|
||||||
version = "21.8.0"
|
version = "22.3.0"
|
||||||
description = "Store and access your passwords safely."
|
description = "Store and access your passwords safely."
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
|
@ -498,7 +506,7 @@ SecretStorage = {version = ">=3.2", markers = "sys_platform == \"linux\""}
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
|
docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
|
||||||
testing = ["pytest (>=3.5,!=3.7.3)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "jaraco.test (>=3.2.0)", "pytest-black (>=0.3.7)", "pytest-mypy"]
|
testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pytest-cov", "pytest-enabler", "pytest-black (>=0.3.7)", "pytest-mypy"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lockfile"
|
name = "lockfile"
|
||||||
|
@ -768,6 +776,28 @@ wcwidth = "*"
|
||||||
checkqa-mypy = ["mypy (==v0.761)"]
|
checkqa-mypy = ["mypy (==v0.761)"]
|
||||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"]
|
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pytest"
|
||||||
|
version = "6.2.5"
|
||||||
|
description = "pytest: simple powerful testing with Python"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
|
||||||
|
attrs = ">=19.2.0"
|
||||||
|
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||||
|
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
|
||||||
|
iniconfig = "*"
|
||||||
|
packaging = "*"
|
||||||
|
pluggy = ">=0.12,<2.0"
|
||||||
|
py = ">=1.8.2"
|
||||||
|
toml = "*"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest-cov"
|
name = "pytest-cov"
|
||||||
version = "2.12.1"
|
version = "2.12.1"
|
||||||
|
@ -1082,7 +1112,7 @@ testing = ["pathlib2", "unittest2", "jaraco.itertools", "func-timeout"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "~2.7 || ^3.5"
|
python-versions = "~2.7 || ^3.5"
|
||||||
content-hash = "290e530f0cdd81360dd6cb93f3182ac8e8b18a46238198d25de11c26f6b0c356"
|
content-hash = "3de9a28e5a2f53d26b75a9aa3eb333b360eb04470769675fb435183ab871798c"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
atomicwrites = [
|
atomicwrites = [
|
||||||
|
@ -1366,6 +1396,10 @@ importlib-resources = [
|
||||||
{file = "importlib_resources-3.2.1-py2.py3-none-any.whl", hash = "sha256:e2860cf0c4bc999947228d18be154fa3779c5dde0b882bd2d7b3f4d25e698bd6"},
|
{file = "importlib_resources-3.2.1-py2.py3-none-any.whl", hash = "sha256:e2860cf0c4bc999947228d18be154fa3779c5dde0b882bd2d7b3f4d25e698bd6"},
|
||||||
{file = "importlib_resources-3.2.1.tar.gz", hash = "sha256:a9fe213ab6452708ec1b3f4ec6f2881b8ab3645cb4e5efb7fea2bbf05a91db3b"},
|
{file = "importlib_resources-3.2.1.tar.gz", hash = "sha256:a9fe213ab6452708ec1b3f4ec6f2881b8ab3645cb4e5efb7fea2bbf05a91db3b"},
|
||||||
]
|
]
|
||||||
|
iniconfig = [
|
||||||
|
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
|
||||||
|
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
|
||||||
|
]
|
||||||
ipaddress = [
|
ipaddress = [
|
||||||
{file = "ipaddress-1.0.23-py2.py3-none-any.whl", hash = "sha256:6e0f4a39e66cb5bb9a137b00276a2eff74f93b71dcbdad6f10ff7df9d3557fcc"},
|
{file = "ipaddress-1.0.23-py2.py3-none-any.whl", hash = "sha256:6e0f4a39e66cb5bb9a137b00276a2eff74f93b71dcbdad6f10ff7df9d3557fcc"},
|
||||||
{file = "ipaddress-1.0.23.tar.gz", hash = "sha256:b7f8e0369580bb4a24d5ba1d7cc29660a4a6987763faf1d8a8046830e020e7e2"},
|
{file = "ipaddress-1.0.23.tar.gz", hash = "sha256:b7f8e0369580bb4a24d5ba1d7cc29660a4a6987763faf1d8a8046830e020e7e2"},
|
||||||
|
@ -1381,8 +1415,8 @@ keyring = [
|
||||||
{file = "keyring-18.0.1.tar.gz", hash = "sha256:67d6cc0132bd77922725fae9f18366bb314fd8f95ff4d323a4df41890a96a838"},
|
{file = "keyring-18.0.1.tar.gz", hash = "sha256:67d6cc0132bd77922725fae9f18366bb314fd8f95ff4d323a4df41890a96a838"},
|
||||||
{file = "keyring-20.0.1-py2.py3-none-any.whl", hash = "sha256:c674f032424b4bffc62abeac5523ec49cc84aed07a480c3233e0baf618efc15c"},
|
{file = "keyring-20.0.1-py2.py3-none-any.whl", hash = "sha256:c674f032424b4bffc62abeac5523ec49cc84aed07a480c3233e0baf618efc15c"},
|
||||||
{file = "keyring-20.0.1.tar.gz", hash = "sha256:963bfa7f090269d30bdc5e25589e5fd9dad2cf2a7c6f176a7f2386910e5d0d8d"},
|
{file = "keyring-20.0.1.tar.gz", hash = "sha256:963bfa7f090269d30bdc5e25589e5fd9dad2cf2a7c6f176a7f2386910e5d0d8d"},
|
||||||
{file = "keyring-21.8.0-py3-none-any.whl", hash = "sha256:4be9cbaaaf83e61d6399f733d113ede7d1c73bc75cb6aeb64eee0f6ac39b30ea"},
|
{file = "keyring-22.3.0-py3-none-any.whl", hash = "sha256:2bc8363ebdd63886126a012057a85c8cb6e143877afa02619ac7dbc9f38a207b"},
|
||||||
{file = "keyring-21.8.0.tar.gz", hash = "sha256:1746d3ac913d449a090caf11e9e4af00e26c3f7f7e81027872192b2398b98675"},
|
{file = "keyring-22.3.0.tar.gz", hash = "sha256:16927a444b2c73f983520a48dec79ddab49fe76429ea05b8d528d778c8339522"},
|
||||||
]
|
]
|
||||||
lockfile = [
|
lockfile = [
|
||||||
{file = "lockfile-0.12.2-py2.py3-none-any.whl", hash = "sha256:6c3cb24f344923d30b2785d5ad75182c8ea7ac1b6171b08657258ec7429d50fa"},
|
{file = "lockfile-0.12.2-py2.py3-none-any.whl", hash = "sha256:6c3cb24f344923d30b2785d5ad75182c8ea7ac1b6171b08657258ec7429d50fa"},
|
||||||
|
@ -1502,6 +1536,8 @@ pytest = [
|
||||||
{file = "pytest-4.6.11.tar.gz", hash = "sha256:50fa82392f2120cc3ec2ca0a75ee615be4c479e66669789771f1758332be4353"},
|
{file = "pytest-4.6.11.tar.gz", hash = "sha256:50fa82392f2120cc3ec2ca0a75ee615be4c479e66669789771f1758332be4353"},
|
||||||
{file = "pytest-5.4.3-py3-none-any.whl", hash = "sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1"},
|
{file = "pytest-5.4.3-py3-none-any.whl", hash = "sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1"},
|
||||||
{file = "pytest-5.4.3.tar.gz", hash = "sha256:7979331bfcba207414f5e1263b5a0f8f521d0f457318836a7355531ed1a4c7d8"},
|
{file = "pytest-5.4.3.tar.gz", hash = "sha256:7979331bfcba207414f5e1263b5a0f8f521d0f457318836a7355531ed1a4c7d8"},
|
||||||
|
{file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"},
|
||||||
|
{file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"},
|
||||||
]
|
]
|
||||||
pytest-cov = [
|
pytest-cov = [
|
||||||
{file = "pytest-cov-2.12.1.tar.gz", hash = "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"},
|
{file = "pytest-cov-2.12.1.tar.gz", hash = "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7"},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "poetry"
|
name = "poetry"
|
||||||
version = "1.1.12"
|
version = "1.1.13"
|
||||||
description = "Python dependency management and packaging made easy."
|
description = "Python dependency management and packaging made easy."
|
||||||
authors = [
|
authors = [
|
||||||
"Sébastien Eustace <sebastien@eustace.io>"
|
"Sébastien Eustace <sebastien@eustace.io>"
|
||||||
|
@ -57,7 +57,7 @@ functools32 = { version = "^3.2.3", python = "~2.7" }
|
||||||
keyring = [
|
keyring = [
|
||||||
{ version = "^18.0.1", python = "~2.7" },
|
{ version = "^18.0.1", python = "~2.7" },
|
||||||
{ version = "^20.0.1", python = "~3.5" },
|
{ version = "^20.0.1", python = "~3.5" },
|
||||||
{ version = "^21.2.0", python = "^3.6" }
|
{ version = ">=21.2.0", python = "^3.6" }
|
||||||
]
|
]
|
||||||
# Use subprocess32 for Python 2.7
|
# Use subprocess32 for Python 2.7
|
||||||
subprocess32 = { version = "^3.5", python = "~2.7" }
|
subprocess32 = { version = "^3.5", python = "~2.7" }
|
||||||
|
@ -66,7 +66,8 @@ importlib-metadata = {version = "^1.6.0", python = "<3.8"}
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
pytest = [
|
pytest = [
|
||||||
{version = "^4.1", python = "<3.5"},
|
{version = "^4.1", python = "<3.5"},
|
||||||
{version = "^5.4.3", python = ">=3.5"}
|
{version = "^5.4.3", python = "~3.5"},
|
||||||
|
{version = "^6.2.5", python = ">=3.6"}
|
||||||
]
|
]
|
||||||
pytest-cov = "^2.5"
|
pytest-cov = "^2.5"
|
||||||
pytest-mock = "^1.9"
|
pytest-mock = "^1.9"
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#!/usr/bin/env nix-shell
|
|
||||||
#! nix-shell -i bash -p curl nix-prefetch-github jq
|
|
||||||
|
|
||||||
rev=$(curl -s https://api.github.com/repos/python-poetry/poetry/releases/latest | jq -r '.name')
|
|
||||||
nix-prefetch-github --rev "$rev" python-poetry poetry > src.json
|
|
||||||
echo >> src.json
|
|
||||||
|
|
||||||
src=$(nix-build --no-out-link --expr 'with import <nixpkgs> {}; fetchFromGitHub (lib.importJSON ./src.json)')
|
|
||||||
cp $src/pyproject.toml $src/poetry.lock .
|
|
||||||
nix-shell -p poetry --run 'poetry lock'
|
|
||||||
nix-build --expr '(import <nixpkgs> { overlays = [ (import ../../overlay.nix) ]; }).poetry'
|
|
20
pkgs/poetry/update.nix
Normal file
20
pkgs/poetry/update.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
let
|
||||||
|
sources = import ../../nix/sources.nix;
|
||||||
|
pkgs = import sources.nixpkgs {
|
||||||
|
overlays = [
|
||||||
|
(import ../../overlay.nix)
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
pythonEnv = pkgs.python3.withPackages (ps: [
|
||||||
|
ps.requests
|
||||||
|
]);
|
||||||
|
|
||||||
|
in
|
||||||
|
pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
pythonEnv
|
||||||
|
pkgs.poetry
|
||||||
|
pkgs.nix
|
||||||
|
];
|
||||||
|
}
|
77
pkgs/poetry/update.py
Executable file
77
pkgs/poetry/update.py
Executable file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#! nix-shell ./update.nix -i python3
|
||||||
|
import subprocess
|
||||||
|
import requests
|
||||||
|
import shutil
|
||||||
|
import json
|
||||||
|
from os.path import (
|
||||||
|
abspath,
|
||||||
|
dirname,
|
||||||
|
join,
|
||||||
|
)
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
workdir = dirname(abspath(__file__))
|
||||||
|
|
||||||
|
rev = requests.get(
|
||||||
|
"https://api.github.com/repos/python-poetry/poetry/releases/latest"
|
||||||
|
).json()["name"]
|
||||||
|
|
||||||
|
p = subprocess.run(
|
||||||
|
[
|
||||||
|
"nix-prefetch-url",
|
||||||
|
"--unpack",
|
||||||
|
f"https://github.com/python-poetry/poetry/archive/refs/tags/{rev}.tar.gz",
|
||||||
|
],
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(join(workdir, "src.json"), "w") as f:
|
||||||
|
f.write(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"owner": "python-poetry",
|
||||||
|
"repo": "poetry",
|
||||||
|
"rev": rev,
|
||||||
|
"sha256": p.stdout.decode().strip(),
|
||||||
|
"fetchSubmodules": True,
|
||||||
|
},
|
||||||
|
indent=2,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
src = (
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
"nix-build",
|
||||||
|
"--no-out-link",
|
||||||
|
"--expr",
|
||||||
|
"with import <nixpkgs> {}; fetchFromGitHub (lib.importJSON ./src.json)",
|
||||||
|
],
|
||||||
|
check=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
.stdout.decode()
|
||||||
|
.strip()
|
||||||
|
)
|
||||||
|
|
||||||
|
for f in ["poetry.lock", "pyproject.toml"]:
|
||||||
|
shutil.copy(join(src, f), join(workdir, f))
|
||||||
|
os.chmod(join(workdir, f), 0o664)
|
||||||
|
|
||||||
|
subprocess.run(["poetry", "lock"], check=True)
|
||||||
|
|
||||||
|
# Build poetry and check updated version matches extracted rev
|
||||||
|
assert (
|
||||||
|
subprocess.run(
|
||||||
|
["nix-shell", join(workdir, "update.nix"), "--run", "poetry --version"],
|
||||||
|
check=True,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
.stdout.decode()
|
||||||
|
.split()[-1]
|
||||||
|
== rev
|
||||||
|
)
|
Loading…
Add table
Reference in a new issue