From fa491155505c4a087b98671943c8547e2fcfd5de Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Wed, 30 Aug 2023 13:44:11 -0400 Subject: [PATCH 1/3] fix: detect virtualenvs on Windows --- rsconnect/bundle.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index d48693c6..e47ae53f 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): From bcd369342678726a51fff322771b803195c13bd6 Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Thu, 31 Aug 2023 11:02:17 -0400 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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 From f18b6d727f42c57b1595185aaecc4465f633a789 Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Tue, 5 Sep 2023 15:17:38 -0400 Subject: [PATCH 3/3] Fix exclusions when deployment dir is a Windows virtualenv --- rsconnect/bundle.py | 4 ++-- rsconnect/main.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rsconnect/bundle.py b/rsconnect/bundle.py index e47ae53f..074427fb 100644 --- a/rsconnect/bundle.py +++ b/rsconnect/bundle.py @@ -864,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"] @@ -1488,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", )