pyfs-utils is a Python library designed to provide a collection of utilities that simplify and extend working with PyFilesystem2. PyFilesystem2 (or fs) is a powerful Python abstraction layer for various filesystems, allowing you to interact with local files, S3 buckets, FTP servers, ZIP files, and many more through a consistent API. This project aims to build upon that foundation, offering tools and helpers to make your filesystem interactions even more straightforward and robust.
This project features:
- Git-tag-based semantic versioning: Automatic version management using git tags
- Comprehensive CI/CD pipeline: GitHub Actions for testing, building, and releasing
- Multiplatform support: Works on Linux, Windows, and macOS
- Binary distributions: Standalone executables for easy installation
- Complete test suite: 100% test coverage with pytest
- Development tools: Scripts for building, testing, and releasing
pyfs-utils intends to offer:
- Simplified File Operations: High-level functions for common filesystem tasks.
- Cross-Filesystem Utilities: Tools that work seamlessly across any filesystem supported by PyFilesystem2.
- CLI Tools: Command-line interfaces for filesystem operations, built using the utilities provided by this library.
Currently, the package includes a template (skeleton.py) that demonstrates how to create both importable Python modules and command-line scripts. This template uses a Fibonacci calculator as a placeholder example, but it showcases the structure for future filesystem-related utilities.
pyfs-utils is for Python developers who:
- Work with multiple types of filesystems (local, cloud storage, archives, etc.).
- Want to write clean, portable code for file and directory manipulations.
- Are looking for pre-built utilities or a framework to create their own tools for PyFilesystem2.
- Need to create command-line tools that interact with various filesystems.
PyFilesystem2 already provides a fantastic abstraction. pyfs-utils aims to make it even more accessible and productive by:
- Reducing Boilerplate: Offering ready-to-use functions for common patterns.
- Enhancing Reusability: Providing well-tested utilities that can be incorporated into larger applications.
- Streamlining CLI Creation: Giving a clear structure for developing filesystem-related command-line tools.
- Centralizing Helpers: Creating a go-to library for common PyFilesystem2 add-ons.
As the library grows, it will become a valuable toolkit for anyone leveraging PyFilesystem2.
pip install pyfs-utils-
Clone the repository:
git clone https://github.com/twardoch/pyfs-utils.git cd pyfs-utils -
Install using pip: For a regular installation:
pip install .For an editable installation (useful for development):
pip install -e .
Standalone executables are available for download from the releases page for:
- Linux (x86_64)
- Windows (x86_64)
- macOS (x86_64 and arm64)
No Python installation required for binary distributions.
pyfs-utils relies on PyFilesystem2 (fs) and a range of its extension packages to support various filesystems, including:
fs-s3fs (for S3), fs.dropboxfs, fs.webdavfs, fs.sshfs, fs.youtube, fs.archive, fs.googledrivefs, fs-gcsfs (for Google Cloud Storage), gitfs2, pypifs, fs.proxy, and httpfs.
These will be installed automatically when you install pyfs-utils.
pyfs-utils can be used both as a command-line tool (as utilities are developed) and as a Python library.
The project template includes an example CLI script, fibonacci. While not a filesystem utility itself, it demonstrates how future CLI tools from this package will be structured and invoked.
To enable the example fibonacci script:
- Uncomment the following lines in the
[options.entry_points]section in yoursetup.cfgfile:to:# console_scripts = # fibonacci = pyfs_utils.skeleton:run
console_scripts = fibonacci = pyfs_utils.skeleton:run
- Re-install the package if you made it non-editable, or if you're using an editable install, the change should be picked up.
Once set up, you could run it like this (from your terminal):
fibonacci 10This would output: The 10-th Fibonacci number is 55.
Future filesystem-related CLI tools developed in this package will follow a similar pattern for usage.
You can import and use functions from pyfs-utils in your Python projects. The skeleton.py file provides an example fib function.
from pyfs_utils.skeleton import fib
# Using the example Fibonacci function
number = 10
result = fib(number)
print(f"The {number}-th Fibonacci number is {result}")
# Output: The 10-th Fibonacci number is 55
# Future filesystem utilities will be importable similarly:
# from pyfs_utils.some_utility import useful_fs_function
#
# fs_url = "s3://mybucket/data/"
# items = useful_fs_function(fs_url, pattern="*.txt")
# for item in items:
# print(item)As actual filesystem utilities are added, you'll be able to import them and use them with PyFilesystem2 URLs or FS objects.
This project uses modern Python development practices with automated CI/CD:
# Clone and set up development environment
git clone https://github.com/twardoch/pyfs-utils.git
cd pyfs-utils
make setup # or ./scripts/dev-setup.sh
# Run tests
make test # or ./scripts/test.sh
# Build package
make build # or ./scripts/build.sh
# Create binary
./scripts/create-binary.shmake help- Show all available commandsmake test- Run tests with coveragemake build- Build the packagemake clean- Clean build artifactsmake lint- Run lintingmake format- Format codemake release VERSION=x.y.z- Release a new version
- Semantic Versioning: The project uses git tags for versioning (e.g.,
v1.0.0) - Automated Releases: Push a git tag to trigger automated release via GitHub Actions
- Multi-platform Builds: CI automatically builds for Linux, Windows, and macOS
- Binary Distributions: Standalone executables are created using PyInstaller
- PyPI Publishing: Packages are automatically published to PyPI on release
- Continuous Integration: Tests run on every push/PR across multiple Python versions and OS
- Security Scanning: Automated security checks using bandit and safety
- Code Quality: Linting, formatting, and type checking
- Release Automation: Automatic releases triggered by git tags
- Binary Creation: Standalone executables for easy distribution
For detailed development instructions, see DEVELOPMENT.md.
This section provides more in-depth information about the pyfs-utils project structure, coding conventions, and contribution guidelines.
-
Project Structure:
src/pyfs_utils/: Contains the main source code for the library.__init__.py: Initializes the package and handles versioning usingimportlib.metadata(orimportlib_metadatafor Python < 3.8).skeleton.py: An example module and CLI script template (currently demonstrates a Fibonacci calculator). This file serves as a blueprint for creating new utilities.
tests/: Contains unit tests for the library, written usingpytest.docs/: Contains files for generating project documentation using Sphinx.setup.py&setup.cfg: Standard Python packaging files.setup.cfgis the primary configuration file forsetuptools, defining metadata, dependencies, entry points, and tool configurations (likepytestandflake8).pyproject.toml: Specifies build system requirements, primarily forsetuptools_scmwhich handles versioning from Git tags.
-
Packaging and Dependency Management:
- The project uses
setuptoolsfor packaging. - Dependencies are listed in
setup.cfgunderinstall_requires. - Console script entry points (for CLI tools) are defined in
setup.cfgunder[options.entry_points]. Thefibonacciscript inskeleton.pyis an example of this.
- The project uses
-
Core Logic (Example -
skeleton.py):- The
skeleton.pyfile shows a pattern for creating modules with both a Python API and a command-line interface. - API: Functions intended for programmatic use (e.g.,
fib(n)). - CLI:
parse_args(): Usesargparseto handle command-line arguments.main(): Orchestrates the CLI logic.run(): Acts as the setuptools entry point, callingmain()with system arguments.
- The
We welcome contributions to pyfs-utils! Please follow these guidelines:
-
Coding Style:
- Code should adhere to PEP 8 guidelines.
- We use
flake8for linting. Configuration is insetup.cfg:max_line_length = 88extend_ignore = E203, W503(for compatibility with Black code formatter)
- Consider using a code formatter like Black to automatically format your code.
-
Testing:
- All new features and bug fixes should include comprehensive tests.
- Tests are written using
pytestand are located in thetests/directory. - Run tests using
pytestfrom the project root:pytest
- You can also use
toxto run tests in isolated environments (seetox.ini):tox
- Aim for high test coverage. Check coverage with:
pytest --cov=pyfs_utils --cov-report=term-missing
-
Documentation:
- The project documentation is generated using Sphinx. Source files are in the
docs/directory. - Docstrings should follow a consistent style (e.g., Google style, as supported by Napoleon Sphinx extension).
- To build the documentation locally, ensure you have the documentation dependencies installed (see
docs/requirements.txt) and run:The output will be intox -e docs
docs/_build/html.
- The project documentation is generated using Sphinx. Source files are in the
-
Versioning:
- The project uses
setuptools_scmto manage versioning based on Git tags. The version is automatically derived from the latest tag and commit history. - The
VERSION.txtfile in the repository root is not manually updated; its current content appears to be an artifact of a Git operation and should ideally be removed or .gitignored if not used by a specific workflow. For official versioning, refer to Git tags and the output ofpython setup.py --version.
- The project uses
-
Contributing Workflow:
- Fork the repository on GitHub.
- Create a new branch for your feature or bug fix:
git checkout -b feature/your-feature-nameorbugfix/issue-number. - Make your changes, ensuring you add tests and update documentation as needed.
- Run tests and linters locally to ensure everything passes.
- Commit your changes with clear, descriptive commit messages.
- Push your branch to your fork:
git push origin feature/your-feature-name. - Open a Pull Request (PR) against the
mainbranch of thetwardoch/pyfs-utilsrepository. - Clearly describe your changes in the PR.
-
Issue Tracking:
- Use the GitHub Issues tracker for reporting bugs or proposing new features.
-
License:
- The project is licensed under the CC0-1.0 Universal license. See
LICENSE.txt. By contributing, you agree that your contributions will be licensed under the same terms.
- The project is licensed under the CC0-1.0 Universal license. See
-
Author Information:
- Project authors and contributors are listed in
AUTHORS.md. - A
CHANGELOG.mdis maintained to track notable changes for each version.
- Project authors and contributors are listed in
-
AGENTS.md/CLAUDE.md:- The user prompt mentioned consulting
CLAUDE.mdfor details. This file was not found in the repository. If specific instructions for AI agents are to be provided, they should be added to anAGENTS.mdfile in the repository root.
- The user prompt mentioned consulting
This project has been set up using PyScaffold 4.0.2. For details and usage information on PyScaffold see https://pyscaffold.org/.