{"library":"s3pathlib","title":"s3pathlib","description":"s3pathlib is a Python package that provides an intuitive, object-oriented programming (OOP) interface for manipulating AWS S3 objects and directories. Its API closely resembles the Python standard library's `pathlib` module, making S3 interactions feel familiar and Pythonic. The library is actively maintained, with the current version being 2.3.6, and receives regular minor updates.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install s3pathlib"],"cli":null},"imports":["from s3pathlib import S3Path","from s3pathlib import context"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import boto3\nimport os\nfrom s3pathlib import S3Path, context\n\n# Configure AWS credentials (e.g., from environment variables or a profile)\n# In a real application, consider using AWS IAM roles or proper credential management.\naws_region = os.environ.get(\"AWS_REGION\", \"us-east-1\")\naws_profile = os.environ.get(\"AWS_PROFILE\", None)\n\n# Attach a boto3 session for s3pathlib to use\nif aws_profile:\n    session = boto3.session.Session(region_name=aws_region, profile_name=aws_profile)\nelse:\n    session = boto3.session.Session(region_name=aws_region)\ncontext.attach_boto_session(session)\n\n# Define an S3 path object\nbucket_name = os.environ.get(\"S3_BUCKET_NAME\", \"your-test-bucket-12345\")\ns3_path = S3Path(bucket_name, \"my-folder\", \"hello.txt\")\n\n# Example: Write text to S3\nprint(f\"Writing to {s3_path.uri}...\")\ns3_path.write_text(\"Hello, s3pathlib!\")\nprint(\"Content written.\")\n\n# Example: Read text from S3\nif s3_path.exists():\n    content = s3_path.read_text()\n    print(f\"Content read from S3: '{content}'\")\n\n# Example: Check if a folder exists and list its contents\ns3_dir = S3Path(bucket_name, \"my-folder/\")\nprint(f\"Checking if {s3_dir.uri} exists: {s3_dir.exists()}\")\n\n# Clean up (optional)\n# s3_path.delete() # Deletes the object\n# s3_dir.delete_dir() # Deletes all objects under the prefix (careful!)\n\n# Detach the boto3 session when done (optional, for explicit resource management)\ncontext.detach_boto_session()","lang":"python","description":"This quickstart demonstrates how to initialize `s3pathlib` with AWS credentials, create an `S3Path` object, write content to S3, and read it back. It shows how to use `context.attach_boto_session` for explicit credential management.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"2.3.6","pypi_latest":"2.3.6","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":4.5,"avg_import_s":0.94,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.88,"mem_mb":19.4,"disk_size":"53.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.1,"import_time_s":0.69,"mem_mb":19.4,"disk_size":"54M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.14,"mem_mb":21.6,"disk_size":"56.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.5,"import_time_s":1.04,"mem_mb":21.6,"disk_size":"57M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":1.03,"mem_mb":21.2,"disk_size":"48.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.8,"import_time_s":1.06,"mem_mb":21.2,"disk_size":"49M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.98,"mem_mb":21.8,"disk_size":"48.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.4,"import_time_s":1.05,"mem_mb":21.8,"disk_size":"49M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.77,"mem_mb":19,"disk_size":"52.9M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"s3pathlib","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5.8,"import_time_s":0.75,"mem_mb":19,"disk_size":"53M"}]}}