Comments (7)
lmk if that fix looks ok to you!
from book-tdd-web-dev-python.
thanks for the extremely thorough reply btw! i learned plenty. really appreciate that.
from book-tdd-web-dev-python.
What OS still ships Python 2 as the default Python?
[edit] - sorry i realise that's a little rude, i don't mean to be, and i'm keen to support as many possilbe contributors as possible!
i think you might be able to get it working by doing source ~/.bashrc
in your ~/.bash_profile
? i seem to remember that noninteractive shells only source one of those two...
from book-tdd-web-dev-python.
Did not take that as rude so no worries!
The problem here lies on PEP 394. It has some great outlingings of the Python runtime distribution situation in 2011 when the PEP was created (especially Abstract and History of this PEP!), and the PEP and its recommendations are still active after 13 years! The most relevant part to this issue are these two bullet points:
- If the
python
command is installed, it is expected to invoke either the same version of Python as thepython3
command or as thepython2
command.- Distributors may choose to set the behavior of the
python
command as follows:
python2
,python3
,- not provide
python
command, allowpython
to be configurable by an end user or a system administrator.
Some distros provide a python
command and some not. For example, Debian and Ubuntu only have python3
installed by default. Here are both distro's wiki pages on this issue: https://wiki.debian.org/Python and https://wiki.debian.org/Python. Here's a citation from the Ubuntu's wiki page because of its relation on the PEP 394:
/usr/bin/python
will point to Python 3. No, this is not going to happen (unless PEP 394 advocates otherwise, which is doubtful for the foreseeable future).
To have a different example as well, here's Fedora's wiki page: https://fedoraproject.org/wiki/Changes/Python_means_Python3.
In package and command names, "Python" will mean "Python 3".
Users installing and running Python or Python packages without specifying a version will get Python 3.
Running
python
will runpython3
.
I'm on the latest Ubuntu, Ubuntu 23.10, and here's what apt show
says:
$ apt show python
Package: python
State: not a real package (virtual)
N: Can't select candidate version from package python as it has no candidate
N: Can't select versions from package 'python' as it is purely virtual
N: No packages found
$ apt show python3
Package: python3
Version: 3.11.4-5
Priority: important
Section: python
Source: python3-defaults
Origin: Ubuntu
...
Then, let's get back to python3
. Here's what PEP 394 states on it:
- We expect Unix-like software distributions (including systems like macOS and Cygwin) to install the
python2
command into the default path whenever a version of the Python 2 interpreter is installed, and the same forpython3
and the Python 3 interpreter.
- If the
python
command is installed, it is expected to invoke either the same version of Python as thepython3
command or as thepython2
command.
So, because python3
is always expected to be provided by Python runtime distributors, wouldn't it be more applicable to use python3
in the Makefile as well?
Then regarding Bash startup files, here's what Bash manual says:
Invoked non-interactively
When Bash is started non-interactively, to run a shell script, for example, it looks for the variable
BASH_ENV
in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATH
variable is not used to search for the filename.As noted above, if a non-interactive shell is invoked with the
--login
option, Bash attempts to read and execute commands from the login shell startup files.
So yes, I could use BASH_ENV
to have my Bash aliases applied but it feels a bit counterintuitive if Makefile could just use the python3
command. Also, people not having python
command provided by their distro and having to use BASH_ENV
may lead to them having different experiences with the Makefile regarding on the differences with their Bash files.
from book-tdd-web-dev-python.
hmmm. well i think python3 will work ok on linuxes and also on macos, but fail on windows... but then again most stuff will fail on windows so.
from book-tdd-web-dev-python.
thanks for the extremely thorough reply btw! i learned plenty. really appreciate that.
Really nice to hear that the reply was helpful for you. Thank you for your comment, Harry! Made my day. 😊
lmk if that fix looks ok to you!
It looks good!
hmmm. well i think python3 will work ok on linuxes and also on macos, but fail on windows... but then again most stuff will fail on windows so.
Yeah, sure, you're not wrong here. Also, README seems to already nudge towards WSL2 on Windows.
Then again, I do think it would be great to think of a way to have a support for OS-independant Makefile. There are multiple sources that seem to indicate that the use of an OS
environment variable could be used 123. But some sources (even on some of the previous ones as well) do mention a uname
command that may be used as well but I'm not sure if it's always included in Windows systems 45.
I don't even have a Windows machine myself ready at the moment to test these (even though I could try my wife's Windows laptop). I may create a VM for testing this at some point, haven't done created one before so it could be fun.
Footnotes
-
Stack Overflow: OS detecting makefile ↩
-
GitHub Gist: Detect operating system in Makefile. ↩
-
Stack Overflow: Platform-dependent Makefile ↩
-
O'Reilly: Managing Projects with GNU Make, 3rd Edition by Robert Mecklenburg. Chapter 7. Portable Makefiles ↩
-
Superuser: How to detect windows OS in shell script ↩
from book-tdd-web-dev-python.
I do think it would be great to think of a way to have a support for OS-independant Makefile
haha i'm not sure this repo has enough contributors to really be worth the effort! it would be purely out of intellectual curiosity...
from book-tdd-web-dev-python.
Related Issues (20)
- ch11l032 - Typo in the test
- ch17|023 - Replace import to enable easier migration to Django 2 HOT 1
- Outdated section | 'What to do next' -> 'Test for Graceful Degradation'
- Dive Into Python URL is wrong HOT 1
- Realy stuck on unix socket HOT 1
- Typos on server-quickstart.md
- Geckodriver Source URL incorrect HOT 1
- Quotation marks needed for "$ python -c from selenium..."? HOT 1
- early release book ~issue / geckodriver.log HOT 2
- Python version mismatch HOT 1
- Chapter 10: Django 4.2.7 still displayed as the result of pip freeze | grep -i django HOT 1
- Chapter 10: callout numbers for annotation texts are not correct in source code block ch09l005 HOT 2
- Broken code listing id-s in Chapter 13 HOT 1
- Chapter 10 Serving Static Files HOT 1
- Chapter 10, Docker file should reference gunicorn not manage.py
- Grammatical Error Chapter 11
- Add become: true to ansible playbook Chapter 11 HOT 2
- Flipped blocks in chapter 11
- Chapter 11, container exec before container started
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from book-tdd-web-dev-python.