zappa / Zappa

Serverless Python
https://zappa.ws/zappa
MIT License
3.24k stars 362 forks source link

[Migrated] `zappa package production` fails when using `--no_venv` #850

Open jneves opened 3 years ago

jneves commented 3 years ago

Originally from: https://github.com/Miserlou/Zappa/issues/2097 by woodrad

Context

Running zappa package production --no_venv throws TypeError: expected str, bytes or os.PathLike object, not NoneType. This error happens only when running outside of a virtual environment. zappa package production works as expected.

While I believe running zappa outside of a virtual environment using --no_venv is supported (per #835), I understand why this would be a low-priority issue.

Expected Behavior

zappa builds an application package.

Actual Behavior

zappa throws the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 2778, in handle
    sys.exit(cli.handle())
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 512, in handle
    self.dispatch_command(self.command, stage)
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 551, in dispatch_command
    self.package(self.vargs['output'])
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 642, in package
    self.create_package(output)
  File "/usr/local/lib/python3.8/site-packages/zappa/cli.py", line 2257, in create_package
    self.zip_path = self.zappa.create_lambda_zip(
  File "/usr/local/lib/python3.8/site-packages/zappa/core.py", line 533, in create_lambda_zip
    split_venv = splitpath(venv)
  File "/usr/local/lib/python3.8/site-packages/zappa/core.py", line 527, in splitpath
    (path, tail) = os.path.split(path)
  File "/usr/local/lib/python3.8/posixpath.py", line 103, in split
    p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Possible Fix

If running zappa package outside of a virtual environment is not supported, then the resolution to this issue would be removing support for zappa package --no_venv or reverting #1891.

Another option is adding a conditional check to splitpath() to see whether we are running in a virtual environment before running splitpath(venv).

What appetite do the project maintainers have for supporting zappa use outside of virtual environments?

Your Environment

argcomplete==1.11.1
boto3==1.13.6
botocore==1.16.6
certifi==2020.4.5.1
cfn-flip==1.2.3
chardet==3.0.4
click==7.1.2
docutils==0.15.2
durationpy==0.5
future==0.18.2
hjson==3.0.1
idna==2.9
jmespath==0.9.5
kappa==0.6.0
pip-tools==5.1.2
placebo==0.9.0
python-dateutil==2.6.1
python-slugify==4.0.0
PyYAML==5.3.1
requests==2.23.0
s3transfer==0.3.3
six==1.14.0
text-unidecode==1.3
toml==0.10.0
tqdm==4.46.0
troposphere==2.6.1
urllib3==1.25.9
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.51.0
j6k4m8 commented 2 years ago

This seems to be true of all commands: zappa update dev --no_venv also fails with the same error on my (brand-new ubuntu VM) build.

github-actions[bot] commented 5 months ago

Hi there! Unfortunately, this Issue has not seen any activity for at least 90 days. If the Issue is still relevant to the latest version of Zappa, please comment within the next 10 days if you wish to keep it open. Otherwise, it will be automatically closed.

j6k4m8 commented 5 months ago

I can confirm that this is still an issue.