Replies: 13 comments 1 reply
-
Hello @awilkins, the recommended installation method for poetry is the fin swimmer |
Beta Was this translation helpful? Give feedback.
-
I pulled def install_poetry(self, version: str, env_path: Path) -> None:
self._overwrite(
"Installing {} ({}): {}".format(
colorize("info", "Poetry"),
colorize("b", version),
colorize("comment", "Installing Poetry"),
)
)
if WINDOWS:
python = env_path.joinpath("Scripts/python.exe")
else:
python = env_path.joinpath("bin/python")
if self._git:
specification = "git+" + version
elif self._path:
specification = version
else:
specification = f"poetry=={version}"
subprocess.run(
[str(python), "-m", "pip", "install", specification],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=True,
) Could you point out where it makes use of the lockfile here, because I'm not seeing it? Is this the wrong routine? |
Beta Was this translation helpful? Give feedback.
-
Ah, sorry. Looks like a was to fast with my answer (shouldn't answer during my vacation 😄) Pinning of the dependency was done by vendoring when using the With the new installer script we do not vendor the dependencies anymore. Taking the lock file into account is also not possible during installation, because this would require to have poetry installed. |
Beta Was this translation helpful? Give feedback.
-
We deploy our poetry-developed applications by first installing a requirements.txt that we generate from the lock file using I am in the process of writing a custom install script for the users I support that does the same thing for poetry itself, because we have no choice but to pin both poetry and poetry-core due to a series of releases that are severely broken on Windows (please could somebody give my one-line PR #4682 some love?). Until I complete this custom script, our poetry installation process is to:
Requirements.txt based pinning of dependencies in the installer would be awesome. An alternative (not saying if it's necessarily better) would be to implement the feature discussed in #2778 and use it for poetry itself. |
Beta Was this translation helpful? Give feedback.
-
At the moment, I'd be hesitent to recommend that we use the Alternative options are;
I would argue that this is not one of the objectives for Poetry. The Poetry, as per best practice, defines the acceptable dependency version versions as package metadata that gets used by |
Beta Was this translation helpful? Give feedback.
-
So I went with "what if the install script contained a full frozen install spec". Sadly it wasn't entirely 100% simple - mostly because of packages with complicated constraint history However... Here's what I arrived at : The process was basically ...
The result is a script that installs a working version of Poetry that doesn't have the bugged version of |
Beta Was this translation helpful? Give feedback.
-
Re I agree that using the wheel's version constraints for locked dependency information would not be the right thing. The dependency constraints and the fixed versions in the lock file have different purposes and the distinction shouldn't be muddied. Putting the concrete dependencies in the wheel would be a hack that would probably be regretted later. Let me state the requirement here in a way that I think/hope nobody disagrees with:
I'll also state another thing that I think/hope is uncontroversial:
If these things are agreed, then it seems like generating a requirements.txt is a very natural way of achieving the goal. It captures the fixed dependencies separately from the version constraints, and does so in a way that can be installed without poetry. The only problem with it, really, is that it requires everybody that does this to solve some problems in their own way. If poetry were to use this approach itself in install-poetry.py, for example, the poetry project would need to establish a way to make the requirements.txt corresponding to each poetry version available to the install script, and the install script would need special code to obtain and make use of the requirements.txt. This would all be out-of-band from pypi and wouldn't be reusable for other projects. I think doing better than this, however, is probably not a challenge poetry can solve on its own. Ideally, the locked dependency information would be published along with the package through the usual channels. Probably the easiest way to achieve that would be to embed the information in the package, but separately from the version constraints. There would need to be options at installation time to choose whether these "preferred" dependency versions should be used. There are probably a load of subtleties to consider. I think something like this could be a great solution, and if the underlying mechanisms existed it would clearly be desirable for poetry to support them. However, they don't and I suspect anything poetry does on its own to address this requirement (beyond fully supporting |
Beta Was this translation helpful? Give feedback.
-
With the above said (about the general topic of fixing dependencies for installations of applications developed with poetry), I think poetry itself is facing the same challenge as other projects here and, like them, should ideally do the best it can with the mechanisms that are currently available. Poetry is a fast moving project and is heavily depended upon as a key piece of development/CI infrastructure. Users need to be able to pin the installed version as that is frequently the only short-term remediation for problems introduced in new releases. They also need to be able to pin third party dependencies to avoid incompatibilities/bugs introduced into those. The facts are:
My suggestion would be to commit a requirements-x.y.z.txt file for each released version of poetry into a folder at the root of the repo, so it can be fetched with a raw.githubusercontent.com in the same way as people are invited to fetch |
Beta Was this translation helpful? Give feedback.
-
I ran into a few when doing the script linked above (which includes the hashes) ; I think they might be quite difficult to solve though (and a lot of that is down to a lack of rigour in published package constraints). e.g. There seems to be a bit of confusion with the boolean logic surrounding the
Another one was that the
As you note, the Poetry installer itself is one of these scenarios, because it takes pains to create it's own cloistered venv, specifically to avoid the problem of other package installs interfering with it. It's slightly more complex, because dependency versions depend on your environment.. unless you know up front what your environment will be and can rely on it not changing, which makes the solution simpler.
This in itself is not a terribly tough problem : the gist linked above does this (by just embedding it in a variable). The fiddle is overcoming the exceptions, which wasn't terribly time consuming but did involve some manual guesses. In an ideal world, the script would then enter a test matrix of the supported install platforms to check it worked.
Not keen on this for the same reason I'm not keen on curling a shell script from the master branch of a public git repo in my build pipeline ; nothing stops a bad actor with commit access changing that file. I've written the exported requirements (with hashes) directly into the script, which means I can copy it and be sure that what it installs will never change and can't be amended by a third party. The requirements doubled the size of script, which is to say they add about 25kB per version. |
Beta Was this translation helpful? Give feedback.
-
If you embed the requirements information in the installation script you will need to ensure that old versions of the installation script can be obtained. I'm not sure I like the fact that that links the requirements information to the installation script implementation such that you can't install older versions with the updated installation logic (problematic if bugs are found in the installation script). I understand the desire not to curl install scripts to bash, but the install script has to be published some way. If you want to review the contents of the script and then be sure it won't change when you invoke it repeatedly you need to put a copy of it somewhere you control. The same is true of the requirements.txt (whether it's in the script or not). It should actually be a bit easier if the requirements and script are separate as that way there won't be a whole new script to review each time you adopt a new version, just a new requirements.txt. Anyway, like you I am setting up a custom installation script based on requirements.txt (but not embedded). Something along these lines is clearly needed. |
Beta Was this translation helpful? Give feedback.
-
Or do as I've done and embed the requirements in a map of Yes, this makes a giant ugly script with a big map of text data embedded in it. But also a single thing you can copy, hash, sign, whatever, for your build process rather than 2 things. By all means keep all the data in separate files and maybe have a process that squishes them onto the end of the install script for a release. |
Beta Was this translation helpful? Give feedback.
-
This has been dormant for a while; did anyone make any progress on a methodology to install poetry with pinned, hashed transitive deps? It does sort of seem like things got worse, running |
Beta Was this translation helpful? Give feedback.
-
Related to this, I've always wished poetry would store the version of itself in the lockfile it generated, similar to how Ruby's bundler does. It helps esp when jumping between projects that may use different poetry versions that behave differently. Poetry wouldn't have to be really strict about using a non-matching version, but it provides info for the user to act on. e.g. I've got multiple poetry installations via pipx. |
Beta Was this translation helpful? Give feedback.
-
Feature Request
When installed, Poetry installs the latest available versions of packages in it's dependency graph.
This has lead to multiple occasions where even when installing a specific version of the Poetry client, differences in the installed libraries have lead to an inconsistent experience.
poetry-core
deprecating support formd5
hashes/simple
) #4688cachecontrol
It's quite ironic for a tool which promotes reproducible builds through the use of a lockfile that it should suffer from breakages caused by installing itself via
pip
.Given the purpose of Poetry (and
poetry-core
), it's very likely to be installed and used in a CI pipeline, where stability and reliability are strong concerns. I humbly submit that installing Poetry andpoetry-core
should be a reproducible act for a given version number.Suggest that this may be achievable by (preferring the first)
poetry build
mode that outputs asetup.py
with frozen dependency specifications based on the lock filepoetry
andpoetry-core
pip freeze
forinstall-poetry.py
instead ofBeta Was this translation helpful? Give feedback.
All reactions