On 2/15/2017 7:42 AM, poseidon wrote:

what are pth files for?

They are for extending (mainly) lib/site-packages. To repeat what I have posted before: every time I install a new version of Python, I add (copy) python.pth containing 'F:/python' (without the quotes). This makes my directory of modules and packages, F:/python, an extension of the new site-packages. In effect, the .pth file 'installs', all at once, all my personal projects in the new version site-packages. This is done without symlinking each individual project directory. It is also done *without* uninstalling projects from previous versions.

As a result, files can be run with -m from a command line just as they could be when in site-packages. For instance, 'py -3.6 -m xploro' runs F:/python/xploro/__main__ with python 3.6. And I can replace '3.6' with 3.5 or 2.7'

I can also use absolute imports within a project/package the same as if the xploro directory were in each versions site-packages. For instance, 'from xplore import test' imports F:/python/xplore/test. There is no hassle with relative imports, and if I ever put the package on PyPI, no change to imports will be needed.

I just verified that dropping python.pth into the site-packages directory of my locally built python 3.7.0a0 lets me easily test that xploro tests run on the next version of python.

--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to