Closed ntoxeg closed 2 years ago
Good catch! I was first going to mention that this seems minor, but if it can really break pip
, then ooooh boy that is nasty.
How can I quickly test this? I assume I should try installing MineRL on Python version older than 3.6.6, judging by the commit?
@Miffyli if you want to reproduce my issue, it’s a bit contrived:
pip
, including minerl
./home/<user>/.local/lib/python<ver>/site-packages
to PYTHONPATH
.pip
...The problem is that PYTHONPATH
adds paths to sys.path
before stdlib. That means that typing
will shadow the standard library.
Even more confusingly you can reproduce this with a new Python version. In the above error I am on Python 3.10…
The weird thing is that installing typing
through pip
only installs something like typing-3.7.4.3
. I don’t really want to spend time figuring out why that is…
The conditional requirement I added will not break anything — if you are on Python >= 3.6.6 then you have everything in stdlib anyway (typing
is just a back-port). Thus, it’s safe to limit this requirement only to those that actually have an older Python version. It will spare some people with unusual setups a lot of work.
Hey! Sorry for taking so long on this (just returned from the vacations). Things look good but I have but one question: the recommendation is to do <=3.5
, but you have 3.6.6
. Could you quickly explain this?
Sidenote: MineRL is not specifically made to support older Pythons (e.g. tests have format-strings), but this is still nice to have to avoid breaking things horribly 😅
@Miffyli because you install typing>=3.6.6
, in other words you require that the typing
module is at least from the Python version of 3.6.6
. So I added a condition of installing it iff actual Python version is less than that, because if you have at least 3.6.6
, then installing typing
does nothing.
If you have Python, say, 3.5
(or even 3.6.0
), it is not certain that not having typing
will work — there might be some changes in the later versions. Ergo, the correct rule in general is to write typing>=X; python_version<“X”
Ah right, I learned something new today! Thank you for the explanation :). LGTM and merging.
As per the description of the
typing
package (https://pypi.org/project/typing/):In some cases the shadowing can occur and it results in errors like this:
And it’s very serious because it prevents you from using
pip
itself.Of course, I conditioned the requirement on the actual version you need.