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

Automatic Python version determination from pyproject.toml #542

Closed
BrandonLWhite opened this issue Nov 17, 2022 · 3 comments
Closed

Automatic Python version determination from pyproject.toml #542

BrandonLWhite opened this issue Nov 17, 2022 · 3 comments
Labels
feature request New feature or request to improve the current logic

Comments

@BrandonLWhite
Copy link

Description:
Automatically determine the best Python version to install by parsing pyproject.toml and using the tool.poetry.dependencies.python version constraint specifier. The "best" version is the latest available Python version that satisfies the constraint.

Justification:
Though the recent support for .python-version file is very helpful, this requires duplication of the Python version declaration in the source project when using Poetry. The version declaration is already in the pyproject.toml, and Poetry already uses it to select the best Python version as described above when working locally. It would be ideal for CI/CD to also use pyproject.toml to determine the best Python version, instead of requiring adding another file to the repo (.python-version) that contains the needed Python version.

Are you willing to submit a PR?
Yes! Before embarking on such and endeavor, I would like to know if the setup-python maintainers are open to such a feature, and what the preferred configuration inputs might look like.

@BrandonLWhite BrandonLWhite added feature request New feature or request to improve the current logic needs triage labels Nov 17, 2022
@MaksimZhukov
Copy link
Contributor

Hello @BrandonLWhite! Thank you for the suggested idea!
We will consider adding this feature and will let you know as soon as we have any decision.

@hongbo-miao
Copy link

Just copy from my original request at #629 as supplement to this ticket 😃


Since Poetry has Python version defined in pyproject.toml

[tool.poetry.dependencies]
python = "3.11.x"

It would be great to support reading Python version from Poetry pyproject.toml.

Something like

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version-file: path/to/pyproject.toml

FYI, today actions/setup-go supports similar way like this:

      - name: Set up Go
        uses: actions/setup-go@v4
        with:
          go-version-file: path/to/go.mod

(Inside go.mod, it has Go version defined)

Thanks! 😃

@dariocurr
Copy link
Contributor

dariocurr commented May 19, 2023

Any update on this?

I would like to use it using the standard pyproject.toml (PEP 621). In that case, the version would be under [package.requires-python]

Moreover, IMHO the python-version-file could be optional as well when the pyproject.toml is in the root folder.

I would love to contribute on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

No branches or pull requests

4 participants