Show HN: Wetlands – a lightweight Python library for managing Conda environments

https://news.ycombinator.com/rss Hits: 6
Summary

Wetlands Wetlands is a lightweight Python library for managing Conda environments. Wetlands can create Conda environments on demand, install dependencies, and execute arbitrary code within them. This makes it easy to build plugin systems or integrate external modules into an application without dependency conflicts, as each environment remains isolated. The name Wetlands comes from the tropical environments where anacondas thrive. Documentation: https://arthursw.github.io/wetlands/latest/ Source Code: https://github.com/arthursw/wetlands/ ✨ Features Automatic Environment Management: Create and configure environments on demand. Dependency Isolation: Install dependencies without conflicts. Embedded Execution: Run Python functions inside isolated environments. Pixi & Micromamba: Wetlands uses either a self-contained pixi or micromamba for fast and lightweight Conda environment handling. 📦 Installation To install Wetlands, simply run: 🚀 Usage Minimal example Here is a minimal example usage: from wetlands.environment_manager import EnvironmentManager # Initialize the environment manager environmentManager = EnvironmentManager("pixi/") # Create and launch a Conda environment named "numpy_env" env = environmentManager.create("numpy_env", {"pip": ["numpy==2.2.4"]}) env.launch() # Import minimal_module in the environment (see minimal_module.py below) minimal_module = env.importModule("minimal_module.py") # minimal_module is a proxy to minimal_module.py in the environment array = [1, 2, 3] # Execute the sum() function in the numpy_env environment and get the result result = minimal_module.sum(array) print(f"Sum of {array} is {result}.") # Clean up and exit the environment env.exit() With minimal_module.py: def sum(x): import numpy as np # type: ignore return int(np.sum(x)) General usage Wetlands allows you to interact with isolated Conda environments in two main ways: Simplified Execution (env.importModule / env.execute): Wetlands manages the communication details, providing ...

First seen: 2025-05-28 16:01

Last seen: 2025-05-28 21:02