Merge pull request #1034 from nix-community/poetry_1_4_0

poetry: 1.3.0 -> 1.4.1
This commit is contained in:
adisbladis 2023-03-24 11:44:28 +13:00 committed by GitHub
commit 109469e975
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 829 additions and 586 deletions

View file

@ -1,4 +1,5 @@
{ python
, stdenv
, buildPackages
, makeSetupHook
, wheel
@ -80,6 +81,44 @@ in
)
{ };
# As of 2023-03 a newer version of packaging introduced a new behaviour where python-requires
# cannot contain version wildcards. This behaviour is complaint with PEP440
#
# The wildcards are a no-op anyway so we can work around this issue by just dropping the precision down to the last known number.
poetry2nixPythonRequiresPatchHook = callPackage
(
_:
let
# Python pre 3.9 does not contain the ast.unparse method.
# We can extract this from Python 3.8 for any
unparser = stdenv.mkDerivation {
name = "${python.name}-astunparse";
inherit (python) src;
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/poetry2nix_astunparse
cp ./Tools/parser/unparse.py $out/poetry2nix_astunparse/__init__.py
'';
};
pythonPath =
[ ]
++ lib.optional (lib.versionOlder python.version "3.9") unparser;
in
makeSetupHook
{
name = "require-python-patch-hook.sh";
substitutions = {
inherit pythonInterpreter pythonPath;
patchScript = ./python-requires-patch-hook.py;
};
} ./python-requires-patch-hook.sh
)
{ };
# When the "wheel" package itself is a wheel the nixpkgs hook (which pulls in "wheel") leads to infinite recursion
# It doesn't _really_ depend on wheel though, it just copies the wheel.
wheelUnpackHook = callPackage

View file

@ -0,0 +1,79 @@
#!/usr/bin/env python
import ast
import sys
import io
# Python2 compat
if sys.version_info[0] < 3:
FileNotFoundError = IOError
# Python <= 3.8 compat
def astunparse(tree):
# Use bundled unparse by default
if hasattr(ast, "unparse"):
return ast.unparse(tree)
# Use example tool from Python sources for older interpreter versions
from poetry2nix_astunparse import Unparser
buf = io.StringIO()
up = Unparser(tree, buf)
return buf.getvalue()
class Rewriter(ast.NodeVisitor):
def __init__(self, *args, **kwargs):
super(Rewriter, self).__init__(*args, **kwargs)
self.modified = False
def visit_Call(self, node):
function_name = ""
if isinstance(node.func, ast.Name):
function_name = node.func.id
elif isinstance(node.func, ast.Attribute):
function_name = node.func.attr
else:
return
if function_name != "setup":
return
for kw in node.keywords:
if kw.arg != "python_requires":
continue
value = kw.value
if not isinstance(value, ast.Constant):
return
# Rewrite version constraints without wildcard characters.
#
# Only rewrite the file if the modified value actually differs, as we lose whitespace and comments when rewriting
# with the AST module.
python_requires = ", ".join(
[v.strip().rstrip(".*") for v in value.value.split(",")]
)
if value.value != python_requires:
value.value = python_requires
self.modified = True
if __name__ == "__main__":
sys.path.extend(sys.argv[1:])
try:
with open("setup.py") as f:
tree = ast.parse(f.read())
except FileNotFoundError:
exit(0)
r = Rewriter()
r.visit(tree)
if r.modified:
with open("setup.py", "w") as f:
f.write(astunparse(tree))

View file

@ -0,0 +1,7 @@
poetry2nix-python-requires-patch-hook() {
if [ -z "${dontFixupPythonRequires-}" ]; then
@pythonInterpreter@ @patchScript@ @pythonPath@
fi
}
postPatchHooks+=(poetry2nix-python-requires-patch-hook)

View file

@ -113,6 +113,7 @@ pythonPackages.callPackage
nativeBuildInputs = [
hooks.poetry2nixFixupHook
]
++ lib.optional (!pythonPackages.isPy27) hooks.poetry2nixPythonRequiresPatchHook
++ lib.optional (isLocked && (getManyLinuxDeps fileInfo.name).str != null) autoPatchelfHook
++ lib.optionals (format == "wheel") [
hooks.wheelUnpackHook

View file

@ -5,10 +5,10 @@
"homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6f493a530feec7358f23d3680416b123717bdf62",
"sha256": "02pn2w7az8pxryqggx69m2fkrsw1qxidiz33z52vj4d5snc7lhd9",
"rev": "49ca35cf163026c3cf91ee1d1e363476f6b5aa7f",
"sha256": "03jnpxi5cili8q6fz91kww437vg8hygc8763jc33apmxhvf7gk3m",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/6f493a530feec7358f23d3680416b123717bdf62.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/49ca35cf163026c3cf91ee1d1e363476f6b5aa7f.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View file

@ -13129,6 +13129,9 @@
"pyproject-flake8": [
"flit-core"
],
"pyproject-hooks": [
"flit-core"
],
"pyproject-metadata": [
"setuptools"
],

View file

@ -1768,7 +1768,7 @@ lib.composeManyExtensions [
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
pkgs.meson
self.meson
pkgs.ninja
pkg-config
];
@ -2261,6 +2261,7 @@ lib.composeManyExtensions [
[ pkgs.gfortran ] ++
lib.optionals (lib.versionAtLeast super.scipy.version "1.7.0") [ self.pythran ] ++
lib.optionals (lib.versionAtLeast super.scipy.version "1.9.0") [ self.meson-python pkg-config ];
dontUseMesonConfigure = true;
propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [ self.pybind11 ];
setupPyBuildFlags = [ "--fcompiler='gnu95'" ];
enableParallelBuilding = true;
@ -2328,7 +2329,8 @@ lib.composeManyExtensions [
shapely = super.shapely.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.geos ];
GEOS_LIBRARY_PATH = pkgs.python3.pkgs.shapely.GEOS_LIBRARY_PATH or null;
GEOS_LIBRARY_PATH = "${pkgs.geos}/lib/libgeos_c${stdenv.hostPlatform.extensions.sharedLibrary}";
GEOS_LIBC = lib.optionalString (!stdenv.isDarwin) "${lib.getLib stdenv.cc.libc}/lib/libc${stdenv.hostPlatform.extensions.sharedLibrary}.6";
@ -2550,7 +2552,7 @@ lib.composeManyExtensions [
# Stop infinite recursion by using bootstrapped pkg from nixpkgs
bootstrapped-pip = super.bootstrapped-pip.override {
wheel = (pkgs.python3.pkgs.override {
wheel = ((if self.python.isPy2 then pkgs.python2 else pkgs.python3).pkgs.override {
python = self.python;
}).wheel;
};
@ -2877,6 +2879,10 @@ lib.composeManyExtensions [
'';
});
meson-python = super.meson-python.overridePythonAttrs (old: {
dontUseMesonConfigure = true;
});
mkdocs = super.mkdocs.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [ self.babel ];
});

1114
pkgs/poetry/poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry"
version = "1.3.0"
version = "1.4.1"
description = "Python dependency management and packaging made easy."
authors = [
"Sébastien Eustace <sebastien@eustace.io>",
@ -47,23 +47,27 @@ generate-setup-file = false
[tool.poetry.dependencies]
python = "^3.7"
poetry-core = "1.4.0"
poetry-plugin-export = "^1.2.0"
poetry-core = "1.5.2"
poetry-plugin-export = "^1.3.0"
"backports.cached-property" = { version = "^1.0.2", python = "<3.8" }
build = "^0.10.0"
cachecontrol = { version = "^0.12.9", extras = ["filecache"] }
cleo = "^2.0.0"
crashtest = "^0.4.1"
dulwich = "^0.20.46"
dulwich = "^0.21.2"
filelock = "^3.8.0"
html5lib = "^1.0"
importlib-metadata = { version = "^4.4", python = "<3.10" }
importlib-metadata = { version = ">=4.4", python = "<3.10" }
installer = "^0.7.0"
jsonschema = "^4.10.0"
keyring = "^23.9.0"
lockfile = "^0.12.2"
# packaging uses calver, so version is unclamped
packaging = ">=20.4"
pexpect = "^4.7.0"
pkginfo = "^1.5"
pkginfo = "^1.9.4"
platformdirs = "^2.5.2"
pyproject-hooks = "^1.0.0"
requests = "^2.18"
requests-toolbelt = ">=0.9.1,<0.11.0"
shellingham = "^1.5"
@ -74,9 +78,9 @@ tomlkit = ">=0.11.1,<1.0.0,!=0.11.2,!=0.11.3"
trove-classifiers = ">=2022.5.19"
# exclude 20.4.5 - 20.4.6 due to https://github.com/pypa/pip/issues/9953
virtualenv = [
{ version = "^20.4.3,!=20.4.5,!=20.4.6", markers = "sys_platform != 'win32' or python_version != '3.9'" },
{ version = "^20.4.3,!=20.4.5,!=20.4.6" },
# see https://github.com/python-poetry/poetry/pull/6950 for details
{ version = "^20.4.3,!=20.4.5,!=20.4.6,<20.16.6", markers = "sys_platform == 'win32' and python_version == '3.9'" },
{ version = "<20.16.6", markers = "sys_platform == 'win32' and python_version == '3.9'" },
]
xattr = { version = "^0.10.0", markers = "sys_platform == 'darwin'" }
urllib3 = "^1.26.0"
@ -87,18 +91,22 @@ pre-commit = "^2.6"
[tool.poetry.group.test.dependencies]
# Cachy frozen to test backwards compatibility for `poetry.utils.cache`.
cachy = "0.3.0"
deepdiff = "^5.0"
flatdict = "^4.0.1"
deepdiff = [
{ version = "^6.2" },
# avoid orjson, which is required by deepdiff 6.2.3, on FreeBSD
# because it requires a rust compiler
{ version = "<6.2.3", markers = "platform_system == 'FreeBSD'"},
]
httpretty = "^1.0"
pytest = "^7.1"
pytest-cov = "^4.0"
pytest-mock = "^3.9"
pytest-randomly = "^3.12"
pytest-xdist = { version = "^2.5", extras = ["psutil"] }
pytest-xdist = { version = "^3.1", extras = ["psutil"] }
zipp = { version = "^3.4", python = "<3.8" }
[tool.poetry.group.typing.dependencies]
mypy = ">=0.990"
mypy = ">=1.0"
types-html5lib = ">=1.1.9"
types-jsonschema = ">=4.9.0"
types-requests = ">=2.28.8"
@ -161,25 +169,22 @@ enable_error_code = [
# warning.
[[tool.mypy.overrides]]
module = [
'poetry.console.commands.self.show.plugins',
'poetry.installation.executor',
'poetry.mixology.version_solver',
'poetry.plugins.plugin_manager',
'poetry.repositories.installed_repository',
'poetry.utils.env',
'poetry.console.commands.self.show.plugins',
'poetry.plugins.plugin_manager',
'poetry.repositories.installed_repository',
'poetry.utils.env',
]
warn_unused_ignores = false
[[tool.mypy.overrides]]
module = [
'cachecontrol.*',
'lockfile.*',
'pexpect.*',
'pkginfo.*',
'requests_toolbelt.*',
'shellingham.*',
'virtualenv.*',
'xattr.*',
'cachecontrol.*',
'lockfile.*',
'pexpect.*',
'requests_toolbelt.*',
'shellingham.*',
'virtualenv.*',
'xattr.*',
]
ignore_missing_imports = true

View file

@ -1,8 +1,8 @@
{
"owner": "python-poetry",
"repo": "poetry",
"rev": "1.3.0",
"sha256": "16ng59ykm7zkjizmwb482y0hawpjjr5mvl0ahjd790xzxcc2bbbv",
"rev": "1.4.1",
"sha256": "09mqabplg5kprs6qgjj2c2xvm1w43ibsawb18swh3css92s4bm4c",
"fetchSubmodules": true
}

View file

@ -79,7 +79,7 @@ builtins.removeAttrs
bcrypt = callTest ./bcrypt { };
mk-poetry-packages = callTest ./mk-poetry-packages { };
markupsafe2 = callTest ./markupsafe2 { };
pendulum = callTest ./pendulum { };
pendulum = skipOSX (callTest ./pendulum { });
# uwsgi = callTest ./uwsgi { }; # Commented out because build is flaky (unrelated to poetry2nix)
jq = callTest ./jq { };
ubersmith = callTest ./ubersmith { };

View file

@ -1,6 +1,7 @@
{ lib, poetry2nix, runCommand }:
{ lib, poetry2nix, runCommand, python38 }:
poetry2nix.mkPoetryApplication {
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
python = python38;
}

View file

@ -1,3 +1,5 @@
# This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "pendulum"
version = "2.1.2"
@ -5,45 +7,7 @@ description = "Python datetimes made easy"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[package.dependencies]
python-dateutil = ">=2.6,<3.0"
pytzdata = ">=2020.1"
[[package]]
name = "python-dateutil"
version = "2.8.1"
description = "Extensions to the standard Python datetime module"
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
[package.dependencies]
six = ">=1.5"
[[package]]
name = "pytzdata"
version = "2020.1"
description = "The Olson timezone database for Python."
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "a890f17c417c63530209c6497568c96aade4ea2907432e17128ce009fd0ba3f3"
[metadata.files]
pendulum = [
files = [
{file = "pendulum-2.1.2-cp27-cp27m-macosx_10_15_x86_64.whl", hash = "sha256:b6c352f4bd32dff1ea7066bd31ad0f71f8d8100b9ff709fb343f3b86cee43efe"},
{file = "pendulum-2.1.2-cp27-cp27m-win_amd64.whl", hash = "sha256:318f72f62e8e23cd6660dbafe1e346950281a9aed144b5c596b2ddabc1d19739"},
{file = "pendulum-2.1.2-cp35-cp35m-macosx_10_15_x86_64.whl", hash = "sha256:0731f0c661a3cb779d398803655494893c9f581f6488048b3fb629c2342b5394"},
@ -66,15 +30,51 @@ pendulum = [
{file = "pendulum-2.1.2-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:94b1fc947bfe38579b28e1cccb36f7e28a15e841f30384b5ad6c5e31055c85d7"},
{file = "pendulum-2.1.2.tar.gz", hash = "sha256:b06a0ca1bfe41c990bbf0c029f0b6501a7f2ec4e38bfec730712015e8860f207"},
]
python-dateutil = [
{file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"},
{file = "python_dateutil-2.8.1-py2.py3-none-any.whl", hash = "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"},
[package.dependencies]
python-dateutil = ">=2.6,<3.0"
pytzdata = ">=2020.1"
[[package]]
name = "python-dateutil"
version = "2.8.2"
description = "Extensions to the standard Python datetime module"
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7"
files = [
{file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"},
{file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"},
]
pytzdata = [
[package.dependencies]
six = ">=1.5"
[[package]]
name = "pytzdata"
version = "2020.1"
description = "The Olson timezone database for Python."
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
files = [
{file = "pytzdata-2020.1-py2.py3-none-any.whl", hash = "sha256:e1e14750bcf95016381e4d472bad004eef710f2d6417240904070b3d6654485f"},
{file = "pytzdata-2020.1.tar.gz", hash = "sha256:3efa13b335a00a8de1d345ae41ec78dd11c9f8807f522d39850f2dd828681540"},
]
six = [
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
files = [
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
]
[metadata]
lock-version = "2.0"
python-versions = "^3.8"
content-hash = "a890f17c417c63530209c6497568c96aade4ea2907432e17128ce009fd0ba3f3"