Skip to content

Commit

Permalink
Allow bytecode again (matrix-org#9502)
Browse files Browse the repository at this point in the history
In matrix-org#75, bytecode was disabled (from a bit of FUD back in `python<2.4` days, according to dev chat), I think it's safe enough to enable it again.

Added in `__pycache__/` and `.pyc`/`.pyd` to `.gitignore`, to extra-insure compiled files don't get committed.

`Signed-off-by: Jonathan de Jong <[email protected]>`
  • Loading branch information
ShadowJonathan authored Feb 26, 2021
1 parent ddb2402 commit e12077a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*.egg
*.egg-info
*.lock
*.pyc
*.py[cod]
*.snap
*.tac
_trial_temp/
_trial_temp*/
/out
.DS_Store
__pycache__/

# stuff that is likely to exist when you run a server locally
/*.db
Expand Down
1 change: 1 addition & 0 deletions changelog.d/9502.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow python to generate bytecode for synapse.
6 changes: 3 additions & 3 deletions debian/build_virtualenv
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ trap "rm -r $tmpdir" EXIT
cp -r tests "$tmpdir"

PYTHONPATH="$tmpdir" \
"${TARGET_PYTHON}" -B -m twisted.trial --reporter=text -j2 tests
"${TARGET_PYTHON}" -m twisted.trial --reporter=text -j2 tests

# build the config file
"${TARGET_PYTHON}" -B "${VIRTUALENV_DIR}/bin/generate_config" \
"${TARGET_PYTHON}" "${VIRTUALENV_DIR}/bin/generate_config" \
--config-dir="/etc/matrix-synapse" \
--data-dir="/var/lib/matrix-synapse" |
perl -pe '
Expand All @@ -87,7 +87,7 @@ PYTHONPATH="$tmpdir" \
' > "${PACKAGE_BUILD_DIR}/etc/matrix-synapse/homeserver.yaml"

# build the log config file
"${TARGET_PYTHON}" -B "${VIRTUALENV_DIR}/bin/generate_log_config" \
"${TARGET_PYTHON}" "${VIRTUALENV_DIR}/bin/generate_log_config" \
--output-file="${PACKAGE_BUILD_DIR}/etc/matrix-synapse/log.yaml"

# add a dependency on the right version of python to substvars.
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
matrix-synapse-py3 (1.29.0) UNRELEASED; urgency=medium

[ Jonathan de Jong ]
* Remove the python -B flag (don't generate bytecode) in scripts and documentation.

-- Synapse Packaging team <[email protected]> Fri, 26 Feb 2021 14:41:31 +0100

matrix-synapse-py3 (1.28.0) stable; urgency=medium

* New synapse release 1.28.0.
Expand Down
2 changes: 1 addition & 1 deletion debian/synctl.1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Configuration file may be generated as follows:
.
.nf

$ python \-B \-m synapse\.app\.homeserver \-c config\.yaml \-\-generate\-config \-\-server\-name=<server name>
$ python \-m synapse\.app\.homeserver \-c config\.yaml \-\-generate\-config \-\-server\-name=<server name>
.
.fi
.
Expand Down
2 changes: 1 addition & 1 deletion debian/synctl.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ process.

Configuration file may be generated as follows:

$ python -B -m synapse.app.homeserver -c config.yaml --generate-config --server-name=<server name>
$ python -m synapse.app.homeserver -c config.yaml --generate-config --server-name=<server name>

## ENVIRONMENT

Expand Down
2 changes: 0 additions & 2 deletions synapse/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

from synapse import python_dependencies # noqa: E402

sys.dont_write_bytecode = True

logger = logging.getLogger(__name__)

try:
Expand Down
3 changes: 1 addition & 2 deletions synctl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import yaml

from synapse.config import find_config_files

SYNAPSE = [sys.executable, "-B", "-m", "synapse.app.homeserver"]
SYNAPSE = [sys.executable, "-m", "synapse.app.homeserver"]

GREEN = "\x1b[1;32m"
YELLOW = "\x1b[1;33m"
Expand Down Expand Up @@ -117,7 +117,6 @@ def start_worker(app: str, configfile: str, worker_configfile: str) -> bool:

args = [
sys.executable,
"-B",
"-m",
app,
"-c",
Expand Down

0 comments on commit e12077a

Please sign in to comment.