Issue building docker image for source-appstore-singer

Summary

Error encountered while building a docker image for source-appstore-singer related to cython_sources attribute in setuptools.


Question

Hi,I having an issue while building a docker image of source-appstore-singer

sudo docker build --no-cache -t <http://ghcr.io/company/source-appstore-singer:0.0.4|ghcr.io/company/source-appstore-singer:0.0.4> .

          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]```
I'd appreciate any insights to help resolve this problem.

<br>

---

This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. [Click here](https://airbytehq.slack.com/archives/C027KKE4BCZ/p1706028540456039) if you want to access the original thread.

[Join the conversation on Slack](https://slack.airbyte.com)

<sub>
["docker-image", "source-appstore-singer", "cython-sources", "error"]
</sub>

AttributeError: cython_sources is only first of errors you will come across

here are Dockefile and setup.py that might be useful

Thanks <@U05JENRCF7C>. The issue is resolved.

The spec step failed while running with docker with this error ModuleNotFoundError: No module named 'requests'

I have added the RUN pip install requests line in the Dockerfile file you sent. But I don’t know why it failed

I see requests ==2.31.0 in the pip list.

Sending build context to Docker daemon   38.4kB
Step 1/20 : FROM python:3.9.11-alpine3.15 as base
 ---&gt; df5be861e65d
Step 2/20 : FROM base as builder
 ---&gt; df5be861e65d
Step 3/20 : WORKDIR /airbyte/integration_code
 ---&gt; Using cache
 ---&gt; 2a7ee7b02c48
Step 4/20 : RUN apk --no-cache upgrade     &amp;&amp; pip install --upgrade pip     &amp;&amp; apk --no-cache add tzdata build-base libffi-dev openssl-dev
 ---&gt; Using cache
 ---&gt; 13472719d896
Step 5/20 : RUN pip install requests
 ---&gt; Using cache
 ---&gt; 8ad592b47051
Step 6/20 : COPY setup.py ./
 ---&gt; Using cache
 ---&gt; 083479f4cb5d
Step 7/20 : RUN pip install pip==21.2.4 poetry==1.7.1 setuptools==57.4.0 wheel==0.37.0
 ---&gt; Using cache
 ---&gt; 41e9b1183924
Step 8/20 : RUN pip install --no-build-isolation --prefix=/install .
 ---&gt; Using cache
 ---&gt; d68fe599f7c1
Step 9/20 : FROM base
 ---&gt; df5be861e65d
Step 10/20 : WORKDIR /airbyte/integration_code
 ---&gt; Using cache
 ---&gt; 2a7ee7b02c48
Step 11/20 : COPY --from=builder /install /usr/local
 ---&gt; Using cache
 ---&gt; 5dac02186ec7
Step 12/20 : COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
 ---&gt; Using cache
 ---&gt; 2b27becc6121
Step 13/20 : RUN echo "Etc/UTC" &gt; /etc/timezone
 ---&gt; Using cache
 ---&gt; 460403e137f3
Step 14/20 : RUN apk --no-cache add bash
 ---&gt; Using cache
 ---&gt; bdc12c6374ab
Step 15/20 : COPY main.py ./
 ---&gt; Using cache
 ---&gt; b7f1242c4fb8
Step 16/20 : COPY source_appstore_singer ./source_appstore_singer
 ---&gt; Using cache
 ---&gt; c6d745086842
Step 17/20 : ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
 ---&gt; Using cache
 ---&gt; 494b859ecbe2
Step 18/20 : ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
 ---&gt; Using cache
 ---&gt; 1b0837b1e422
Step 19/20 : LABEL io.airbyte.version=0.2.6
 ---&gt; Using cache
 ---&gt; 550b2e29f416
Step 20/20 : LABEL io.airbyte.name=airbyte/source-appstore-singer
 ---&gt; Using cache
 ---&gt; 46bd8bd4ec3d
Successfully built 46bd8bd4ec3d
Successfully tagged <http://ghcr.io/company/source-appstore-singer:0.0.4|ghcr.io/company/source-appstore-singer:0.0.4>```
```(.venv3.10) ubuntu@ip-172-31-39-30:~/work/projects/airbyte/airbyte-integrations/connectors/source-appstore-singer$ docker run --rm <http://ghcr.io/company/source-appstore-singer:0.0.4|ghcr.io/company/source-appstore-singer:0.0.4> spec
Traceback (most recent call last):
  File "/airbyte/integration_code/main.py", line 9, in &lt;module&gt;
    from source_appstore_singer import SourceAppstoreSinger
  File "/airbyte/integration_code/source_appstore_singer/__init__.py", line 1, in &lt;module&gt;
    from .source import SourceAppstoreSinger
  File "/airbyte/integration_code/source_appstore_singer/source.py", line 15, in &lt;module&gt;
    from appstoreconnect import Api
  File "/usr/local/lib/python3.9/site-packages/appstoreconnect/__init__.py", line 1, in &lt;module&gt;
    from .api import Api, UserRole
  File "/usr/local/lib/python3.9/site-packages/appstoreconnect/api.py", line 1, in &lt;module&gt;
    import requests
ModuleNotFoundError: No module named 'requests'```

weird, requests should be installed as a dependency of appstoreconnect
https://github.com/Ponytech/appstoreconnectapi/blob/640d3dc02a55b41327caea691da267cbedada366/setup.py#L18

RUN pip install requests doesn’t work because COPY --from=builder /install /usr/local doesn’t copy requests code
this is an example of multi-stage build https://docs.docker.com/build/building/multi-stage/

you need
pip install requests --prefix=/install
or add
requests==2.20.1 (or any other version) to setup.py