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

Failed installation: setup.py import assumes deps already installed #37

Closed
dfernandez-at-wiris opened this issue Nov 8, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@dfernandez-at-wiris
Copy link

When installing ipregistry 2.0.0 in our CI server we get the following errors:

#8 7.073 Collecting ipregistry==2.0.0
#8 7.144   Downloading ipregistry-2.0.0.tar.gz (5.8 kB)
#8 7.338     ERROR: Command errored out with exit status 1:
#8 7.338      command: /var/lang/bin/python3.8 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/setup.py'"'"'; __file__='"'"'/tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-paikyw6j
#8 7.338          cwd: /tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/
#8 7.338     Complete output (9 lines):
#8 7.338     Traceback (most recent call last):
#8 7.338       File "<string>", line 1, in <module>
#8 7.338       File "/tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/setup.py", line 3, in <module>
#8 7.338         from ipregistry import __version__
#8 7.338       File "/tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/ipregistry/__init__.py", line 5, in <module>
#8 7.338         from .cache import *
#8 7.338       File "/tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/ipregistry/cache.py", line 17, in <module>
#8 7.338         import abc, six
#8 7.338     ModuleNotFoundError: No module named 'six'
#8 7.338     ----------------------------------------
#8 7.342 WARNING: Discarding https://files.pythonhosted.org/packages/aa/eb/791256c45052d3fde4fe7e6d10b489f025b943ce56cfde691cff46dd1090/ipregistry-2.0.0.tar.gz#sha256=f07a5f9b8b791b83f648f47475e53d600a91cc52d8f7658486d946a87bb9bad0 (from https://pypi.org/simple/ipregistry/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#8 7.342 ERROR: Could not find a version that satisfies the requirement ipregistry==2.0.0 (from versions: 1.0.0, 1.1.0, 2.0.0, 2.0.1, 3.0.0, 3.1.0)
#8 7.342 ERROR: No matching distribution found for ipregistry==2.0.0
#8 7.463 WARNING: You are using pip version 21.1.1; however, version 21.3.1 is available.
#8 7.463 You should consider upgrading via the '/var/lang/bin/python3.8 -m pip install --upgrade pip' command.
#8 ERROR: process "/bin/sh -c pip install --no-cache-dir -r /tmp/requirements.txt" did not complete successfully: exit code: 1
------
 > [4/7] RUN pip install --no-cache-dir -r /tmp/requirements.txt:
#8 7.338         from .cache import *
#8 7.338       File "/tmp/pip-install-s1_fc88h/ipregistry_0f83ab2a0e3d4d13bdf0bb70c6d21a9e/ipregistry/cache.py", line 17, in <module>
#8 7.338         import abc, six
#8 7.338     ModuleNotFoundError: No module named 'six'
#8 7.338     ----------------------------------------
#8 7.342 WARNING: Discarding https://files.pythonhosted.org/packages/aa/eb/791256c45052d3fde4fe7e6d10b489f025b943ce56cfde691cff46dd1090/ipregistry-2.0.0.tar.gz#sha256=f07a5f9b8b791b83f648f47475e53d600a91cc52d8f7658486d946a87bb9bad0 (from https://pypi.org/simple/ipregistry/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#8 7.342 ERROR: Could not find a version that satisfies the requirement ipregistry==2.0.0 (from versions: 1.0.0, 1.1.0, 2.0.0, 2.0.1, 3.0.0, 3.1.0)
#8 7.342 ERROR: No matching distribution found for ipregistry==2.0.0

The reason seems to be that setup.py imports from the module (from ipregistry import __version__). This import in turn causes __init__.py to run several other imports, basically trying to import all of its dependencies, like that import abc, six you see above. Because the deps are not yet installed, the whole process fails. This all happens before the installation begins.

In our case, this was solved by manually installing ALL dependencies in our CI server before beginning the build process (and in our local dev environment for development). This is not only quite inconvenient, but could cause dependency problems in monorepo-style projects.

A suggestion for a simple and quick fix would be to store the __version__ variable in a separate version.py. This way __init__.py would import from it and setup.py would not require importing all dependencies of the (yet to install) package.

Additionally, the reason we are using version ipregistry 2.0.0 is that requirements are very strict (all are ==), which means that our dependency management tool (poetry) won't be able to find a compatible combination of dependency versions with the other packages we're using. Seeing as this package is seldomly updated and its dependencies are a few, fairly stable packages like requests, I'd suggest relaxing those requirements to allow for patches or even minor version upgrades (e.g. requests>=2.22.0,<3).

@lpellegr lpellegr self-assigned this Nov 8, 2021
@lpellegr lpellegr added the enhancement New feature or request label Nov 8, 2021
@lpellegr
Copy link
Contributor

lpellegr commented Nov 8, 2021

Thanks for creating this issue. Could you please share the version of Python and the command used to install ipregistry?

@dfernandez-at-wiris
Copy link
Author

dfernandez-at-wiris commented Nov 9, 2021

Hi there. We tried both with latest Python 3.8 and latest 3.9 and the exact command was pip install --no-cache-dir -r requirements.txt (ipregistry==2.0.0 is in our requirements.txt).

@lpellegr
Copy link
Contributor

lpellegr commented Nov 9, 2021

Thanks for the information. We've released a new version (3.2.0) following your suggestions. Could you please give it a try and let me know if it works as you expect?

@dfernandez-at-wiris
Copy link
Author

Thank you for such an amazingly quick response. We've queued the upgrade but upon local testing it looks good to me. I'll hopefully report back tomorrow with good news!

@lpellegr
Copy link
Contributor

@dfernandez-at-wiris Just a quick message to check if everything is OK on your side.

@dfernandez-at-wiris
Copy link
Author

Hi @lpellegr. Apologies for the delay, we have been making absolutely sure everything is okay on our end across a couple of projects. I can confirm now that the issue seems to be completely gone, both locally and in our CI servers. Thanks again for the quick response time and following up on us, we really appreciate it :)

@lpellegr
Copy link
Contributor

Great. Thanks for the update.

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

No branches or pull requests

2 participants