def run_pip_based_installations(env, pip_invocation, requirements, download_cache_folder): # 'pip' download caching system usage notes: # 1. When not installing from our own local installation storage folder, we # can still use pip's internal download caching system. # 2. We must not enable pip's internal download caching system when # installing from our own local installation storage folder. In that # case, pip attempts to populate its cache from our local installation # folder, but that logic fails when our folder contains a wheel (.whl) # distribution. More precisely, it fails attempting to store the wheel # distribution file's content type information. Tested using Python # 3.4.0 & pip 1.5.4. try: pip_options = ["install"] if config.installation_cache_folder() is None: pip_options.extend(pip_download_cache_options( download_cache_folder)) else: # pip allows us to identify a local folder containing predownloaded # installation packages using its '-f' command-line option taking # an URL parameter. However, it does not require the URL to be # URL-quoted and it does not even seem to recognize URLs containing # %xx escaped characters. Tested using an installation cache folder # path containing spaces with Python 3.4.0 & pip 1.5.4. installation_cache_folder_URL = utility.path_to_URL( config.installation_cache_folder(), escape=False) pip_options.extend(["-f", installation_cache_folder_URL, "--no-index"]) env.execute(pip_invocation + pip_options + requirements) except (KeyboardInterrupt, SystemExit): raise except Exception: raise EnvironmentSetupError("pip based installation failed.")
def run_pip_based_installations(env, pip_invocation, requirements, download_cache_folder): # 'pip' download caching system usage notes: # 1. When not installing from our own local installation storage folder, we # can still use pip's internal download caching system. # 2. We must not enable pip's internal download caching system when # installing from our own local installation storage folder. In that # case, pip attempts to populate its cache from our local installation # folder, but that logic fails when our folder contains a wheel (.whl) # distribution. More precisely, it fails attempting to store the wheel # distribution file's content type information. Tested using Python # 3.4.0 & pip 1.5.4. try: pip_options = ["install"] if config.installation_cache_folder() is None: pip_options.extend( pip_download_cache_options(download_cache_folder)) else: # pip allows us to identify a local folder containing predownloaded # installation packages using its '-f' command-line option taking # an URL parameter. However, it does not require the URL to be # URL-quoted and it does not even seem to recognize URLs containing # %xx escaped characters. Tested using an installation cache folder # path containing spaces with Python 3.4.0 & pip 1.5.4. installation_cache_folder_URL = utility.path_to_URL( config.installation_cache_folder(), escape=False) pip_options.extend( ["-f", installation_cache_folder_URL, "--no-index"]) env.execute(pip_invocation + pip_options + requirements) except (KeyboardInterrupt, SystemExit): raise except Exception: raise EnvironmentSetupError("pip based installation failed.")
def setuptools_install_options(local_storage_folder): """ Return options to make setuptools use installations from the given folder. No other installation source is allowed. """ if local_storage_folder is None: return [] # setuptools expects its find-links parameter to contain a list of link # sources (either local paths, file: URLs pointing to folders or URLs # pointing to a file containing HTML links) separated by spaces. That means # that, when specifying such items, whether local paths or URLs, they must # not contain spaces. The problem can be worked around by using a local # file URL, since URLs can contain space characters encoded as '%20' (for # more detailed information see below). # # Any URL referencing a folder needs to be specified with a trailing '/' # character in order for setuptools to correctly recognize it as a folder. # # All this has been tested using Python 2.4.3/2.4.4 & setuptools 1.4/1.4.2 # as well as Python 3.4 & setuptools 3.3. # # Supporting paths with spaces - method 1: # ---------------------------------------- # One way would be to prepare a link file and pass an URL referring to that # link file. The link file needs to contain a list of HTML link tags # (<a href="..."/>), one for every item stored inside the local storage # folder. If a link file references a folder whose name matches the desired # requirement name, it will be searched recursively (as described in method # 2 below). # # Note that in order for setuptools to recognize a local link file URL # correctly, the file needs to be named with the '.html' extension. That # will cause the underlying urllib2.open() operation to return the link # file's content type as 'text/html' which is required for setuptools to # recognize a valid link file. # # Supporting paths with spaces - method 2: # ---------------------------------------- # Another possible way is to use an URL referring to the local storage # folder directly. This will cause setuptools to prepare and use a link # file internally - with its content read from a 'index.html' file located # in the given local storage folder, if it exists, or constructed so it # contains HTML links to all top-level local storage folder items, as # described for method 1 above. if " " in local_storage_folder: find_links_param = utility.path_to_URL(local_storage_folder) if find_links_param[-1] != "/": find_links_param += "/" else: find_links_param = local_storage_folder return ["-f", find_links_param, "--allow-hosts=None"]