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

Update tox.ini and fix install requirements #181

Closed
wants to merge 2 commits into from

Conversation

ildyria
Copy link
Contributor

@ildyria ildyria commented Oct 5, 2023

Installing tox is done directly via pip install -r test-requirements.txt.
This ensures that a newer version of tox does not conflict with dependencies.

@mbyrnepr2
Copy link
Contributor

mbyrnepr2 commented Oct 5, 2023

Hi @ildyria 👋 .
I'm not sure about the rationale here - Let me know if I've gotten this all wrong :)

I think we can be flexible with the version of tox that is required -
So, in test-requirements.txt we should probably unpin the version specified currently for tox to be a range instead (e.g. any version higher than 4.0.0 should be fine for our tox commands to work). Otherwise when we ask users to install test-requirements.txt directly, we are forcing a particular version of tox on them, which isn't ideal, since you can use one globally-installed tox to manage multiple locally checked-out github projects.

Adding a new section at the top of tox.ini can also help with this:

[tox]
minversion = 4.0.0

@ildyria
Copy link
Contributor Author

ildyria commented Oct 6, 2023

I think we can be flexible with the version of tox that is required

Well, I would have hoped so, but when I run this on my laptop with Tox 4.11.3 it was breaking due to that conflict.

@mbyrnepr2
Copy link
Contributor

mbyrnepr2 commented Oct 6, 2023

What sort of breaking output are you getting just so we are looking at the same thing?

I've performed 2 tests on resc-backend, using Python3.11 and python3.9. The below details describe the 3.11 test but the same versions of pip and tox are used in both tests. I haven't run into any issues with the setup as described here.

# I'm using the same version of tox (4.11.3) that you are using
# Tox was installed on my machine using Python 3.11
markbyrne@Marks-MacBook-Air-2 resc-backend % python3.11 -m tox --version
4.11.3 from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/tox/__init__.py

# pip version:
markbyrne@Marks-MacBook-Air-2 resc-backend % python3.11 -m pip --version
pip 23.2.1 from /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pip (python 3.11)
# Run tox `lint` environment
cd resc-backend
python3.11 -m tox -e lint
# flake8 & pylint complete
# Tox's site-packages contains the version of tox defined in test-requirements.txt:
markbyrne@Marks-MacBook-Air-2 resc-backend % ls .tox/lint/lib/python3.11/site-packages/tox
tox/                   tox-4.11.1.dist-info/

The one thing I did run into which could be fixed is when running tox by default with the tox command. Then I see a:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'.
Note this was fixed for the resc-helm-wizard package.

@ildyria
Copy link
Contributor Author

ildyria commented Oct 6, 2023

▶ python3 --version
Python 3.11.5

resc-repository-scanner/components/resc-vcs-scanner  update-tox-install-requirements ✗                       23h32m ◒
▶ python3 -m venv env

resc-repository-scanner/components/resc-vcs-scanner  update-tox-install-requirements ✗                       23h32m ◒
▶ source env/bin/activate
(env)
resc-repository-scanner/components/resc-vcs-scanner  update-tox-install-requirements ✗                       23h32m ◒
▶ pip3 install -r requirements.txt
Looking in indexes: nexus...
[...]
Successfully installed GitPython-3.1.32 Mako-1.2.4 MarkupSafe-2.1.3 aiofiles-0.8.0 aiohttp-3.8.5 aiosignal-1.3.1 alembic-1.11.2 amqp-5.1.1 asgiref-3.7.2 async-timeout-4.0.3 attrs-23.1.0 billiard-4.1.0 celery-5.3.1 certifi-2023.7.22 cffi-1.16.0 charset-normalizer-3.3.0 click-8.1.7 click-didyoumean-0.3.0 click-plugins-1.1.1 click-repl-0.3.0 cryptography-41.0.3 fastapi-0.66.1 fastapi-cache2-0.2.1 frozenlist-1.4.0 gitdb-4.0.10 greenlet-3.0.0 h11-0.14.0 idna-3.4 kombu-5.3.2 multidict-6.0.4 packaging-21.3 pendulum-2.1.2 prettytable-3.8.0 prompt-toolkit-3.0.39 pycparser-2.21 pydantic-1.8.2 pyjwt-2.8.0 pyparsing-3.1.1 python-dateutil-2.8.2 python-multipart-0.0.6 pytzdata-2020.1 redis-4.6.0 requests-2.31.0 resc-backend-2.0.0 six-1.16.0 smmap-5.0.1 sqlalchemy-1.4.37 starlette-0.14.2 tenacity-8.2.2 termcolor-2.3.0 tomlkit-0.12.1 typing-3.7.4.3 typing-extensions-4.8.0 tzdata-2023.3 urllib3-2.0.6 uvicorn-0.17.6 vine-5.0.0 waitress-2.1.2 wcwidth-0.2.8 yarl-1.9.2
(env)
resc-repository-scanner/components/resc-vcs-scanner  update-tox-install-requirements ✗     23h33m ◒
▶ pip install tox
[...]
cachetools, virtualenv, pyproject-api, tox
  Attempting uninstall: packaging
    Found existing installation: packaging 21.3
    Uninstalling packaging-21.3:
      Successfully uninstalled packaging-21.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
resc-backend 2.0.0 requires packaging==21.3, but you have packaging 23.2 which is incompatible.
Successfully installed cachetools-5.3.1 chardet-5.2.0 colorama-0.4.6 distlib-0.3.7 filelock-3.12.4 packaging-23.2 platformdirs-3.11.0 pluggy-1.3.0 pyproject-api-1.6.1 tox-4.11.3 virtualenv-20.24.5
(env)

@mbyrnepr2
Copy link
Contributor

mbyrnepr2 commented Oct 6, 2023

Aha right :D. So I would say the root-cause here is that resc-backend is pinning all of it's dependencies too strictly.
resc-backend is a library (it's one of resc-vcs-scanner's dependencies) so it needs to be less restrictive since it's packages need to live side-by-side in your environment with any other packages you may have installed there.
So I would unpin those versions in resc-backend's requirements.txt (or give them a minimum required version which still minimises the chances for these kind of conflicts.)
This is likely to be a recurring issue until that action is taken.

https://caremad.io/posts/2013/07/setup-vs-requirement/

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

Successfully merging this pull request may close these issues.

2 participants