You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Move themes and templates out of /usr/lib/pythonXX/site-packages/mkdocs and into /usr/share/mkdocs #697
changed the title [-]Mopve themes and templates out of /usr/lib/pythonXX/site-packages/mkdocs and into /usr/share/mkdocs[/-][+]Move themes and templates out of /usr/lib/pythonXX/site-packages/mkdocs and into /usr/share/mkdocs[/+]on Jul 25, 2015
While I think I understand the motivation (packaging, right?) it isn't that simple. Just complying with the link you provided isn't fully compatible with Python packaging. For example, if we have multiple Python versions or multiple installations of MkDocs (in different virtualenvs we could have many combinations) I don't think it will work.
I would consider something that allows the location to be specified in install time if that makes things easier for you.
In addition to the points that @d0ugal makes, what about Windows? MkDocs should work cross-platform so any solution needs to address all platforms. /usr/share/mkdocs will absolutely not work for Windows.
I should note that it is not technically correct to state that themes reside at /usr/lib/pythonXX/site-packages/mkdocs. Rather they reside at /usr/lib/pythonXX/site-packages/<packagename>, where <packagename> is the name of the package which they are distributed with. The default themes are distributed with the "mkdocs" package, so they under "mkdocs". However, other, third party themes would reside under the name of the package they are distributed with. Anyone can make a third party theme, wrap is up as a Python package, upload it to PyPI and their users can then install with pip install packagename and it is installed, regardless of the platform. Additionally, because "entry points" are used to determine the path to the theme, in the config file, the user only needs to enter the name of the theme, not the full path. The discussion which lead to the current implementation is here, where it is all explained more completely.
And as mentioned previously, with different virtual environments, a user could have different themes with the same name, different versions of the same theme, etc all on the same platform, but each in a different virtual environment.
Speaking of virtual environments, Python packaging tools (Distutils and Setuptools) provide variables which point to the appropriate locations on the file system for various types of files in a cross platform way. Therefore, the variable for the "bin" could point to usr/local/bin in one situation, c:\\Pythonx.x\Scripts in another and /path/to/some/virtualenv/bin in a third. Some goes for the "site-packages" dir. That way, when writing custom installation scripts in setup.py, you can reliably write to the appropriate location regardless of the users platform. However, the packaging tools offer no variable which points to a cross-platform location for storing static data. Presumably, for that reason, virtualenv does not support such a feature either. Therefore, if MkDocs created such an installation system, it would be one-off and MkDocs would then require every third party theme to replicate it. Seems like a bad idea to me.
If you really care about this I would suggest taking it upstream to virtualenv/distutils/setuptools.
I should have been more precise in explaining the issue. The issue is that the theme location should be customizable at install time, with suitably chosen defaults (which would be /usr/share/mkdocs on linux, I have no idea about windows as I don't use it). Setuptools already supports this, and has for some time, it's just that mkdocs isn't making use of it:
Dumping the themes under the python package directory isn't consistent with python packaging design conventions or the FHS. Similarly, other packages providing themes for mkdocs would rightly install them using the same mechanism (translating to defaulting under /usr/share on linux, and wherever else on windows).
... with suitably chosen defaults (which would be /usr/share/mkdocs on linux
No, it would be /usr/share/<packagename>. And that means that third party themes would not be under /usr/share/mkdocs, they would be under /usr/share/otherpackename. Now, how does MkdDocs find them without making the user enter the full path (the config settings need to be non-platform specific as well)? The solution is "entry points". But they only work if the location is on the Python path. I don't know how to resolve this issue any other way.
Setuptools already supports this, and has for some time
Ok, I forgot about that, however it is interesting to note the following from a few sections down.
setuptools does not install these data files in a separate location, however. They are bundled inside the egg file or directory, alongside the Python modules and packages.
So, in the end, this changes nothing. All that feature of Setuptools does is provide a way to include data files in your package to distribute to others. It does not assist with installing the data files in an appropriate cross platform location.
And as far as I can tell, virtualenv offers no such support either. Until that happens, I think this is a non-starter. In other words, all static data files must be installed per Python install, not globally. There is no way to do that other than within the package directory. So, if you want an overridable default, the current location is the correct default. But I don't know how you would have MkDocs find your themes if the default was overridden on a given user's system. I suppose an Environment Variable would work, but those have generally been less than ideal in any Python package that I've seen use them (and they are not new user friendly either, especially in virtualenvs -- I don't recall does that even work?).
OK, I had totally missed the point that setuptools doesn't do the same thing that distutils does with installing data, you're entirely right. That's quite ugly engineering by the setuptools folks, IMO. I see the win of that ugliness is the entry points mechanism you rely on, so yeah, this isn't going to be an easy fix. The only way I can see of engineering this out is for mkdocs to introduce a notion of a theme search path that is set in a config directory that other packages can add files to which append/prepends to that search path. Or fixing setuptools to also search under /usr/share/pythonXX/ for data files when using the entry point infrastructure. Oh well, this isn't the simple issue I thought it was.
I guess this should be closed - I won't do so though, just in case you wanted to keep it open for future tracking - I'll leave it up to you. Thanks for the responses though, and taking the time to educate me as to why things are the way they are.
Activity
[-]Mopve themes and templates out of /usr/lib/pythonXX/site-packages/mkdocs and into /usr/share/mkdocs[/-][+]Move themes and templates out of /usr/lib/pythonXX/site-packages/mkdocs and into /usr/share/mkdocs[/+]d0ugal commentedon Jul 25, 2015
While I think I understand the motivation (packaging, right?) it isn't that simple. Just complying with the link you provided isn't fully compatible with Python packaging. For example, if we have multiple Python versions or multiple installations of MkDocs (in different virtualenvs we could have many combinations) I don't think it will work.
I would consider something that allows the location to be specified in install time if that makes things easier for you.
waylan commentedon Jul 25, 2015
In addition to the points that @d0ugal makes, what about Windows? MkDocs should work cross-platform so any solution needs to address all platforms.
/usr/share/mkdocswill absolutely not work for Windows.I should note that it is not technically correct to state that themes reside at
/usr/lib/pythonXX/site-packages/mkdocs. Rather they reside at/usr/lib/pythonXX/site-packages/<packagename>, where<packagename>is the name of the package which they are distributed with. The default themes are distributed with the "mkdocs" package, so they under "mkdocs". However, other, third party themes would reside under the name of the package they are distributed with. Anyone can make a third party theme, wrap is up as a Python package, upload it to PyPI and their users can then install withpip install packagenameand it is installed, regardless of the platform. Additionally, because "entry points" are used to determine the path to the theme, in the config file, the user only needs to enter the name of the theme, not the full path. The discussion which lead to the current implementation is here, where it is all explained more completely.And as mentioned previously, with different virtual environments, a user could have different themes with the same name, different versions of the same theme, etc all on the same platform, but each in a different virtual environment.
Speaking of virtual environments, Python packaging tools (Distutils and Setuptools) provide variables which point to the appropriate locations on the file system for various types of files in a cross platform way. Therefore, the variable for the "bin" could point to
usr/local/binin one situation,c:\\Pythonx.x\Scriptsin another and/path/to/some/virtualenv/binin a third. Some goes for the "site-packages" dir. That way, when writing custom installation scripts in setup.py, you can reliably write to the appropriate location regardless of the users platform. However, the packaging tools offer no variable which points to a cross-platform location for storing static data. Presumably, for that reason, virtualenv does not support such a feature either. Therefore, if MkDocs created such an installation system, it would be one-off and MkDocs would then require every third party theme to replicate it. Seems like a bad idea to me.If you really care about this I would suggest taking it upstream to virtualenv/distutils/setuptools.
jonathanunderwood commentedon Jul 25, 2015
OK, thanks for your responses.
I should have been more precise in explaining the issue. The issue is that the theme location should be customizable at install time, with suitably chosen defaults (which would be /usr/share/mkdocs on linux, I have no idea about windows as I don't use it). Setuptools already supports this, and has for some time, it's just that mkdocs isn't making use of it:
http://peak.telecommunity.com/DevCenter/setuptools#including-data-files
Dumping the themes under the python package directory isn't consistent with python packaging design conventions or the FHS. Similarly, other packages providing themes for mkdocs would rightly install them using the same mechanism (translating to defaulting under /usr/share on linux, and wherever else on windows).
waylan commentedon Jul 26, 2015
No, it would be
/usr/share/<packagename>. And that means that third party themes would not be under/usr/share/mkdocs, they would be under/usr/share/otherpackename. Now, how does MkdDocs find them without making the user enter the full path (the config settings need to be non-platform specific as well)? The solution is "entry points". But they only work if the location is on the Python path. I don't know how to resolve this issue any other way.Ok, I forgot about that, however it is interesting to note the following from a few sections down.
So, in the end, this changes nothing. All that feature of Setuptools does is provide a way to include data files in your package to distribute to others. It does not assist with installing the data files in an appropriate cross platform location.
And as far as I can tell, virtualenv offers no such support either. Until that happens, I think this is a non-starter. In other words, all static data files must be installed per Python install, not globally. There is no way to do that other than within the package directory. So, if you want an overridable default, the current location is the correct default. But I don't know how you would have MkDocs find your themes if the default was overridden on a given user's system. I suppose an Environment Variable would work, but those have generally been less than ideal in any Python package that I've seen use them (and they are not new user friendly either, especially in virtualenvs -- I don't recall does that even work?).
jonathanunderwood commentedon Jul 26, 2015
OK, I had totally missed the point that setuptools doesn't do the same thing that distutils does with installing data, you're entirely right. That's quite ugly engineering by the setuptools folks, IMO. I see the win of that ugliness is the entry points mechanism you rely on, so yeah, this isn't going to be an easy fix. The only way I can see of engineering this out is for mkdocs to introduce a notion of a theme search path that is set in a config directory that other packages can add files to which append/prepends to that search path. Or fixing setuptools to also search under /usr/share/pythonXX/ for data files when using the entry point infrastructure. Oh well, this isn't the simple issue I thought it was.
jonathanunderwood commentedon Jul 26, 2015
I guess this should be closed - I won't do so though, just in case you wanted to keep it open for future tracking - I'll leave it up to you. Thanks for the responses though, and taking the time to educate me as to why things are the way they are.