Skip to content

Conversation

@winterberryhypernova
Copy link

Hi,
This is an addition based on the documentation about loading collections.

NOTE : I'm using Invoke on Windows 11.

Currently, when using invoke --list command, only current directory and its parents are checked when trying to find tasks package or module. Sys.path is never checked, seemingly contradicting the docs.

This PR aims to correct this by also checking paths in sys.path if cwd search failed. This allows the use of PYTHONPATH env variable and other package managers like REZ and avoids writing the root path for tasks in every invoke call.
Also, as the cwd/root is checked first and will return the results if tasks are found there, this shouldn't break existing setups.

There is also a small fix to avoid empty paths ("") being passed to os.path()

@winterberryhypernova
Copy link
Author

One test should be edited to support changes :

class load_collection:
    def complains_when_default_collection_not_found(self):
        # NOTE: assumes system under test has no tasks.py in root. Meh.
        with cd(ROOT):
           expect("-l", err="Can't find any collection named 'tasks'!\n")

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.

1 participant