-
Notifications
You must be signed in to change notification settings - Fork 91
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
Dependency errors when using python 3.9 and 3.8 #174
Comments
Lines 30 to 39 in 400386b
I fixed this problem by adding |
I am running into this issue with python3.8 (though I do not run into this with python3.7 and have not yet tried python3.9). I submitted a bug to pytype suggesting they add explicit version pinning to their If you add the Also, I created my own seed repo as I did not see that @cjolowicz had created a seed repo of his own. I'll look at that and then potentially deprecate mine. |
Due to issues with pytype not pinning dependency versions, I'm removing the explicit version checking semantics. See also: * google/pytype#731 * cjolowicz/hypermodern-python#174
I have the same problem with python 3.8 and 3.9. Only nox sessions with python 3.7 do not fail with variations of the above console output. Other packages that are missing hashes in the output of Is this behavior caused by poetry or pip or pyenv or python? While adding the argument |
Could you try downgrading Poetry to 1.1.2, or if that doesn't help, 1.0.10? |
In the meantime, please refrain from asking maintainers of other projects to pin their requirements. This is based on a misunderstanding: Even if pytype pinned their |
After downgrading poetry to 1.1.2 the nox sessions for lint, mypy, and tests under python 3.8 run successfully. Edit: The above issue also occurs for poetry 1.1.3 |
Sadly, this did not work for me. Error message is effectively the same, though for all Nox sessions. Tried using Poetry 1.0.10, 1.1.2, and 1.1.4 (latest at time of writing). Also tried using different combinations of recent Pip versions as well as the most recent one. |
Here is what I am currently using: def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None:
"""Install packages constrained by Poetry's lock file.
This function is a wrapper for nox.sessions.Session.install. It
invokes pip to install packages inside of the session's virtualenv.
Additionally, pip is passed a constraints file generated from
Poetry's lock file, to ensure that the packages are pinned to the
versions specified in poetry.lock. This allows you to manage the
packages as Poetry development dependencies.
Arguments:
session: The Session object.
args: Command-line arguments for pip.
kwargs: Additional keyword arguments for Session.install.
"""
with tempfile.NamedTemporaryFile() as requirements:
session.run(
"poetry",
"export",
"--dev",
"--format=requirements.txt",
"--without-hashes",
f"--output={requirements.name}",
external=True,
)
session.install(f"--constraint={requirements.name}", *args, **kwargs) Then using it within nox sessions as: @nox.session(python=_versions)
def lint(session: Session) -> None:
"""Run the code linters."""
args = session.posargs or locations
install_with_constraints(
session,
"darglint",
"flake8",
"flake8-annotations",
"flake8-black",
"flake8-docstrings",
"flake8-isort",
"flake8-rst-docstrings",
"flake8_sphinx_links",
)
session.run("flake8", *args) I hope that helps. |
Yeah I have the same setup pretty much. I've checked the exported It's pretty strange and makes me wonder if the DockerHub python slim images I'm using are themselves somehow the problem... but they haven't been updated for 7 months, so maybe it's not at a lower layer? |
Update- I got it! I was on the right track, with my previous comment above. However, instead of looking down to the Docker image layer, I had forgotten that there is one last layer before we get to Docker, which is virtualenv! Manually pinning virtualenv to version 20.0.26 (current version is 20.2.2) fixes the issue. Not sure if it's just this specific current version that introduces the issue, though. |
Glad you found a workaround. I would suspect that this is triggered by changes to constraints file handling in pip's new resolver. Pip is bundled with virtualenv. You could then also "solve" this by pinning pip to a version before the new resolver became the default, setting the environment variable VIRTUALENV_PIP to 20.2.4 |
We also were having this issue ^. Should an issue be raised with It seems like it's a bug if the error is the hashes are not present, but they are. Edit: based on the discussion pypa/pip#8792 its a design decision and not a bug. |
@cjolowicz is right that just pinning Pip to 20.2.4, which is the version right before the current one at time of writing, will have the same effect as the solution I talked about above. So we're just doing |
@wanderrful That didn't work for me =/ https://github.com/DontShaveTheYak/cloud-radar/actions/runs/420486474 Unless you mean pinning pip with poetry or some other way? Pinning I ended up just using |
For me, doing the environment variable approach recommended above and then also pinning the Pip version itself together worked out fine. One difference between your build and mine is that you're using the latest version of Nox, whereas we've pinned the previous version of it (2020.5.24). Nox has a Also, we're using |
The cause definitely seems to be the changes to pip with the new resolver becoming the default in version 20.3. Looks like the way constraints file work has changed in this version. pypa/pip#9020 and https://pip.pypa.io/en/latest/user_guide/#watch-out-for cleared it up for me. It seems that the only solution, other than not upgrading pip, is to add "--without-hashes" to the "poetry export" command in |
Not sure if it helps, but I can only second this what @Harrison88 said. For me with a fresh install and newest cookiecutter template this is giving me errors. I think this is closely connected to this issue regarding virtualenv and the new pip resolver here. This got reported in the anaconda environment, but still holds true for me, since I have both - miniconda and python versions 3.9 and 3.8 installed via pyenv. nox > Running session mypy-3.8
nox > Creating virtual environment (virtualenv) using python.exe in .nox\mypy-3-8
nox > Command $HOME\.local\pipx\venvs\nox\scripts\python.exe -m virtualenv $HOME\mjt\overwatch\.nox\mypy-3-8 -p $HOME\Miniconda3\python.exe failed with exit code 1:
FileNotFoundError: [Errno 2] No such file or directory: '$HOME\\Miniconda3\\Lib\\venv\\scripts\\nt\\python.exe'
nox > Session mypy-3.8 failed. Here is my cache-dir = "$HOME\\AppData\\Local\\pypoetry\\Cache"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}\\virtualenvs" # $HOME\AppData\Local\pypoetry\Cache\virtualenvs for Poetry version 1.1.4 and 1.1.2 |
After trying many combinations of pip, virtualenv, poetry and nox-poetry the combination that worked best for me with latest versions is:
Basically, new poetry not working well with new virtualenv (and vice-versa). pip version does not seem to impact on hashes problem. |
For other people coming along here: An alternative solution to downgrading pip to 20.2.4 might be to use the old resolver in pip 20.3 (check here for more info) by setting it's use in an environment variable or the config, on Linux for the config this would be in
This however has no influence on the virtualenv pip AFAIK. |
Update from my last comment. Now using all latest versions, everything seems to be working together perfectly:
@cjolowicz any chance we get a new release of cookiecutter with these updated versions? |
hi @staticdev
2021.1.29 was just released. |
For everyone not using the Cookiecutter and/or nox-poetry, I would recommend passing |
This seems to continue to persist in 3.10.
|
Issue
When using python version 3.9: For me, all nox sessions where
install_with_constrains
is used with python version 3.9 fail.For instance running the tests session works fine, till chapter 4. After adding more nox sessions and installing more dependencies I started to see multiple dependencies for different python versions (I am following the tutorial using python 3.9 and 3.8 respectively).
After some research, it seems this problem is related to Duplicate dependency export #1970
Console Output
CLICK ME
The text was updated successfully, but these errors were encountered: