Skip to content

Commit 77fa8e2

Browse files
committed
Fixed virtualenv and pip references to support Windows
1 parent cc65271 commit 77fa8e2

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lambda_uploader/package.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import shutil
1717
import zipfile
1818
import logging
19+
import sys
1920

2021
from subprocess import Popen, PIPE
2122

@@ -53,13 +54,13 @@ def build_package(path, requirements):
5354
cmd = None
5455
if requirements:
5556
LOG.debug("Installing requirements found %s in config" % requirements)
56-
cmd = [os.path.join(pkg_venv, 'bin/pip'),
57+
cmd = [os.path.join(pkg_venv, _venv_pip()),
5758
'install', " ".join(requirements)]
5859

5960
elif os.path.isfile("requirements.txt"):
6061
# Pip install
6162
LOG.debug("Installing requirements from requirements.txt file")
62-
cmd = [os.path.join(pkg_venv, 'bin/pip'),
63+
cmd = [os.path.join(pkg_venv, _venv_pip()),
6364
"install", "-r", "requirements.txt"]
6465

6566
if cmd is not None:
@@ -74,12 +75,24 @@ def build_package(path, requirements):
7475

7576
# Copy site packages into package base
7677
LOG.info('Copying site packages')
77-
shutil.copytree(os.path.join(pkg_venv, 'lib/python2.7/site-packages'),
78+
79+
site_packages = 'lib/python2.7/site-packages'
80+
if sys.platform == 'win32' or sys.platform == 'cygwin':
81+
site_packages = 'lib\\site-packages'
82+
83+
shutil.copytree(os.path.join(pkg_venv, site_packages),
7884
package)
7985
_copy_src_files(path, package)
8086
_create_zip(package, path)
8187

8288

89+
def _venv_pip():
90+
if sys.platform == 'win32' or sys.platform == 'cygwin':
91+
return 'Scripts\pip.exe'
92+
else:
93+
return 'bin/pip'
94+
95+
8396
def _copy_src_files(src, package):
8497
LOG.info('Copying source files')
8598
# Re-create cwd directory structure

0 commit comments

Comments
 (0)