Skip to content

Commit fa5f3e7

Browse files
authored
Fix missing readline error on Windows (#503)
## Problem Missing `readline` dependency error when using `list_models` function. Reported in #502 ## Solution This error was the result of the Cursor assistant putting some code into `pinecone/scripts/repl.py` that should only have gone into `scripts/repl.py` (and not been part of the package distribution). This wasn't caught in CI because: - ~`readline` is included in our dev dependencies, which are installed in CI for testing purposes.~ `readline` is part of the python standard library, so even though this reference was inadvertantly referenced, the presence of these import statements should not cause a problem on dev machines (mac) or CI (linux). However, `readline` is [not available for Windows](python/cpython#90028) which is why this error was occurring for the person who reported. - Currently we do not have any Windows-specific testing in CI which is why this error shipped unnoticed. So I implemented some new tests to check the package can be installed on Windows in this PR. ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) ## Test Plan - Going to make a dev build and verify `list_models()` works in google colab (where dev dependencies are not present) (7.0.2.dev1) - Tested in Colab with 7.0.0 and 7.0.1 and could not reproduce the problem; after further research it turns out this is a windows specific problem. I should probably add some windows builds into the test matrix. - Added new installation tests workflow to verify Windows install
1 parent 60dc2e4 commit fa5f3e7

File tree

6 files changed

+91
-85
lines changed

6 files changed

+91
-85
lines changed

.github/workflows/pr.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ jobs:
5757
secrets: inherit
5858
needs: unit-tests
5959

60+
testing-install:
61+
uses: './.github/workflows/testing-install.yaml'
62+
secrets: inherit
63+
6064
package:
6165
name: Check packaging
6266
runs-on: ubuntu-latest

.github/workflows/testing-install.yaml

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@ name: Installation Tests
22

33
on:
44
workflow_call:
5+
workflow_dispatch:
56

67
permissions:
78
contents: read
89
pull-requests: write
910

1011
jobs:
11-
test-install:
12+
install:
1213
runs-on: ${{ matrix.os }}
1314
strategy:
15+
max-parallel: 3
16+
fail-fast: true
1417
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
python: [3.9]
18+
os: [ubuntu-latest, macos-latest]
19+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
20+
1721

1822
steps:
1923
- name: Checkout code
@@ -32,13 +36,90 @@ jobs:
3236
run: python -m build --sdist --wheel
3337

3438
- name: Install from built artifacts
39+
shell: bash
3540
run: |
36-
# Use the wheel if it's pure-python; fallback to sdist otherwise
3741
pip install dist/*.whl || pip install dist/*.tar.gz
3842
3943
- name: Verify import & version
4044
run: |
4145
python - <<EOF
4246
import pinecone
4347
print("Imported OK, version:", pinecone.__version__)
48+
from pinecone import Pinecone
4449
EOF
50+
51+
- name: Check a few basic functions
52+
run: |
53+
python - <<EOF
54+
from pinecone import Pinecone
55+
56+
pc = Pinecone()
57+
print("Indexes:", pc.list_indexes())
58+
print("Collections:", pc.list_collections())
59+
print("Backups:", pc.list_backups())
60+
print("Assistants:", pc.assistant.list_assistants())
61+
print("Inference Models:", pc.inference.list_models())
62+
EOF
63+
env:
64+
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
65+
PINECONE_ADDITIONAL_HEADERS: ${{ vars.PINECONE_ADDITIONAL_HEADERS }}
66+
67+
install-windows:
68+
runs-on: ${{ matrix.os }}
69+
strategy:
70+
max-parallel: 3
71+
fail-fast: true
72+
matrix:
73+
os: [windows-latest]
74+
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Set up Python ${{ matrix.python }}
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: ${{ matrix.python }}
83+
84+
- name: Install build tools
85+
run: |
86+
python -m pip install --upgrade pip setuptools wheel build
87+
88+
- name: Build sdist & wheel
89+
run: python -m build --sdist --wheel
90+
91+
- name: Install from built artifacts
92+
shell: pwsh
93+
run: |
94+
$wheels = Get-ChildItem -Path "dist" -Filter "*.whl"
95+
$sdists = Get-ChildItem -Path "dist" -Filter "*.tar.gz"
96+
if ($wheels) {
97+
pip install $wheels[0].FullName
98+
}
99+
elseif ($sdists) {
100+
pip install $sdists[0].FullName
101+
}
102+
else {
103+
throw "No wheel or sdist found in dist/"
104+
}
105+
106+
- name: Verify import & version
107+
shell: pwsh
108+
run: |
109+
python -c "import pinecone; print('Imported OK, version:', pinecone.__version__)"
110+
111+
- name: Check a few basic functions
112+
shell: pwsh
113+
run: |
114+
python -c "
115+
from pinecone import Pinecone
116+
pc = Pinecone()
117+
print('Indexes:', pc.list_indexes())
118+
print('Collections:', pc.list_collections())
119+
print('Backups:', pc.list_backups())
120+
print('Assistants:', pc.assistant.list_assistants())
121+
print('Inference Models:', pc.inference.list_models())
122+
"
123+
env:
124+
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
125+
PINECONE_ADDITIONAL_HEADERS: ${{ vars.PINECONE_ADDITIONAL_HEADERS }}

pinecone/scripts/repl.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

pinecone/utils/repr_overrides.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import json
22
from datetime import datetime
3-
import readline
4-
import os
5-
import atexit
63

74

85
def custom_serializer(obj):
@@ -23,23 +20,3 @@ def install_json_repr_override(klass):
2320
klass.__repr__ = lambda self: json.dumps(
2421
self.to_dict(), indent=4, sort_keys=False, default=custom_serializer
2522
)
26-
27-
28-
def setup_readline_history():
29-
"""Setup readline history for the custom REPL."""
30-
# Create .pinecone directory in user's home if it doesn't exist
31-
history_dir = os.path.expanduser("~/.pinecone")
32-
os.makedirs(history_dir, exist_ok=True)
33-
34-
# Set up history file
35-
history_file = os.path.join(history_dir, "repl_history")
36-
37-
# Load history if it exists
38-
if os.path.exists(history_file):
39-
readline.read_history_file(history_file)
40-
41-
# Set history size
42-
readline.set_history_length(1000)
43-
44-
# Save history on exit
45-
atexit.register(readline.write_history_file, history_file)

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pinecone-plugin-interface = "^0.0.7"
5858
python-dateutil = ">=2.5.3"
5959
aiohttp = { version = ">=3.9.0", optional = true }
6060
aiohttp-retry = { version = "^2.9.1", optional = true }
61+
pinecone-plugin-assistant = "^1.6.0"
6162

6263
[tool.poetry.group.types]
6364
optional = true
@@ -98,7 +99,6 @@ urllib3_mock = "0.3.3"
9899
responses = ">=0.8.1"
99100
ruff = "^0.9.3"
100101
beautifulsoup4 = "^4.13.3"
101-
pinecone-plugin-assistant = "^1.6.0"
102102
vprof = "^0.38"
103103
tuna = "^0.5.11"
104104
python-dotenv = "^1.1.0"

0 commit comments

Comments
 (0)