Skip to content

Commit a0b12fc

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

4 files changed

Lines changed: 122 additions & 15 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: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
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"
48
description = "Pick an option in the terminal with a simple GUI"
5-
authors = ["wong2 <wonderfuly@gmail.com>", "AN Long <aisk1988@gmail.com>"]
9+
authors = ["wong2 <wonderfuly@gmail.com>"]
610
license = "MIT"
711
readme = "README.md"
8-
repository = "https://github.com/aisk/pick"
912
homepage = "https://github.com/aisk/pick"
1013
keywords = ["terminal", "gui"]
14+
classifiers = [
15+
"Development Status :: 5 - Production/Stable",
16+
"Environment :: Console",
17+
"Intended Audience :: Developers",
18+
"License :: OSI Approved :: MIT License",
19+
"Operating System :: OS Independent",
20+
"Programming Language :: Python",
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.8",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
27+
"Topic :: Software Development :: Libraries :: Python Modules",
28+
"Topic :: Terminals"
29+
]
30+
packages = [{include = "pick", from = "src"}]
1131

1232
[tool.poetry.dependencies]
13-
python = ">=3.8"
14-
windows-curses = {version = "^2.2.0", platform = "win32"}
33+
python = "^3.8"
34+
windows-curses = {version = "^2.2.0", markers = "platform_system == 'Windows'"}
1535

16-
[tool.poetry.dev-dependencies]
36+
[tool.poetry.group.dev.dependencies]
37+
mypy = "^1.14.1"
1738
pytest = "^8.3.5"
18-
mypy = "^1.4"
1939
pre-commit = "^3.5.0"
20-
21-
[build-system]
22-
requires = ["poetry-core>=1.0.0"]
23-
build-backend = "poetry.core.masonry.api"
40+
setuptools = "^73.0.0"
41+
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)