python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.14k stars 2.25k forks source link

(🎁) Provide a wrapper script entry point (like Gradle does with the Gradle wrapper) #4988

Open KotlinIsland opened 2 years ago

KotlinIsland commented 2 years ago

Feature Request

Working on a Gradle project is super easy because to install dependencies/build/run all you have to do is use the Gradle wrapper script that is committed with the project as an entry point, eg: ./gradlew build. It would be great if Poetry had something similar to ease the setup process when Poetry itself isn't installed. Currently you have to mess around with the Poetry install script or use pipx or something, coming from Gradle this all seems like so much work.

This is also a big hassle when different projects(or branches with projects) use different versions of poetry.

Gradle Wrapper

Solution

Use Pyprojectx

[tool.pyprojectx]
poetry = "poetry==1.6.1"
> ./pw poetry install

Does the poetry team want to update the docs to suggest Pyprojectx?

DetachHead commented 1 year ago

i don't know if this is related but attempting to update my python version is so frustrating because it always completely breaks my poertry.

> python --version
Python 3.11.0
> poetry --version
No Python at 'C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe'
> pipx
Fatal error in launcher: Unable to create process using '"C:\Users\user\AppData\Local\Programs\Python\Python310\python.exe"  "c:\users\user\appdata\roaming\python\python310\scripts\pipx.exe" ': The system cannot find the file specified.
> pip show pipx
WARNING: Package(s) not found: pipx

what's the correct way to update python when i'm using poetry? i don't care if i have to uninstall and reinstall it but there should at least be a simple way to do it

KotlinIsland commented 1 year ago

pipx accounts for this scenario: https://pypa.github.io/pipx/docs/#pipx-reinstall-all For the poetry installer maybe you could try curl -sSL https://install.python-poetry.org | python3 - --uninstall?

DetachHead commented 1 year ago

pipx accounts for this scenario: https://pypa.github.io/pipx/docs/#pipx-reinstall-all

i've had nothing but bad experiences with the poetry installer which is why i was using pipx in the first place

For the poetry installer maybe you could try curl -sSL https://install.python-poetry.org | python3 - --uninstall?

(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - --uninstall seemed to work this time, but it's pretty concerning that the docs don't even have windows-specific uninstallation instructions. and i'm certain it will just fail and leave me with a half-installed poetry if i tried running it after updating python

DetachHead commented 1 year ago

turns out the issue is because, for some absurd reason, the python installer by default includes the version number in the install path, which breaks installed packages like pipx and poetry if you decide to uninstall the old version.

the solution is to always install python to the same path (ie. %localappdata%\programs\python instead of %localappdata%\programs\python\python3.11)

KotlinIsland commented 12 months ago

Epic !

pyprojectx supports poetry!

[tool.pyprojectx]
poetry = "poetry==1.6.1"
> ./pw poetry install