Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not run env check on lore import - only on cli invocation #173

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
41 changes: 21 additions & 20 deletions lore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,29 @@ def banner():
)


lore_no_env = False
if hasattr(sys, 'lore_no_env'):
lore_no_env = sys.lore_no_env
def env_check():
lore_no_env = False
if hasattr(sys, 'lore_no_env'):
lore_no_env = sys.lore_no_env


no_env_commands = ['--version', 'install', 'init', 'server']
if len(sys.argv) > 1 and os.path.basename(sys.argv[0]) in ['lore', 'lore.exe'] and sys.argv[1] in no_env_commands:
lore_no_env = True
no_env_commands = ['--version', 'install', 'init', 'server']
if len(sys.argv) > 1 and os.path.basename(sys.argv[0]) in ['lore', 'lore.exe'] and sys.argv[1] in no_env_commands:
lore_no_env = True

if '--no-env' in sys.argv:
lore_no_env = True

if not lore_no_env:
# everyone else gets validated and launched on import
env.validate()
env.launch()

if env.launched():
print(banner())
logger.info(banner())
logger.debug('python environment: %s' % env.PREFIX)
if '--no-env' in sys.argv:
lore_no_env = True

if not lore_no_env:
with timer('check requirements', logging.DEBUG):
env.check_requirements()
# everyone else gets validated and launched on import
env.validate()
env.launch()

if env.launched():
print(banner())
logger.info(banner())
logger.debug('python environment: %s' % env.PREFIX)

if not lore_no_env:
with timer('check requirements', logging.DEBUG):
env.check_requirements()
1 change: 1 addition & 0 deletions lore/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,4 +1292,5 @@ def pip_install(path, args):


if __name__ == '__main__':
env_check()
main()