summaryrefslogtreecommitdiff
path: root/repo/poetry
diff options
context:
space:
mode:
Diffstat (limited to 'repo/poetry')
-rw-r--r--repo/poetry/fix-packaging-tags.patch97
-rw-r--r--repo/poetry/poetry.xibuild35
2 files changed, 132 insertions, 0 deletions
diff --git a/repo/poetry/fix-packaging-tags.patch b/repo/poetry/fix-packaging-tags.patch
new file mode 100644
index 0000000..5d9303e
--- /dev/null
+++ b/repo/poetry/fix-packaging-tags.patch
@@ -0,0 +1,97 @@
+From: Patrycja Rosa <alpine@ptrcnull.me>
+Date: Sat, 12 Feb 2022 16:22:01 +0100
+Subject: use embedded script rather than global packaging/tags.py
+
+ Based vaguely on https://github.com/python-poetry/poetry/pull/4749
+
+diff --git a/poetry/utils/env.py b/poetry/utils/env.py
+--- a/poetry/utils/env.py
++++ b/poetry/utils/env.py
+@@ -9,7 +9,6 @@
+ import subprocess
+ import sys
+ import sysconfig
+-import textwrap
+
+ from contextlib import contextmanager
+ from copy import deepcopy
+@@ -56,6 +55,25 @@
+ from poetry.poetry import Poetry
+
+
++GET_SYS_TAGS = f"""
++import importlib.util
++import json
++import sys
++
++from pathlib import Path
++
++spec = importlib.util.spec_from_file_location("packaging", Path(r"{packaging.__file__}"))
++packaging = importlib.util.module_from_spec(spec)
++sys.modules[spec.name] = packaging
++
++spec = importlib.util.spec_from_file_location("packaging.tags", Path(r"{packaging.tags.__file__}"))
++packaging_tags = importlib.util.module_from_spec(spec)
++spec.loader.exec_module(packaging_tags)
++
++print(json.dumps([(t.interpreter, t.abi, t.platform) for t in packaging_tags.sys_tags()]))
++"""
++
++
+ GET_ENVIRONMENT_INFO = """\
+ import json
+ import os
+@@ -1396,31 +1396,6 @@
+
+ def get_supported_tags(self): # type: () -> List[Tag]
+- file_path = Path(packaging.tags.__file__)
+- if file_path.suffix == ".pyc":
+- # Python 2
+- file_path = file_path.with_suffix(".py")
+-
+- with file_path.open(encoding="utf-8") as f:
+- script = decode(f.read())
+-
+- script = script.replace(
+- "from ._typing import TYPE_CHECKING, cast",
+- "TYPE_CHECKING = False\ncast = lambda type_, value: value",
+- )
+- script = script.replace(
+- "from ._typing import MYPY_CHECK_RUNNING, cast",
+- "MYPY_CHECK_RUNNING = False\ncast = lambda type_, value: value",
+- )
+-
+- script += textwrap.dedent(
+- """
+- import json
+-
+- print(json.dumps([(t.interpreter, t.abi, t.platform) for t in sys_tags()]))
+- """
+- )
+-
+- output = self.run_python_script(script)
++ output = self.run_python_script(GET_SYS_TAGS)
+
+ return [Tag(*t) for t in json.loads(output)]
+
+diff --git a/tests/utils/test_env.py b/tests/utils/test_env.py
+index 440add18b..eab04eb0b 100644
+--- a/tests/utils/test_env.py
++++ b/tests/utils/test_env.py
+@@ -99,6 +99,16 @@ def test_env_shell_commands_with_stdinput_in_their_arg_work_as_expected(
+ assert run_output_path.resolve() == venv_base_prefix_path.resolve()
+
+
++def test_env_get_supported_tags_matches_inside_virtualenv(tmp_dir, manager):
++ venv_path = Path(tmp_dir) / "Virtual Env"
++ manager.build_venv(str(venv_path))
++ venv = VirtualEnv(venv_path)
++
++ import packaging.tags
++
++ assert venv.get_supported_tags() == list(packaging.tags.sys_tags())
++
++
+ @pytest.fixture
+ def in_project_venv_dir(poetry):
+ os.environ.pop("VIRTUAL_ENV", None)
diff --git a/repo/poetry/poetry.xibuild b/repo/poetry/poetry.xibuild
new file mode 100644
index 0000000..fbc0f38
--- /dev/null
+++ b/repo/poetry/poetry.xibuild
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+NAME="poetry"
+DESC="Python dependency management and packaging system"
+
+MAKEDEPS="python-poetry-core python-build python-installer python-pyrsistent python-lark python-tomlkit"
+
+PKG_VER=1.1.13
+SOURCE="https://github.com/sdispater/poetry/archive/$PKG_VER.tar.gz"
+
+ADDITIONAL="
+fix-packaging-tags.patch
+"
+
+prepare() {
+ apply_patches
+ git init
+}
+
+build() {
+ python3 -m build --no-isolation --skip-dependency-check --wheel
+}
+
+package() {
+ python3 -m installer -d "$PKG_DEST" --compile-bytecode 0 \
+ dist/poetry-$PKG_VER-py2.py3-none-any.whl
+
+ # remove conflicts with files owned by py3-poetry-core (direct dependency of poetry)
+ # see: https://github.com/python-poetry/poetry/issues/2800
+ local sitedir=$(python3 -c "import site; print(site.getsitepackages()[0])")
+ rm "$PKG_DEST/$sitedir"/poetry/__init__.py \
+ "$PKG_DEST/$sitedir"/poetry/__pycache__/__init__.cpython-*.pyc \
+ "$PKG_DEST/$sitedir"/poetry/json/schemas/poetry-schema.json
+}
+