parent
dc97101d47
commit
f79b4bd324
2 changed files with 49 additions and 0 deletions
38
README.md
38
README.md
|
@ -47,6 +47,44 @@ support is still experimental.
|
|||
|
||||
/python version
|
||||
|
||||
## Using virtualenv
|
||||
If you want to install dependencies inside a virtualenv, rather than
|
||||
globally for your system or user, you can use a virtualenv.
|
||||
Weechat-Matrix will automatically use any virtualenv it finds in a
|
||||
directory called `venv` next to its main Python file (after resolving
|
||||
symlinks). Typically, this means `~/.weechat/python/venv`.
|
||||
|
||||
To create such a virtualenv, you can use something like below. This only
|
||||
needs to happen once:
|
||||
|
||||
```
|
||||
virtualenv ~/.weechat/python/venv
|
||||
```
|
||||
|
||||
Then, activate the virtualenv:
|
||||
|
||||
```
|
||||
. ~/.weechat/python/venv/bin/activate
|
||||
```
|
||||
|
||||
This needs to be done whenever you want to install packages inside the
|
||||
virtualenv (so before running the `pip install` command documented
|
||||
above.
|
||||
|
||||
|
||||
Once the virtualenv is prepared in the right location, Weechat-Matrix
|
||||
will automatically activate it when the plugin is loaded. This should
|
||||
not affect other plugins, which seem to have a separate Python
|
||||
environment.
|
||||
|
||||
Note that this only supports virtualenv tools that support the
|
||||
[`activate_this.py` way of
|
||||
activation](https://virtualenv.pypa.io/en/latest/userguide/#using-virtualenv-without-bin-python).
|
||||
This includes the `virtualenv` command, but excludes pyvenv and the
|
||||
Python3 `venv` module. In particular, this works if (for a typical
|
||||
installation of `matrix.py`) the file
|
||||
`~/.weechat/python/venv/bin/activate_this.py` exists.
|
||||
|
||||
## Uploads
|
||||
|
||||
Uploads are done using a helper script, the script found under
|
||||
|
|
11
main.py
11
main.py
|
@ -18,6 +18,17 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
# See if there is a `venv` directory next to our script, and use that if
|
||||
# present. This first resolves symlinks, so this also works when we are
|
||||
# loaded through a symlink (e.g. from autoload).
|
||||
# See https://virtualenv.pypa.io/en/latest/userguide/#using-virtualenv-without-bin-python
|
||||
# This does not support pyvenv or the python3 venv module, which do not
|
||||
# create an activate_this.py: https://stackoverflow.com/questions/27462582
|
||||
activate_this = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'venv', 'bin', 'activate_this.py')
|
||||
if os.path.exists(activate_this):
|
||||
exec(open(activate_this).read(), {'__file__': activate_this})
|
||||
|
||||
import socket
|
||||
import ssl
|
||||
import textwrap
|
||||
|
|
Loading…
Reference in a new issue