home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 672372465

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/928#issuecomment-672372465 https://api.github.com/repos/simonw/datasette/issues/928 672372465 MDEyOklzc3VlQ29tbWVudDY3MjM3MjQ2NQ== 9599 2020-08-11T23:54:28Z 2020-08-11T23:54:28Z OWNER

While debugging this I found a useful clue in https://github.com/pypa/pip/blob/e060970d51c5946beac8447eb95585d83019582d/src/pip/_internal/cli/main.py#L23-L47

```

Do not import and use main() directly! Using it directly is actively

discouraged by pip's maintainers. The name, location and behavior of

this function is subject to change, so calling it directly is not

portable across different pip versions.

In addition, running pip in-process is unsupported and unsafe. This is

elaborated in detail at

https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program.

That document also provides suggestions that should work for nearly

all users that are considering importing and using main() directly.

However, we know that certain users will still want to invoke pip

in-process. If you understand and accept the implications of using pip

in an unsupported manner, the best approach is to use runpy to avoid

depending on the exact location of this entry point.

The following example shows how to use runpy to invoke pip in that

case:

sys.argv = ["pip", your, args, here]

runpy.run_module("pip", run_name="main")

Note that this will exit the process after running, unlike a direct

call to main. As it is not safe to do any processing after calling

main, this should not be an issue in practice.

```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
677272618  
Powered by Datasette · Queries took 1.173ms · About: github-to-sqlite