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

[RFE] Micropipenv get-python-version #189

Open
frenzymadness opened this issue Sep 17, 2021 · 7 comments
Open

[RFE] Micropipenv get-python-version #189

frenzymadness opened this issue Sep 17, 2021 · 7 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@frenzymadness
Copy link
Collaborator

Given these two facts:

  • micropipenv is able to parse all the .lock and pyproject files and
  • micropipenv is not able to create a Python virtual environment

it might make sense to implement a new command get-python-version. The new command would basically just print out the information about the Python version the configuration is prepared for.

Let's say I'd like to use micropipenv instead of pipenv in an automated script for deploying applications. I'm able to create my own virtual environment for the application but I need to know which Python version to use. And this is the spot micropipenv can help me. All the logic to find the proper file and parse all the JSONs or TOMLs is already there so this new feature would enable us to do something like:

PYTHON_VERSION=`micropipenv get-python-version`
python$PYTHON_VERSION -m venv venv
source venv/bin/activate
micropipenv install

@encukou I hope that I described your idea correctly.

This is slightly related to #187

Possible problems to solve:

  • requirements.txt files do not contain Python version, what to return in this case?
  • poetry can use version specifiers like ==3.6.7 or >=3.6.7 or worse ^3.7, what version return in case of such ranges?
  • pipfile should contain only one version and it's generated there automatically but the specification is kinda vague and it seems to me that a pipfile without python_version is valid and pipenv works fine in that case without any issues of warnings.
@encukou
Copy link

encukou commented Sep 17, 2021

One idea would be a filter-python-versions command.
Given a file like:

3.9.7
3.8.12
3.7.12
3.6.15
3.5
3.10.0rc2

then cat versions | micropipenv filter-python-versions would output all versions that match: all of them for requirements.txt; matching ones for Poetry; only the configured one for pipenv with python_version; all of them for pipenv without python_version.

Creating the list (and possibly ordering it by desrability) would be left to the caller, as would choosing a default/error if the result is empty.

@fridex
Copy link
Collaborator

fridex commented Sep 21, 2021

+1 on my side, the extension sounds reasonable.

Possible problems to solve:

  • requirements.txt files do not contain Python version, what to return in this case?

It might be a good idea to end with an error here - following "Explicit is better than implicit." Then, let the user decide which version to use. Alternatively, create a flag like --default-sys-executable that would default to the Python available in sys.executable in these cases.

  • poetry can use version specifiers like ==3.6.7 or >=3.6.7 or worse ^3.7, what version return in case of such ranges?

The lowest matching might make sense here. Maybe create a flag that would assist in choosing the appropriate version in this case as well.

@goern
Copy link
Member

goern commented Oct 4, 2021

/kind feature
/priority backlog

@sesheta sesheta added kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence. labels Oct 4, 2021
@sesheta
Copy link
Member

sesheta commented Jan 2, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@sesheta sesheta added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 2, 2022
@fridex
Copy link
Collaborator

fridex commented Jan 3, 2022

/remove-lifecycle stale

@sesheta sesheta removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 3, 2022
@sesheta
Copy link
Member

sesheta commented Apr 3, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@sesheta sesheta added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 3, 2022
@harshad16
Copy link
Member

/lifecycle frozen

@sesheta sesheta added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

6 participants