Metadata-Version: 2.4
Name: fit
Version: 0.5.1
Summary: FIT file I/O for Python
Author-email: Alex Rembish <alex@rembish.org>
License-Expression: BSD-3-Clause
Project-URL: Homepage, https://github.com/rembish/fit
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black>=24; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: mypy>=1.10; extra == "dev"
Requires-Dist: pre-commit>=3; extra == "dev"
Requires-Dist: tox>=4; extra == "dev"
Requires-Dist: build>=1; extra == "dev"
Requires-Dist: twine>=6; extra == "dev"
Dynamic: license-file

# fit

Read and write Garmin FIT (Flexible and Interoperable Data Transfer) files from Python.

FIT is a binary format designed for sport, fitness, and health devices. It is compact,
interoperable, and extensible — any FIT-compliant device can interpret a FIT file from
any other FIT-compliant device.

## Installation

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
```

Or use the Makefile:

```bash
make install
```

## Usage

### Reading a FIT file

```python
from fit import FitFile

with FitFile.open("path/to/activity.fit") as f:
    for message in f:
        print(message)
```

### Copying a FIT file

```python
from fit import FitFile

with FitFile.open("path/to/source.fit") as src:
    with FitFile.open("path/to/copy.fit", mode="w") as dst:
        dst.copy(src)
```

### Creating a new FIT file

```python
from fit.files.activity import ActivityFile
from fit.messages.common import FileCreator

fnew = ActivityFile.create("path/to/new.fit")
fnew.append(FileCreator(software_version=100))
fnew.write()
fnew.close()
```

### Reading from a stream

```python
from io import BytesIO
from fit import FitFile

data = open("path/to/activity.fit", "rb").read()
with FitFile.open(BytesIO(data)) as f:
    for message in f:
        print(message)
```

## Development

```bash
make install     # create .venv and install all dev dependencies
make format      # run black
make lint        # run ruff
make typecheck   # run mypy
make test        # run pytest with coverage
make tox         # run tests across Python 3.9, 3.10, 3.12
make clean       # remove build artefacts and the virtualenv
```

## License

BSD 3-Clause — see `LICENSE`.
