Skip to content

Commit b87fe4e

Browse files
authored
Merge pull request #247 from cloudblue/cr/LITE-33583-drop-fs-fix-brew-install
LITE-33583 Fix Homebrew installation crashing on missing pkg_resources
2 parents 0fce53b + 69e7a06 commit b87fe4e

4 files changed

Lines changed: 35 additions & 40 deletions

File tree

connect/cli/plugins/product/clone.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from datetime import datetime
2+
from tempfile import TemporaryDirectory
23

34
from click import ClickException
45
from connect.client import ClientError
5-
from fs.tempfs import TempFS
66
from openpyxl import load_workbook
77

88
from connect.cli.plugins.product.export import dump_product
@@ -20,9 +20,17 @@
2020
from connect.cli.plugins.shared.utils import get_translation_attributes_sheets
2121

2222

23+
class _TempDir:
24+
# ponytail: stdlib stand-in for the archived pyfilesystem2 TempFS, which broke
25+
# on setuptools>=81 (pkg_resources removed). Cleaned up on garbage collection.
26+
def __init__(self, identifier):
27+
self._tmp = TemporaryDirectory(suffix=identifier)
28+
self.root_path = self._tmp.name
29+
30+
2331
class ProductCloner:
2432
def __init__(self, config, source_account, destination_account, product_id, progress, stats):
25-
self.fs = TempFS(identifier=f'_clone_{product_id}')
33+
self.fs = _TempDir(f'_clone_{product_id}')
2634
self.config = config
2735
self.source_account = source_account if source_account else config.active.id
2836
self.destination_account = destination_account if destination_account else config.active.id

poetry.lock

Lines changed: 7 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ connect-eaas-core = ">=37.0"
7272
rich = "^12.4.1"
7373
poetry-core = "^1.3.0"
7474
uvloop = { version = "^0.22.0", markers = "sys_platform == \"linux\" or sys_platform == \"darwin\"" }
75-
fs = "^2.4.12"
7675
pyyaml = "^6.0"
76+
# interrogatio (and other deps) import the legacy pkg_resources API, removed in setuptools 81.
77+
setuptools = "<81"
7778

7879
[tool.poetry.group.test.dependencies]
7980
black = "23.*"

tests/conftest.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import pytest
77
import responses
8-
from fs.tempfs import TempFS
98
from openpyxl import load_workbook
109
from responses.registries import OrderedRegistry
1110

@@ -24,8 +23,22 @@
2423

2524

2625
@pytest.fixture(scope='function')
27-
def fs():
28-
return TempFS()
26+
def fs(tmp_path):
27+
# ponytail: pytest's tmp_path (auto-cleaned) replaces pyfilesystem2 TempFS;
28+
# tests only need root_path plus these three path helpers, relative to the root.
29+
class _FS:
30+
root_path = str(tmp_path)
31+
32+
def makedir(self, path):
33+
os.mkdir(os.path.join(self.root_path, path))
34+
35+
def makedirs(self, path):
36+
os.makedirs(os.path.join(self.root_path, path))
37+
38+
def create(self, path):
39+
open(os.path.join(self.root_path, path), 'w').close()
40+
41+
return _FS()
2942

3043

3144
@pytest.fixture(scope='session', autouse=True)

0 commit comments

Comments
 (0)