diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index be498fe..43386c1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] steps: - name: Checkout repository diff --git a/MANIFEST.in b/MANIFEST.in index f63f6d5..edaf60a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include fspin_cheatsheet.md +include fspin/fspin_cheatsheet.md diff --git a/fspin/__main__.py b/fspin/__main__.py index 3830a99..1a5cd42 100644 --- a/fspin/__main__.py +++ b/fspin/__main__.py @@ -1,24 +1,34 @@ import os import sys -def main(): - # Get the directory where this file is located - current_dir = os.path.dirname(os.path.abspath(__file__)) - - # Path to the cheatsheet (it should be bundled with the package) - # We look for it in the package directory or the project root - cheatsheet_path = os.path.join(current_dir, "fspin_cheatsheet.md") - - # Fallback for development environment if not found in package dir - if not os.path.exists(cheatsheet_path): - cheatsheet_path = os.path.join(current_dir, "..", "fspin_cheatsheet.md") +try: + from importlib import resources +except ImportError: + # Fallback for Python < 3.7 + import importlib_resources as resources - if os.path.exists(cheatsheet_path): - with open(cheatsheet_path, "r", encoding="utf-8") as f: - print(f.read()) - else: - print("fspin Cheatsheet not found.") - print("Please check the online documentation at https://github.com/Suke0811/fspin") +def main(): + # Use importlib.resources to access the cheatsheet bundled in the package + try: + # For modern Python (3.9+) + if hasattr(resources, 'files'): + cheatsheet_content = resources.files('fspin').joinpath('fspin_cheatsheet.md').read_text(encoding='utf-8') + else: + # Fallback for older importlib.resources (Python 3.7, 3.8) + with resources.open_text('fspin', 'fspin_cheatsheet.md', encoding='utf-8') as f: + cheatsheet_content = f.read() + print(cheatsheet_content) + except Exception: + # Fallback to local file path if importlib.resources fails (e.g. during development) + current_dir = os.path.dirname(os.path.abspath(__file__)) + cheatsheet_path = os.path.join(current_dir, "fspin_cheatsheet.md") + + if os.path.exists(cheatsheet_path): + with open(cheatsheet_path, "r", encoding="utf-8") as f: + print(f.read()) + else: + print("fspin Cheatsheet not found.") + print("Please check the online documentation at https://github.com/Suke0811/fspin") if __name__ == "__main__": main() diff --git a/fspin_cheatsheet.md b/fspin/fspin_cheatsheet.md similarity index 100% rename from fspin_cheatsheet.md rename to fspin/fspin_cheatsheet.md diff --git a/setup.py b/setup.py index c0b5ae7..2bc4500 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ def read(rel_path): }, license='MIT', packages=find_packages(include=[PACKAGE_NAME, PACKAGE_NAME + '.*']), + include_package_data=True, install_requires=requirements, classifiers=CLASSIFIERS, python_requires=PYTHON_REQUIRES,