3939)
4040
4141from . import api
42- from .bundle import make_manifest_bundle
42+ from .bundle import is_environment_dir , make_manifest_bundle
4343from .metadata import ServerStore , AppStore
4444from .models import AppModes
4545
@@ -403,6 +403,20 @@ def _warn_if_no_requirements_file(directory):
403403 )
404404
405405
406+ def _warn_if_environment_directory (directory ):
407+ """
408+ Issue a warning if the deployment directory is itself a virtualenv (yikes!).
409+
410+ :param directory: the directory to check in.
411+ """
412+ if is_environment_dir (directory ):
413+ click .secho (
414+ " Warning: The deployment directory appears to be a python virtual environment.\n "
415+ " Excluding the 'bin' and 'lib' directories." ,
416+ fg = "yellow" ,
417+ )
418+
419+
406420def _warn_on_ignored_conda_env (environment ):
407421 """
408422 Checks for a discovered Conda environment and produces a warning that it will be ignored when
@@ -575,8 +589,10 @@ def deploy_notebook(
575589
576590 click .secho (' Deploying %s to server "%s"' % (file , connect_server .url ))
577591
578- _warn_on_ignored_manifest (dirname (file ))
579- _warn_if_no_requirements_file (dirname (file ))
592+ base_dir = dirname (file )
593+ _warn_on_ignored_manifest (base_dir )
594+ _warn_if_no_requirements_file (base_dir )
595+ _warn_if_environment_directory (base_dir )
580596
581597 with cli_feedback ("Inspecting Python environment" ):
582598 python , environment = get_python_env_info (file , python , conda , force_generate )
@@ -588,7 +604,7 @@ def deploy_notebook(
588604 _warn_on_ignored_conda_env (environment )
589605
590606 if force_generate :
591- _warn_on_ignored_requirements (dirname ( file ) , environment .filename )
607+ _warn_on_ignored_requirements (base_dir , environment .filename )
592608
593609 with cli_feedback ("Creating deployment bundle" ):
594610 bundle = create_notebook_deployment_bundle (
@@ -881,6 +897,7 @@ def _deploy_by_framework(
881897
882898 _warn_on_ignored_manifest (directory )
883899 _warn_if_no_requirements_file (directory )
900+ _warn_if_environment_directory (directory )
884901
885902 with cli_feedback ("Inspecting Python environment" ):
886903 _ , environment = get_python_env_info (module_file , python , conda , force_generate )
0 commit comments