Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

ChrisRackauckas-Claude
Copy link

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Oct 10, 2025

Summary

This PR addresses the implementation approach in #161 with a cleaner solution using lazy imports instead of dummy functions.

Problem with PR #161's approach

PR #161 defines a dummy function at import time:

try:
    from jill.install import install_julia
except ModuleNotFoundError:
    def install_julia():
        raise RuntimeError("Could not install Julia as the Jill module was not found.")

This approach:

  • Creates a confusing placeholder function that only exists to raise an error
  • Delays error detection until the function is actually called
  • Makes the code harder to understand

Better Solution: Lazy Import

Move the jill import to where it's actually used:

def _ensure_julia_installed():
    if not _find_julia():
        print("No Julia version found. Installing Julia.")
        try:
            from jill.install import install_julia
        except ImportError:
            raise RuntimeError(
                "Julia is not installed and the 'jill' package is not available. "
                "Please install Julia manually or install jill: pip install jill"
            )
        install_julia()
        # ...

Benefits

  1. Cleaner code: No dummy functions that just raise errors
  2. Better error messages: Clear, immediate error messages when there's a problem
  3. Lazy loading: Only imports jill when Julia installation is actually needed
  4. Same functionality: Jill remains a default dependency, no change in user experience

Changes

  • diffeqpy/__init__.py:
    • Remove top-level from jill.install import install_julia
    • Add lazy import with proper error handling in _ensure_julia_installed() and install() functions
  • setup.py: No changes (jill remains a required dependency)

Testing

  • Syntax validation passes
  • Same functionality as before, just cleaner implementation

🤖 Generated with Claude Code

ChrisRackauckas and others added 3 commits October 10, 2025 09:39
Previously, jill was a hard dependency that was imported at module load time.
This meant diffeqpy would fail to import if jill was not installed, even when
Julia was already present on the system.

Changes:
- Remove top-level import of jill.install
- Lazy import jill only when Julia needs to be installed
- Move jill to optional extras_require in setup.py
- Provide clear error message when jill is needed but not installed

This allows users with Julia already installed to use diffeqpy without
installing jill, while still providing automatic Julia installation for
users who want it via: pip install diffeqpy[julia-install]

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
setup.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.