Skip to content

Commit 385b5e8

Browse files
committed
refactor: remove windows-curses dependency for MSYS2 compatibility
1 parent f7c0e07 commit 385b5e8

4 files changed

Lines changed: 102 additions & 11 deletions

File tree

poetry.lock

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

pyproject.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
15
[tool.poetry]
26
name = "pick"
37
version = "2.5.0"
@@ -10,14 +14,12 @@ homepage = "https://github.com/aisk/pick"
1014
keywords = ["terminal", "gui"]
1115

1216
[tool.poetry.dependencies]
13-
python = ">=3.8"
14-
windows-curses = {version = "^2.2.0", platform = "win32"}
17+
python = "^3.8"
18+
windows-curses = {version = "^2.2.0", markers = "platform_system == 'Windows'"}
1519

1620
[tool.poetry.dev-dependencies]
1721
pytest = "^8.3.5"
1822
mypy = "^1.4"
1923
pre-commit = "^3.5.0"
20-
21-
[build-system]
22-
requires = ["poetry-core>=1.0.0"]
23-
build-backend = "poetry.core.masonry.api"
24+
setuptools = "^73.0.0"
25+
types-setuptools = "^73.0.0"

setup.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import sysconfig
2+
from setuptools import setup, find_packages
3+
4+
install_requires = []
5+
6+
if not sysconfig.get_platform().startswith("mingw"):
7+
install_requires.append('windows-curses>=2.2.0,<3.0.0; platform_system == "Windows"')
8+
9+
setup(
10+
name='pick',
11+
version='2.5.0',
12+
packages=find_packages(where='src'),
13+
package_dir={'': 'src'},
14+
install_requires=install_requires,
15+
description="Pick an option in the terminal with a simple GUI",
16+
author="wong2",
17+
author_email="wonderfuly@gmail.com",
18+
license="MIT",
19+
url="https://github.com/aisk/pick",
20+
keywords=["terminal", "gui"],
21+
classifiers=[
22+
"Development Status :: 5 - Production/Stable",
23+
"Environment :: Console",
24+
"Intended Audience :: Developers",
25+
"License :: OSI Approved :: MIT License",
26+
"Operating System :: OS Independent",
27+
"Programming Language :: Python",
28+
"Programming Language :: Python :: 3",
29+
"Programming Language :: Python :: 3.8",
30+
"Programming Language :: Python :: 3.9",
31+
"Programming Language :: Python :: 3.10",
32+
"Programming Language :: Python :: 3.11",
33+
"Programming Language :: Python :: 3.12",
34+
"Topic :: Software Development :: Libraries :: Python Modules",
35+
"Topic :: Terminals"
36+
],
37+
)

src/pick/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
1-
import curses
1+
import os
2+
import sys
23
import textwrap
34
from collections import namedtuple
45
from dataclasses import dataclass, field
56
from typing import Any, Container, Generic, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union
67

8+
# Handle curses import for different environments
9+
if sys.platform == "win32":
10+
# Check if we're in an MSYS2 environment
11+
if "MSYSTEM" in os.environ:
12+
# MSYS2 has built-in curses support
13+
import curses
14+
else:
15+
# Native Windows requires windows-curses
16+
try:
17+
import curses
18+
except ImportError:
19+
try:
20+
import windows_curses as curses
21+
except ImportError:
22+
raise ImportError(
23+
"On native Windows, the 'windows-curses' package is required. "
24+
"Please install it using: pip install windows-curses"
25+
)
26+
else:
27+
# Non-Windows systems have built-in curses
28+
import curses
29+
730
__all__ = ["Picker", "pick", "Option"]
831

932

0 commit comments

Comments
 (0)