I have a .python-version file, and when I create a Python repo with github and specify that it should have a .gitignore, it adds the .python-version file to it. It seems to me that that file should NOT be ignored since other people running the code on different machines would want to know what version of Python they need.
So why is it .gitignored?
You should put in . gitignore all files and patterns that are generated by the build system of your project, or any file that it might output while running. With this, it makes sure that nobody is committing compiled Python files.
A versioning file system is any computer file system which allows a computer file to exist in several versions at the same time. Thus it is a form of revision control. Most common versioning file systems keep a number of old copies of the file.
While being too specific, you can still version that file (meaning: not include it in the default .gitignore), as :
pyenv README, in order to illustrate what version of python is recommended for the specific project,pyenv), or simply ignored (if you don't have pyenv). As the article "How to manage multiple Python versions and virtual environments " states:
When setting up a new project that is to use Python 3.6.4 then
pyenv local 3.6.4would be ran in its root directory.
This would both set the version, and create a.python-versionfile, so that other contributors’ machines would pick it up.
But:
pyenvlooks in four places to decide which version of Python to use, in priority order:
- The
PYENV_VERSIONenvironment variable (if specified).
You can use thepyenv shellcommand to set this environment variable in your current shell session.- The application-specific
.python-versionfile in the current directory (if present).
You can modify the current directory's.python-versionfile with thepyenv localcommand.- The first
.python-versionfile found (if any) by searching each parent directory, until reaching the root of your filesystem.- The global version file. You can modify this file using the
pyenv globalcommand.
If the global version file is not present,pyenvassumes you want to use the "system" Python. (In other words, whatever version would run ifpyenvweren't in yourPATH.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With