diff --git a/poetry.lock b/poetry.lock index c042544..1152cf2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. [[package]] name = "cfgv" @@ -331,6 +331,23 @@ files = [ {file = "pyyaml-6.0.2.tar.gz", hash = "sha256:d584d9ec91ad65861cc08d42e834324ef890a082e591037abe114850ff7bbc3e"}, ] +[[package]] +name = "setuptools" +version = "73.0.1" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "setuptools-73.0.1-py3-none-any.whl", hash = "sha256:b208925fcb9f7af924ed2dc04708ea89791e24bde0d3020b27df0e116088b34e"}, + {file = "setuptools-73.0.1.tar.gz", hash = "sha256:d59a3e788ab7e012ab2c4baed1b376da6366883ee20d7a5fc426816e3d7b1193"}, +] + +[package.extras] +core = ["importlib-metadata (>=6) ; python_version < \"3.10\"", "importlib-resources (>=5.10.2) ; python_version < \"3.9\"", "jaraco.text (>=3.7)", "more-itertools (>=8.8)", "packaging (>=24)", "platformdirs (>=2.6.2)", "tomli (>=2.0.1) ; python_version < \"3.11\"", "wheel (>=0.43.0)"] +doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "pyproject-hooks (!=1.1)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier", "towncrier (<24.7)"] +test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "importlib-metadata", "ini2toml[lite] (>=0.14)", "jaraco.develop (>=7.21) ; python_version >= \"3.9\" and sys_platform != \"cygwin\"", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "jaraco.test", "mypy (==1.11.*)", "packaging (>=23.2)", "pip (>=19.1)", "pyproject-hooks (!=1.1)", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy", "pytest-perf ; sys_platform != \"cygwin\"", "pytest-ruff (<0.4) ; platform_system == \"Windows\"", "pytest-ruff (>=0.2.1) ; sys_platform != \"cygwin\"", "pytest-ruff (>=0.3.2) ; sys_platform != \"cygwin\"", "pytest-subprocess", "pytest-timeout", "pytest-xdist (>=3)", "tomli", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel (>=0.44.0)"] + [[package]] name = "tomli" version = "2.2.1" @@ -374,6 +391,18 @@ files = [ {file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"}, ] +[[package]] +name = "types-setuptools" +version = "73.0.0.20240822" +description = "Typing stubs for setuptools" +optional = false +python-versions = ">=3.8" +groups = ["dev"] +files = [ + {file = "types-setuptools-73.0.0.20240822.tar.gz", hash = "sha256:3a060681098eb3fbc2fea0a86f7f6af6aa1ca71906039d88d891ea2cecdd4dbf"}, + {file = "types_setuptools-73.0.0.20240822-py3-none-any.whl", hash = "sha256:b9eba9b68546031317a0fa506d4973641d987d74f79e7dd8369ad4f7a93dea17"}, +] + [[package]] name = "typing-extensions" version = "4.13.2" @@ -414,7 +443,7 @@ description = "Support for the standard curses module on Windows" optional = false python-versions = "*" groups = ["main"] -markers = "sys_platform == \"win32\"" +markers = "platform_system == \"Windows\"" files = [ {file = "windows_curses-2.4.1-cp310-cp310-win32.whl", hash = "sha256:53d711e07194d0d3ff7ceff29e0955b35479bc01465d46c3041de67b8141db2f"}, {file = "windows_curses-2.4.1-cp310-cp310-win_amd64.whl", hash = "sha256:325439cd4f37897a1de8a9c068a5b4c432f9244bf9c855ee2fbeb3fa721a770c"}, @@ -436,5 +465,5 @@ files = [ [metadata] lock-version = "2.1" -python-versions = ">=3.8" -content-hash = "cd366ba1f1cf7c56f91f8e2f1101c126217ba7c9898ddfa69424dd6e42fd1a5e" +python-versions = "^3.8" +content-hash = "58f8e7ea7bba7c4004cdef9eb5fd23ad7984646a3e340151fe312450922f2586" diff --git a/pyproject.toml b/pyproject.toml index deaced0..a778239 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + [tool.poetry] name = "pick" version = "2.5.0" @@ -10,14 +14,12 @@ homepage = "https://github.com/aisk/pick" keywords = ["terminal", "gui"] [tool.poetry.dependencies] -python = ">=3.8" -windows-curses = {version = "^2.2.0", platform = "win32"} +python = "^3.8" +windows-curses = {version = "^2.2.0", markers = "platform_system == 'Windows'"} [tool.poetry.dev-dependencies] pytest = "^8.3.5" mypy = "^1.4" pre-commit = "^3.5.0" - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" +setuptools = "^73.0.0" +types-setuptools = "^73.0.0" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..be5693e --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +import sysconfig +from setuptools import setup, find_packages + +install_requires = [] + +if not sysconfig.get_platform().startswith("mingw"): + install_requires.append('windows-curses>=2.2.0,<3.0.0; platform_system == "Windows"') + +setup( + name='pick', + version='2.5.0', + packages=find_packages(where='src'), + package_dir={'': 'src'}, + install_requires=install_requires, + description="Pick an option in the terminal with a simple GUI", + author="wong2", + author_email="wonderfuly@gmail.com", + license="MIT", + url="https://github.com/aisk/pick", + keywords=["terminal", "gui"], + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Terminals" + ], +) diff --git a/src/pick/__init__.py b/src/pick/__init__.py index 49d96db..bbe8983 100644 --- a/src/pick/__init__.py +++ b/src/pick/__init__.py @@ -1,9 +1,32 @@ -import curses +import os +import sys import textwrap from collections import namedtuple from dataclasses import dataclass, field from typing import Any, Container, Generic, Iterable, List, Optional, Sequence, Tuple, TypeVar, Union +# Handle curses import for different environments +if sys.platform == "win32": + # Check if we're in an MSYS2 environment + if "MSYSTEM" in os.environ: + # MSYS2 has built-in curses support + import curses + else: + # Native Windows requires windows-curses + try: + import curses + except ImportError: + try: + import windows_curses as curses + except ImportError: + raise ImportError( + "On native Windows, the 'windows-curses' package is required. " + "Please install it using: pip install windows-curses" + ) +else: + # Non-Windows systems have built-in curses + import curses + __all__ = ["Picker", "pick", "Option"]