Skip to content

Commit

Permalink
Refactor dependencies and reorganize project structure (#100)
Browse files Browse the repository at this point in the history
* refactor: remove schema dep

* refactor: remove pandas performance deps

Seems a better policy to allow users to decide whether or not to use pandas[performance], especially since it can introduce issues with numba, llvmlite as compiled packages.

* chore: reorganise pyproject and use uv's new dev groups

* chore: check optional installs on testpypi

* bump version v0.7.5 -> v0.7.6dev0

* fix: improve optional dependency handling

- Implement lazy loading for optional components via __getattr__
- Centralize optional dependency configuration in _optionals.py
- Add explicit __all__ list for better IDE support
- Remove dynamic __all__ manipulation for more reliable behavior
- Maintain helpful error messages for missing dependencies

This change improves the developer and user experience when working with
optional features while maintaining backwards compatibility.

* refactor: relative imports

* refactor: reduce dependencies

* fix: opt dep tests

* bump version v0.7.6dev0 -> v0.7.6dev1

* fix: fixed test collection

* bump version v0.7.6dev1 -> v0.7.6dev2

### Improvements to optional dependencies handling:

* Centralized optional dependency configuration in `_optionals.py` for better maintainability. (`CONTRIBUTING.md` [[1]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055R85)], [[2]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L93-R99)], [[3]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L108-R125)], [[4]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L130-R141)], [[5]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L145-R272)])
* Improved error messages and IDE support for optional dependencies. (`CHANGELOG.md` [[CHANGELOG.mdR8-R59](diffhunk://#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edR8-R59)])

### Updates to testing and CI workflows:

* Added new workflows for tagged releases and testing tagged releases, including installation from TestPyPI and running tests. (`.github/workflows/test-tag-release.yml` [[.github/workflows/test-tag-release.ymlL107-R132](diffhunk://#diff-11b7dedbf7b09ab5a0bd90aa70d8a2eda1918dab64a511c82104706cfa09f3b7L107-R132)])
* Updated `conftest.py` to handle dependency checks in a more modular way, caching results for better performance. (`conftest.py` [[1]](diffhunk://#diff-a31c7ed5d35f5ed8233994868c54d625b18e6bacb6794344c4531e62bd9dde59L7-R39)], [[2]](diffhunk://#diff-a31c7ed5d35f5ed8233994868c54d625b18e6bacb6794344c4531e62bd9dde59L54-R65)], [[3]](diffhunk://#diff-a31c7ed5d35f5ed8233994868c54d625b18e6bacb6794344c4531e62bd9dde59L89-R88)])
* Simplified the `pyproject.toml` by consolidating dependencies and updating test configurations. (`pyproject.toml` [[1]](diffhunk://#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L3-R15)], [[2]](diffhunk://#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L37-R57)], [[3]](diffhunk://#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711L71-R66)])

### Documentation updates:

* Added detailed developer notes and guidelines for adding new optional features and handling dependencies. (`CONTRIBUTING.md` [[1]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055R85)], [[2]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L93-R99)], [[3]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L108-R125)], [[4]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L130-R141)], [[5]](diffhunk://#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055L145-R272)])
* Documented the new optional dependencies system and provided examples for both success and failure cases. (`CHANGELOG.md` [[CHANGELOG.mdR8-R59](diffhunk://#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4edR8-R59)])
  • Loading branch information
MitchellAcoustics authored Nov 6, 2024
1 parent 33d9bb3 commit 5b5db3a
Show file tree
Hide file tree
Showing 12 changed files with 387 additions and 431 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/test-tag-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,29 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install package from TestPyPI
- name: Install soundscapy from TestPyPI
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "soundscapy==${{ needs.details.outputs.version_str }}"
- run: python -c "import soundscapy; print(soundscapy.__version__)"
- run: python -c "import soundscapy; print(soundscapy.__version__)"

- name: Install soundscapy[audio] from TestPyPI
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "soundscapy[audio]==${{ needs.details.outputs.version_str }}"
- run: python -c "import soundscapy; print(soundscapy.__version__); from soundscapy import Binaural"

- name: Install soundscapy[all] from TestPyPI
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 3
retry_wait_seconds: 30
command: python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "soundscapy[all]==${{ needs.details.outputs.version_str }}"
- run: python -c "import soundscapy; print(soundscapy.__version__); from soundscapy import Binaural"
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,58 @@ All notable changes to the Soundscapy project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.6rc0] - 2024-11-06

### Changed

- Improved handling of optional dependencies to provide better error messages and IDE support
- Audio components (like `Binaural`) can now be imported directly from the top-level package
(`from soundscapy import Binaural`) while maintaining helpful error messages when
dependencies are missing
- Centralized optional dependency configuration in `_optionals.py` for better maintainability

### Developer Notes

- No changes required to existing code using audio components
- The new system provides better IDE completion support while maintaining the same runtime behavior
- Optional components can still be imported from their original location
(`from soundscapy.audio import Binaural`) or from the top level
(`from soundscapy import Binaural`)

## [0.7.5]

### Added

#### Support for Optional Dependencies

Soundscapy splits its functionality into optional modules to reduce the number of dependencies required for basic functionality. By default, Soundscapy includes the survey data processing and plotting functionality.

If you would like to use the binaural audio processing and psychoacoustics functionality, you will need to install the optional `audio` dependency:

```bash
pip install soundscapy[audio]
```

To install all optional dependencies, use the following command:

```bash
pip install soundscapy[all]
```

### Developer notes

#### Dev Container Configuration

* Added a new `devcontainer.json` file to configure the development container with specific features and VSCode extensions. (`.devcontainer/devcontainer.json` [.devcontainer/devcontainer.jsonR1-R69](diffhunk://#diff-24ad71c8613ddcf6fd23818cb3bb477a1fb6d83af4550b0bad43099813088686R1-R69))
* Updated `.dockerignore` to exclude the virtual environment directory. (`.devcontainer/.dockerignore` [.devcontainer/.dockerignoreR1](diffhunk://#diff-7691e653179b9ed2292151d962426f76e6f5378e4989e741859bdfcbcef16b97R1))

#### GitHub Workflows:

* Removed old CI, release, and test-release workflows. (`.github/workflows/ci.yml` [[1]](diffhunk://#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fL1-L40) `.github/workflows/release.yml` [[2]](diffhunk://#diff-87db21a973eed4fef5f32b267aa60fcee5cbdf03c67fafdc2a9b553bb0b15f34L1-L33) `.github/workflows/test-release.yml` [[3]](diffhunk://#diff-191bb5b4e97db48c9d0bdb945dd00e17b53249422f60a642e9e8d73250b5913aL1-L53)
* Added a new workflow for tagged releases to automate the release process, including building and publishing to PyPI and TestPyPI. (`.github/workflows/tag-release.yml` [.github/workflows/tag-release.ymlR1-R138](diffhunk://#diff-21e1251c1676ed10064d2d98ab1a8f6471a9718058bd316970abe934169f2b60R1-R138))
* Added a new workflow for testing tagged releases, including installation from TestPyPI and running tests. (`.github/workflows/test-tag-release.yml` [.github/workflows/test-tag-release.ymlR1-R114](diffhunk://#diff-11b7dedbf7b09ab5a0bd90aa70d8a2eda1918dab64a511c82104706cfa09f3b7R1-R114))
* Added new workflows for running tests on the main codebase and tutorial notebooks. (`.github/workflows/test.yml` [[1]](diffhunk://#diff-faff1af3d8ff408964a57b2e475f69a6b7c7b71c9978cccc8f471798caac2c88R1-R52) `.github/workflows/test-tutorials.yml` [[2]](diffhunk://#diff-01bd86ab14c3e8d7d1382e5ed2172404eb7d3c46bbffeffe09fc11431885e2a0R1-R42)

## [0.7.3]

### Improved
Expand Down
Loading

0 comments on commit 5b5db3a

Please sign in to comment.