From b90515f8041352a33c6ca7099be38dee0d5a5cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 20 Jul 2018 16:48:06 +0200 Subject: Make install directory if it doesn't exist yet Problem: In Fedora, `sudo python3 setup.py install` installs to /usr/local/lib/pythonX.Y/site-packages. However that directory is not always there as it is not installed together with the python3 package (Fedora packages should not install stuff to /usr/local). When the directory does not exist an installation attempt fails with: [Errno 2] No such file or directory: '/usr/local/lib/python3.7/site-packages/test-easy-install-11875.write-test' Solution: Make the directory if it doesn't exists yet. If user has no permissions, the above error is preserved, yet with root (sudo) it works now. --- setuptools/command/easy_install.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/command') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 05508ceb..5b65b95d 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -450,6 +450,12 @@ class easy_install(Command): instdir = normalize_path(self.install_dir) pth_file = os.path.join(instdir, 'easy-install.pth') + if not os.path.exists(instdir): + try: + os.makedirs(instdir) + except (OSError, IOError): + self.cant_write_to_target() + # Is it a configured, PYTHONPATH, implicit, or explicit site dir? is_site_dir = instdir in self.all_site_dirs -- cgit v1.2.3