Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zappa failing due to newer version of setuptools #1349

Open
sridhar562345 opened this issue Sep 16, 2024 · 14 comments
Open

Zappa failing due to newer version of setuptools #1349

sridhar562345 opened this issue Sep 16, 2024 · 14 comments

Comments

@sridhar562345
Copy link
Contributor

sridhar562345 commented Sep 16, 2024

from distutils.dir_util import copy_tree

copy_tree(temp_package_path, temp_project_path, update=True)

Env details

Python version: 3.10
pip version: 24.2
setuptools version: 75.0.0

Logs

  File "/_venv/lib/python3.10/site-packages/zappa/core.py", line 690, in create_lambda_zip
        copy_tree(temp_package_path, temp_project_path, update=True)
  File "/_venv/lib/python3.10/site-packages/setuptools/_distutils/dir_util.py", line 155, in copy_tree
    return list(itertools.chain.from_iterable(map(copy_one, names)))
  File "/_venv/lib/python3.10/site-packages/setuptools/_distutils/dir_util.py", line 197, in _copy_one
    file_util.copy_file(
  File "/_venv/lib/python3.10/site-packages/setuptools/_distutils/file_util.py", line 104, in copy_file
    from distutils._modified import newer
ModuleNotFoundError: No module named 'distutils._modified'
@sridhar562345
Copy link
Contributor Author

We already have below function:

def copytree(src, dst, metadata=True, symlinks=False, ignore=None):

Replacing the distutils usage with copytree in utilities.py should solve the problem.

Let me know if doing so is sufficient or not?

@RicardoNeto
Copy link

Following

I temporarilly forced the previous version of setup-tools and it worked

@carlos-schwabe
Copy link

To which version of setup-tools did you revert to?

@RicardoNeto
Copy link

setuptools==74.1.2

@carlos-schwabe

@shikarkhane
Copy link

shikarkhane commented Sep 20, 2024

For anyone else who is using Github actions to deploy and using pipenv, you will have tough time fixing the setuptools version because #pipenv takes the latest.

So you will have update the virtualenv after install like
pipenv install -r requirements.txt --python 3.8
pipenv run pip install setuptools==74.1.2

@carlos-schwabe
Copy link

@RicardoNeto Even that wouldn't work for me sadly.
I had to make a little tweak to the workflow file to make it work properly.

For reference and if anyone else is experiencing issues with GitHub Actions:
- name: Create virtual env with Python3.8 run: | pip install virtualenv python3.8 -m virtualenv env - name: Install Requirements run: | . env/bin/activate python -m pip install --upgrade pip pip install -r requirements.txt pip install setuptools==69.5.1 deactivate - name: Install Zappa run: | . env/bin/activate pip install zappa deactivate - name: Update application using zappa run: | . env/bin/activate zappa update prod deactivate

@jturan
Copy link

jturan commented Sep 25, 2024

A bit concerning that this PR is still sitting in a review state. Every one of my personal and work-related GitHub Actions deployment scripts using Zappa are failing because of this bug.

@vhiremath
Copy link

vhiremath commented Sep 25, 2024

I started seeing this issue today with my zappa deploy to aws lambda.
I have not updated/changed my pyproject.toml or poetry.lock file for last couple of months. Yet this error occurred with latest deploy attempt.

Traceback (most recent call last):
  File "/code/.venv/lib/python3.11/site-packages/zappa/cli.py", line 3048, in handle
    sys.exit(cli.handle())
             ^^^^^^^^^^^^
  File "/code/.venv/lib/python3.11/site-packages/zappa/cli.py", line 521, in handle
    self.dispatch_command(self.command, stage)
  File "/code/.venv/lib/python3.11/site-packages/zappa/cli.py", line 574, in dispatch_command
    self.update(
  File "/code/.venv/lib/python3.11/site-packages/zappa/cli.py", line 980, in update
    self.create_package()
  File "/code/.venv/lib/python3.11/site-packages/zappa/cli.py", line 2453, in create_package
    self.zip_path = self.zappa.create_lambda_zip(  # type: ignore[attr-defined]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/.venv/lib/python3.11/site-packages/zappa/core.py", line 690, in create_lambda_zip
    copy_tree(temp_package_path, temp_project_path, update=True)
==============
  File "/code/.venv/lib/python3.11/site-packages/setuptools/_distutils/dir_util.py", line 155, in copy_tree
    return list(itertools.chain.from_iterable(map(copy_one, names)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/.venv/lib/python3.11/site-packages/setuptools/_distutils/dir_util.py", line 186, in _copy_one
    yield from copy_tree(
               ^^^^^^^^^^
  File "/code/.venv/lib/python3.11/site-packages/setuptools/_distutils/dir_util.py", line 155, in copy_tree
    return list(itertools.chain.from_iterable(map(copy_one, names)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/.venv/lib/python3.11/site-packages/setuptools/_distutils/dir_util.py", line 197, in _copy_one
    file_util.copy_file(
  File "/code/.venv/lib/python3.11/site-packages/setuptools/_distutils/file_util.py", line 104, in copy_file
    from distutils._modified import newer
ModuleNotFoundError: No module named 'distutils._modified'

Whats the remedy here?
My poetry.lock says
[package.extras] test = ["pytest (>=6.0.0)", "setuptools (>=65)"]

@ikkshvaku
Copy link

ikkshvaku commented Sep 26, 2024

iam facing this issue too.
when is the fix expected? I already see PR ready for review. Will this be merged soon ?
or any other workaround for zappa users plz? thx

@ikkshvaku
Copy link

do zappa follow this sequence?

https://github.com/pypa/setuptools/blob/v75.1.0/_distutils_hack/__init__.py#L16-L23

    warnings.warn(
        "Distutils was imported before Setuptools, but importing Setuptools "
        "also replaces the `distutils` module in `sys.modules`. This may lead "
        "to undesirable behaviors or errors. To avoid these issues, avoid "
        "using distutils directly, ensure that setuptools is installed in the "
        "traditional way (e.g. not an editable install), and/or make sure "
        "that setuptools is always imported before distutils."
    )

I see that setuptools TOT still has modified.py at setuptools_distutils
Why do we still see the issue in discussion?

@ejjick
Copy link

ejjick commented Sep 26, 2024

Got it to work with the change proposed in the PR

71d834a

@ikkshvaku
Copy link

My zappa deploy is triggered from Docker CI/CD
How can I apply this fix proposed in PR in such case?

@jturan
Copy link

jturan commented Sep 27, 2024

For the poetry users, I was able to fix this by pinning an older version of setuptools, similar to the other responses above:

poetry add [email protected]

@anthonyhashemi
Copy link

Looks like this has been fixed on main with the merging of #1352

When can we expect a release including the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants