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

pip install not working for paytm-pg 1.1.0 #1

Closed
arvind-kalyan opened this issue Jun 27, 2022 · 2 comments · May be fixed by #2
Closed

pip install not working for paytm-pg 1.1.0 #1

arvind-kalyan opened this issue Jun 27, 2022 · 2 comments · May be fixed by #2

Comments

@arvind-kalyan
Copy link

arvind-kalyan commented Jun 27, 2022

Hi team,

pip install is failing with error:

Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/hr/kqh8ht4172s832b39r1ydw5h0000gp/T/pip-req-build-906fvzmo/setup.py", line 2, in <module>
        from paytmpg import package_version
      File "/private/var/folders/hr/kqh8ht4172s832b39r1ydw5h0000gp/T/pip-req-build-906fvzmo/paytmpg/__init__.py", line 13, in <module>
        from paytmpg.pg.Payment import Payment
      File "/private/var/folders/hr/kqh8ht4172s832b39r1ydw5h0000gp/T/pip-req-build-906fvzmo/paytmpg/pg/Payment.py", line 10, in <module>
        from paytmpg.pg.utils.SignatureUtil import generateSignature
      File "/private/var/folders/hr/kqh8ht4172s832b39r1ydw5h0000gp/T/pip-req-build-906fvzmo/paytmpg/pg/utils/SignatureUtil.py", line 6, in <module>
        from Crypto.Cipher import AES
    ModuleNotFoundError: No module named 'Crypto'

My setup:

python3.7, pip 21.1.2

Steps to reproduce:

  1. git clone
  2. start a new virtualenv of python3.7 / 3.8 (new env without any existing packages installed is key here)
  3. python setup.py install --> throws error mentioned above

Problem & Suggested Solution:

This is happening because of compilation error caused due to Crypto dependency in the installation flow. This is introduced during setup time because of this line in setup.py : from paytmpg import package_version. This ends up loading __init__.py of paytmpg package, which also loads Payment -> SignatureUtil -> Crypto. (You can find that in the stacktrace above as well).

Simple solution would be to move VERSION.py outside paytmpg package and put that in the root of the project (or alternatively hardcode it in setup.py itself). Once the import statement dependency from setup.py is removed, installation works as expected. You can let me know if I should raise a pull request for the same.

PS : For solution completeness, I was also reading about how to solve these issues. If we need the current setup to work as-is, there are other best-practices like defining a pyproject.toml file (Refer: https://stackoverflow.com/questions/62983756/what-is-pyproject-toml-file-for), where we can mention build-time dependencies. (Refer : https://stackoverflow.com/questions/49715799/how-to-specify-dependencies-that-setup-py-needs-during-installation). Here, pip understands and installs the dependencies based on pyproject.toml first, and then installs setup.py.

@mageshravi
Copy link

Can confirm this issue exists. Please implement a fix.

@arvind-kalyan
Copy link
Author

We had reported this to paytm team, they have fixed this in 1.1.1. Closing this issue.

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