diff --git a/CHANGELOG.md b/CHANGELOG.md index a0cb8990..2984fa03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed +- Python virtualenvs are now detected in Windows environments, and are automatically + excluded from the uploaded bundle. + ### Added - Add `--disable-env-management`, `--disable-env-management-py` and `--disable-env-management-r` flags for all content types diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index d48693c6..074427fb 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -815,8 +815,13 @@ def create_glob_set(directory, excludes): def is_environment_dir(directory): + """Detect whether `directory` is a virtualenv""" + + # A virtualenv will have Python at ./bin/python python_path = join(directory, "bin", "python") - return exists(python_path) + # But on Windows, it's at Scripts\Python.exe + win_path = join(directory, "Scripts", "Python.exe") + return exists(python_path) or exists(win_path) def list_environment_dirs(directory): @@ -859,7 +864,7 @@ def make_api_manifest( :return: the manifest and a list of the files involved. """ if is_environment_dir(directory): - excludes = list(excludes or []) + ["bin/", "lib/"] + excludes = list(excludes or []) + ["bin/", "lib/", "Lib/", "Scripts/", "Include/"] extra_files = extra_files or [] skip = [environment.filename, "manifest.json"] @@ -1483,7 +1488,7 @@ def _warn_if_environment_directory(directory): if is_environment_dir(directory): click.secho( " Warning: The deployment directory appears to be a python virtual environment.\n" - " Excluding the 'bin' and 'lib' directories.", + " Python libraries and binaries will be excluded from the deployment.", fg="yellow", ) diff --git a/rsconnect/main.py b/rsconnect/main.py index c9b6e23c..5af3128f 100644 --- a/rsconnect/main.py +++ b/rsconnect/main.py @@ -761,7 +761,7 @@ def _warn_if_environment_directory(directory): if is_environment_dir(directory): click.secho( " Warning: The deployment directory appears to be a python virtual environment.\n" - " Excluding the 'bin' and 'lib' directories.", + " Python libraries and binaries will be excluded from the deployment.", fg="yellow", )