# When a CircuitPython Module Becomes a Package: Fixing Circup Updates

*When an installed CircuitPython library changes from a single module file into a package directory, Circup has to replace the old file with the new package.*

Circup installs and updates libraries from the CircuitPython bundle. A library can be distributed as one module, such as `foo.py`, or as a package directory containing `__init__.py` and related modules.

That creates an update edge case: a library that was installed as a single file can later be reorganized as a package. The update needs to remove the old file and copy the package directory into place.

![Figure 1. Circup replaces an installed single-file library module with the package directory from the CircuitPython bundle.](https://cdn.hashnode.com/uploads/covers/6b0a762e1551beb5c5821976/3ace7a53-bc9f-4389-800f-68995b863c6f.png align="center")

*Figure 1. File-to-package transition handled by Circup: the prior module file is replaced by the library's package directory.*

## The file-to-package transition

A simplified example is:

```text
Before: adafruit_emc2101.py
After:  adafruit_emc2101/
```

The names still refer to the same library, but the filesystem object has changed from a file to a directory. An updater that keeps resolving the old bundle path can try to handle the package as if it were still a file.

## What the pull request changes

[Adafruit Circup PR #290](https://github.com/adafruit/circup/pull/290) updates path resolution so Circup can install a package after the old single-file module is removed. The change covers both the local disk backend and the Web Workflow backend.

The requested update can still use Circup’s existing command:

```console
circup install --update adafruit_emc2101
```

The fix is intended to handle the transition without changing how users choose or install libraries.

## Regression coverage

The review discussion asked for tests to use a real package from the bundle rather than a mocked empty module. The revised tests use `adafruit_emc2101`, create the old single-file form on the test device, run the update, and check that the old file is replaced by the package. The disk and Web Workflow paths are both covered.

The PR description reports four focused Windows regression cases passing, 68 passing tests, and five failures in unchanged tests during the full Windows suite. It lists Linux CI as pending. These results come from the PR description and were not independently rerun for this article.

## Review status

As of 29 November 2026, PR #290 remains open and unmerged. The revised tests use the real `adafruit_emc2101` package to cover both disk and Web Workflow paths, as requested in review. The current PR description lists Linux CI as pending. This article describes work under review, not an accepted or released change. The issue linked from the pull request is [#100](https://github.com/adafruit/circup/issues/100).

## References

- [Adafruit Circup PR #290: Handle updates when a module becomes a package](https://github.com/adafruit/circup/pull/290)
- [Circup issue #100](https://github.com/adafruit/circup/issues/100)
