Skip to content

Import order causes warnings when working with epicscorelibs and softioc #23

@MJGaughran

Description

@MJGaughran

As epicscorelibs maintains its own libca, it provides the option to set the 'CATOOLS_LIBCA_PATH' before using cothread. This can be found here. This mechanism does not appear to be ideal.

For example, softioc uses this mechanism here. The problem comes when another program attempts to use both softioc and cothread itself. A simple program such as the following:

#! /usr/bin/env python3

import cothread.catools
import softioc

will result in the following error (and potentially problematic behaviour):

$ ./test_imports.py 
/path/to/pipenv/environment/lib/python3.7/site-packages/epicscorelibs/path/cothread.py:18: UserWarning: epicscorelibs.path.cothread must be imported before cothread.catools to have effect
  warnings.warn("epicscorelibs.path.cothread must be imported before cothread.catools to have effect")

There are two problems:

  1. It is not immediately clear what is causing the error
  2. If using standard tools such as isort, you need to manually force a particular order of imports to avoid this error. You need to isort:skip multiple lines of code

I am not sure why cothread does not use epicscorelibs by default. Would it be possible to implement this?

Alternatively, some kind of conditional import of epicscorelibs could be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions