Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ pioarduino provides native support for multiple filesystem options, allowing you
- **SPIFFS** - Simple legacy filesystem. While still functional, LittleFS is recommended for new projects due to better wear-leveling and reliability.
- **FatFS** - Industry-standard FAT filesystem with broad compatibility across platforms and operating systems.

### FatFS Integration

FatFS support has been fully integrated as a Python module, providing the same seamless experience as LittleFS. Configuration is straightforward - simply specify your preferred filesystem in your project settings: See [FATFS_INTEGRATION.md](FATFS_INTEGRATION.md) for detailed documentation.

**Quick Start:**

```ini
Expand Down
21 changes: 21 additions & 0 deletions builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@
# Import GDB_TOOL_PACKAGES from penv_setup (already loaded into sys.modules by platform.py)
from penv_setup import GDB_TOOL_PACKAGES

# Automatically register pio-lock targets if custom_pio_lock is enabled
env_name = env.subst("$PIOENV")
if projectconfig.get(f"env:{env_name}", "custom_pio_lock", default="false").lower() in ("true", "yes", "1"):
try:
# Try to import pio_lock module from penv
import pio_lock
# Register custom targets with SCons
pio_lock.register_pio_targets(env)
except ImportError as exc:
sys.stderr.write(
f"Warning: custom_pio_lock=true but pio_lock could not be imported "
f"({exc}). Lock targets (lock-capture/lock-restore/lock-check) "
f"will not be available.\n"
)
except AttributeError as exc:
sys.stderr.write(
f"Warning: pio_lock is installed but does not expose "
f"register_pio_targets ({exc}). Update pio-lock to a compatible "
f"version.\n"
)

# Load board configuration and determine MCU architecture
board = env.BoardConfig()
board_id = env.subst("$BOARD")
Expand Down
65 changes: 53 additions & 12 deletions builder/penv_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,33 +329,40 @@ def get_packages_to_install(deps, installed_packages):
"""
Generator for Python packages that need to be installed.
Compares package names case-insensitively.

Handles both semantic version specs and direct URLs (git+, http, etc.).

Args:
deps (dict): Dictionary of package names and version specifications
installed_packages (dict): Dictionary of currently installed packages (keys should be lowercase)

Yields:
str: Package name that needs to be installed
"""
for package, spec in deps.items():
name = package.lower()
if name not in installed_packages:
yield package
elif spec.startswith(('http://', 'https://', 'git+', 'file://')):
# URL/git/file specs cannot be parsed by semantic_version.SimpleSpec.
# Treat the pinned URL as already satisfied if present in the env;
# use `uv pip install --upgrade` separately to refresh on demand.
continue
else:
version_spec = semantic_version.SimpleSpec(spec)
if not version_spec.match(installed_packages[name]):
yield package


def install_python_deps(python_exe, external_uv_executable, uv_cache_dir=None):
def install_python_deps(python_exe, external_uv_executable, uv_cache_dir=None, additional_deps=None):
"""
Ensure uv package manager is available in penv and install required Python dependencies.

Args:
python_exe: Path to Python executable in the penv
external_uv_executable: Path to external uv executable used to create the penv (can be None)
uv_cache_dir: Optional path to uv cache directory

additional_deps: Optional dictionary of additional package names and version specs to install

Returns:
bool: True if successful, False otherwise
"""
Expand Down Expand Up @@ -471,23 +478,29 @@ def _get_installed_uv_packages():
return result

installed_packages = _get_installed_uv_packages()
packages_to_install = list(get_packages_to_install(python_deps, installed_packages))


# Combine core and additional dependencies
all_deps = dict(python_deps)
if additional_deps:
all_deps.update(additional_deps)

packages_to_install = list(get_packages_to_install(all_deps, installed_packages))

if packages_to_install:
packages_list = []
for p in packages_to_install:
spec = python_deps[p]
spec = all_deps[p]
if spec.startswith(('http://', 'https://', 'git+', 'file://')):
packages_list.append(spec)
else:
packages_list.append(f"{p}{spec}")

cmd = [
penv_uv_executable, "pip", "install",
f"--python={python_exe}",
"--quiet", "--upgrade"
] + packages_list

try:
subprocess.check_call(
cmd,
Expand All @@ -496,7 +509,7 @@ def _get_installed_uv_packages():
timeout=300,
env=uv_env
)

except subprocess.CalledProcessError as e:
print(f"Error: Failed to install Python dependencies (exit code: {e.returncode})")
return False
Expand All @@ -509,7 +522,7 @@ def _get_installed_uv_packages():
except Exception as e:
print(f"Error installing Python dependencies: {e}")
return False

return True


Expand Down Expand Up @@ -806,6 +819,34 @@ def _install_esptool_from_tl_install(platform, python_exe, uv_executable, uv_cac
# Don't exit - esptool installation is not critical for penv setup


def install_pio_lock(platform, uv_executable, penv_executable, uv_cache_dir=None):
"""
Install pio-lock into the platform's Python virtual environment.

pio-lock provides dependency lockfile functionality for PlatformIO,
enabling reproducible builds for embedded projects.

Args:
platform: PlatformIO platform object
uv_executable (str): Path to uv executable
penv_executable (str): Path to penv Python executable
uv_cache_dir: Optional path to uv cache directory
"""
if not has_network:
return

# Define pio-lock as additional dependency
# todo: Replace with official pio-lock package when available
# For now, use the git source from m-mcgowan without version and install check
pio_lock_dep = {
"pio-lock": "git+https://github.com/m-mcgowan/pio-lock.git@v0.2.0"
}

# Use the centralized installer
if not install_python_deps(penv_executable, uv_executable, uv_cache_dir, pio_lock_dep):
print("Warning: Failed to install pio-lock")


def install_freertos_gdb(platform, uv_executable, penv_executable, uv_cache_dir=None):
"""
Install freertos-gdb into each GDB tool's embedded Python site (share/gdb/python/).
Expand Down
File renamed without changes.
File renamed without changes.
Loading