sanic icon indicating copy to clipboard operation
sanic copied to clipboard

Incorrect files being fetched when installing a specific version Sanic through pip

Open souri opened this issue 3 years ago • 3 comments

Describe the bug A clear and concise description of what the bug is, make sure to paste any exceptions and tracebacks. Facing a very weird issue in our production systems. I have a version of Sanic pinned in my pipfile. The version is 20.6.3. the project is dockerized, and the current builds work fine. (the existing build system fetches the pip packages through it's local cache). On running this build in a new system, the project fails to start with this error:

ImportError: cannot import name 'OS_IS_WINDOWS' from 'sanic.compat' (/usr/local/lib/python3.8/site-packages/sanic/compat.py)
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/opt/project/__main__.py", line 3, in <module>
    from sanic import Blueprint, Sanic
  File "/usr/local/lib/python3.8/site-packages/sanic/__init__.py", line 2, in <module>
    from sanic.app import Sanic
  File "/usr/local/lib/python3.8/site-packages/sanic/app.py", line 18, in <module>
    from sanic.asgi import ASGIApp
  File "/usr/local/lib/python3.8/site-packages/sanic/asgi.py", line 25, in <module>
    from sanic.server import ConnInfo, StreamBuffer
  File "/usr/local/lib/python3.8/site-packages/sanic/server/__init__.py", line 6, in <module>
    from sanic.server.runners import serve, serve_multiple, serve_single
  File "/usr/local/lib/python3.8/site-packages/sanic/server/runners.py", line 22, in <module>
    from sanic.compat import OS_IS_WINDOWS, ctrlc_workaround_for_windows
ImportError: cannot import name 'OS_IS_WINDOWS' from 'sanic.compat' (/usr/local/lib/python3.8/site-packages/sanic/compat.py)

On investigating the contents of our previously build docker images - we don't find this /usr/local/lib/python3.8/site-packages/sanic/server/runners.py file in the 20.6.3 version of Sanic package directory.

Code snippet Relevant source code, make sure to remove what is not necessary. The Pipfile contents:

[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages]
sanic = "==20.6.3"
sanic-cors = ">=0.10.0.post3"

The dockerfile contents

FROM python:3.8-buster

WORKDIR /opt

RUN apt-get -y update && \
    apt-get -y install --no-install-recommends --no-install-suggests \
    gcc gnupg2 libc-dev make netcat postgresql-client

RUN pip install pipenv
COPY Pipfile* ./
RUN pipenv install --skip-lock --system --deploy
RUN pip install httpx==0.13.3
RUN pip install aiohttp
COPY . .
ENTRYPOINT ["/opt/entrypoint.sh"]
EXPOSE 8000
CMD ["python", "-m", "project"]

Expected behavior A clear and concise description of what you expected to happen. We expect that there is no change in the contents of the package if a version is pinned.

Environment (please complete the following information):

  • OS: python:3.8-buster

Additional context Add any other context about the problem here.

Checking the contents of docker images (new vs old) _New download

cat /usr/local/lib/python3.8/site-packages/sanic/__version__.py
__version__ = "20.6.3"

_Old download

cat /usr/local/lib/python3.8/site-packages/sanic/__version__.py
__version__ = "20.6.3"

Package contents New download image

Old download image

There are 41 files in /usr/local/lib/python3.8/site-packages/sanic/ now vs the previous 39. Any help would be greatly appreciated.

souri avatar Dec 13 '21 15:12 souri

There is certainly something wrong with your install cache. That file is very recent and certainly not in such an old version. Sorry that I don't have more to offer, but this doesn't seem to be a problem with Sanic, and is more related to your build system.

ahopkins avatar Dec 13 '21 15:12 ahopkins

@souri did you get this sorted in the end?

prryplatypus avatar Apr 08 '22 11:04 prryplatypus

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 05:09 stale[bot]