Skip to content

[EHN] _soft_import should accept libraries that don't have __version__ #13863

Closed

Description

@bruAristimunha

Describe the new feature or enhancement

package.__version__ is really a standard parameter, but time to time, I found some libraries that don't have version in version, but inside some package, versioning or other space.

I think we should be more flexible about this.

Describe your proposed implementation

make _soft_import, accept some extra parameter check_version, or something like this.

Describe possible alternatives

Don't implement this.

Additional context

No response

Activity

  1. larsoner commented on Apr 23, 2026

    @larsoner
    Member

    Sure. I don't think we need an extra parameter or anything, just use the info if available and don't otherwise. (Of course if min_version is supplied / not-None, the __version__ does need to be present...) So I think we can just refactor to be smarter about handling the missing-__version__ case

  2. drammock commented on Apr 28, 2026

    @drammock
    Member

    before we merge #13870, I'd like to know what packages are actually causing problems here. _soft_import is an internal, private function, and AFAICT none of the packages we use it for internally are lacking __version__ --- if they were, the error you mention should cause a test to fail! --- and if I'm wrong about that, please tell us which ones are problematic so we can improve the tests.

    If the request is for compatibility with other packages that we don't use internally, I'd actually lean toward wontfix here, except for the fact that @baris-talar has already done the work so I'd feel a bit bad for wasting their time.

  3. bruAristimunha commented on Apr 28, 2026

    @bruAristimunha
    ContributorAuthor

    I think @larsoner just saw the case with the rsa library, but I already pass some situations where I could not use. I will get my notes tomorrow about this.

  4. baris-talar commented on Apr 29, 2026

    @baris-talar
    Contributor

    Thanks for the clarification. I checked the current _soft_import call sites and you’re right that all existing dependencies expose version, so this isn’t affecting anything in MNE at the moment.

    The change was mainly defensive, to handle a potential edge case where a future optional dependency (or external use of _soft_import) doesn’t expose version at the top level. That said, I understand it may not be worth adding without a concrete example.

    Happy to leave this as is or close it if you prefer. Also, if there are any issues you’d recommend for new contributors, I’d be glad to take a look.

  5. bruAristimunha commented on May 1, 2026

    @bruAristimunha
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions