{"html_url": "https://github.com/simonw/datasette/issues/928#issuecomment-672379897", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/928", "id": 672379897, "node_id": "MDEyOklzc3VlQ29tbWVudDY3MjM3OTg5Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-12T00:07:49Z", "updated_at": "2022-02-23T16:19:47Z", "author_association": "OWNER", "body": "Made this into a TIL: https://til.simonwillison.net/python/call-pip-programatically", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 677272618, "label": "Test failures caused by failed attempts to mock pip"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/928#issuecomment-672373061", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/928", "id": 672373061, "node_id": "MDEyOklzc3VlQ29tbWVudDY3MjM3MzA2MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-11T23:56:19Z", "updated_at": "2020-08-11T23:56:19Z", "author_association": "OWNER", "body": "New implementation of the `install` command:\r\nhttps://github.com/simonw/datasette/blob/afdeda8216d4d3027f87583ccdbef17ad85022ef/datasette/cli.py#L235-L240", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 677272618, "label": "Test failures caused by failed attempts to mock pip"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/928#issuecomment-672372465", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/928", "id": 672372465, "node_id": "MDEyOklzc3VlQ29tbWVudDY3MjM3MjQ2NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-11T23:54:28Z", "updated_at": "2020-08-11T23:54:28Z", "author_association": "OWNER", "body": "While debugging this I found a useful clue in https://github.com/pypa/pip/blob/e060970d51c5946beac8447eb95585d83019582d/src/pip/_internal/cli/main.py#L23-L47\r\n\r\n```\r\n# Do not import and use main() directly! Using it directly is actively\r\n# discouraged by pip's maintainers. The name, location and behavior of\r\n# this function is subject to change, so calling it directly is not\r\n# portable across different pip versions.\r\n\r\n# In addition, running pip in-process is unsupported and unsafe. This is\r\n# elaborated in detail at\r\n# https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program.\r\n# That document also provides suggestions that should work for nearly\r\n# all users that are considering importing and using main() directly.\r\n\r\n# However, we know that certain users will still want to invoke pip\r\n# in-process. If you understand and accept the implications of using pip\r\n# in an unsupported manner, the best approach is to use runpy to avoid\r\n# depending on the exact location of this entry point.\r\n\r\n# The following example shows how to use runpy to invoke pip in that\r\n# case:\r\n#\r\n# sys.argv = [\"pip\", your, args, here]\r\n# runpy.run_module(\"pip\", run_name=\"__main__\")\r\n#\r\n# Note that this will exit the process after running, unlike a direct\r\n# call to main. As it is not safe to do any processing after calling\r\n# main, this should not be an issue in practice.\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 677272618, "label": "Test failures caused by failed attempts to mock pip"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/928#issuecomment-672372197", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/928", "id": 672372197, "node_id": "MDEyOklzc3VlQ29tbWVudDY3MjM3MjE5Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-11T23:53:38Z", "updated_at": "2020-08-11T23:53:38Z", "author_association": "OWNER", "body": "Caused by the tests for #925", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 677272618, "label": "Test failures caused by failed attempts to mock pip"}, "performed_via_github_app": null}