Skip to content

Commit eea813e

Browse files
authored
Merge pull request #472 from rstudio/ignore-win-env
fix: detect virtualenvs on Windows
2 parents c410de9 + f18b6d7 commit eea813e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
### Fixed
10+
- Python virtualenvs are now detected in Windows environments, and are automatically
11+
excluded from the uploaded bundle.
12+
913
### Added
1014

1115
- Add `--disable-env-management`, `--disable-env-management-py` and `--disable-env-management-r` flags for all content types

rsconnect/bundle.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,13 @@ def create_glob_set(directory, excludes):
815815

816816

817817
def is_environment_dir(directory):
818+
"""Detect whether `directory` is a virtualenv"""
819+
820+
# A virtualenv will have Python at ./bin/python
818821
python_path = join(directory, "bin", "python")
819-
return exists(python_path)
822+
# But on Windows, it's at Scripts\Python.exe
823+
win_path = join(directory, "Scripts", "Python.exe")
824+
return exists(python_path) or exists(win_path)
820825

821826

822827
def list_environment_dirs(directory):
@@ -859,7 +864,7 @@ def make_api_manifest(
859864
:return: the manifest and a list of the files involved.
860865
"""
861866
if is_environment_dir(directory):
862-
excludes = list(excludes or []) + ["bin/", "lib/"]
867+
excludes = list(excludes or []) + ["bin/", "lib/", "Lib/", "Scripts/", "Include/"]
863868

864869
extra_files = extra_files or []
865870
skip = [environment.filename, "manifest.json"]
@@ -1483,7 +1488,7 @@ def _warn_if_environment_directory(directory):
14831488
if is_environment_dir(directory):
14841489
click.secho(
14851490
" Warning: The deployment directory appears to be a python virtual environment.\n"
1486-
" Excluding the 'bin' and 'lib' directories.",
1491+
" Python libraries and binaries will be excluded from the deployment.",
14871492
fg="yellow",
14881493
)
14891494

rsconnect/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def _warn_if_environment_directory(directory):
761761
if is_environment_dir(directory):
762762
click.secho(
763763
" Warning: The deployment directory appears to be a python virtual environment.\n"
764-
" Excluding the 'bin' and 'lib' directories.",
764+
" Python libraries and binaries will be excluded from the deployment.",
765765
fg="yellow",
766766
)
767767

0 commit comments

Comments
 (0)