Poetry gives: `TooManyIndirects` error suddenly - python-poetry

I have a pyproject.toml:
...
[[tool.poetry.source]]
name = "REPO_NAME"
url = "https://gitlab.com/SOME_ADDRESS"
secondary = true
When trying to install the project using poetry
(poetry install/poetry update) i get:
Updating dependencies Resolving dependencies... (14.3s)
TooManyRedirects
Exceeded 30 redirects.

Currently pypi.python.org is having an issue and there is nothing one can do about it:
But hey, it's Friday.

Clearing the cache seemed to do the trick:
poetry cache clear --all REPO_NAME
Also, it could happen on global PYPI, in that case run:
poetry cache clear --all pypi
To list all poetry's repos:
poetry cache list

There has been an issue with PyPI Json endpoints that poetry uses. pip was unaffected because it uses different endpoints.
A workaround is to export poetry dependencies to the requirements.txt format and use pip:
poetry export --dev > requirements.txt && pip install -r requirements.txt

Related

Install JAX with CUDA via requirements.txt

I installed JAX[cuda] using the installation instructions from official JAX Github: pip install --upgrade "jax[cuda]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html which works nicely. Now I want to wrap this into a requirements.txt in order to save my environment.
I already tried --pre --extra-index-url https://storage.googleapis.com/jax-releases/jax_cuda_releases.html "jax[cuda]" within my requirements.txt but pip install -r requirements.txt always installs the CPU version, not the GPU version. Is there any trick to force the requirements-file to install the GPU / cuda release of JAX?
In a pip requirements.txt file, each global option should be written on its own individual line:
--pre
--find-links https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
jax[cuda]
References
https://pip.pypa.io/en/stable/reference/requirements-file-format/#supported-options

pip install from local directory doesnt add [build-system] dependencies

In our project (Locust) we use setuptools_scm for versioning, so it is needed for all installations from local directory.
We used to have this specified in setup.py:
setup(
setup_requires=["setuptools_scm>=6.2"],
...
)
But we have upgraded to use setup.cfg and pyproject.toml
[build-system]
requires = ["setuptools_scm>=6.2", ...]
This works nicely in most cases, but it does not install setuptools_scm if someone does pip install -e . (it doesnt work for pip install . either but that is less important)
With no setuptools_scm installed the local version becomes 0.0.0:
~/git/locust pip install -e .
Looking in indexes: https://pypi.org/simple
...
Running setup.py develop for locust
Successfully installed locust-0.0.0
... and that makes me very sad.
What is the appropriate way make pip install setuptools_scm when installing from source?
I could of course add it as a regular dependency in setup.cfg, but that would make thousands of users download setuptools_scm even when it is not needed (when installing from PyPi)

Python Poetry - update -dev dependencies only to latest

How do I get Poetry to update dev dependencies only to latest?
I originally had:
[tool.poetry.dev-dependencies]
pytest = "^4.6"
But I wanted:
[tool.poetry.dev-dependencies]
pytest = "^6.0"
I achieved it by manual editing the pyproject.toml file.
When I ran poetry update it ( brilliantly ) bumped all my normal ( non-dev ) dependencies.
This is the command I wanted:
poetry add pytest#latest --dev
With latest poetry version you should use
poetry add pytest#latest --group dev

Poetry takes ages to update dependencies

Yesterday I've commanded poetry to add new dependency. I'm still waiting...
$ poetry add readability
Using version ^0.3.1 for readability
Updating dependencies
Resolving dependencies... (66408.9s)
Is there any way to fix that or manually update lock?
First run:
poetry cache clear pypi --all
Then run:
poetry lock

How to install a package with Poetry that requires CLI args?

Here's an example that requires it:
poetry add pycurl
... gives:
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
The fix is given in that post:
pip install --compile --install-option="--with-openssl" pycurl
How to package-manage my project now?
Must I use poetry for everything else, and manually pip install pycurl?
Or can I somehow fold it into my pyproject.toml?
Although this is old, I would like to share an alternative to re-install the package with the CLI options.
I do not know if running this with Poetry could cause any damage, but I would believe not.
First you'd have to activate your poetry environment with poetry shell.
After that, get the current version of pycurl that is installed using pip list, and copy that value.
Now, you can run pip install --compile --install-option="--with-openssl" --upgrade --force-reinstall pycurl==<version> to install it with the correct options.

Resources