Skip to content

Commit f5e3add

Browse files
committed
Support python binaries that are not called "python"
1 parent c12b4a4 commit f5e3add

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

Makefile

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SHELL := /bin/bash
2+
PYTHON ?= python
23

34
NS ?= abhinavsingh
45
IMAGE_NAME ?= proxy.py
@@ -40,23 +41,23 @@ all: lib-test
4041

4142
https-certificates:
4243
# Generate server key
43-
python -m proxy.common.pki gen_private_key \
44+
$(PYTHON) -m proxy.common.pki gen_private_key \
4445
--private-key-path $(HTTPS_KEY_FILE_PATH)
45-
python -m proxy.common.pki remove_passphrase \
46+
$(PYTHON) -m proxy.common.pki remove_passphrase \
4647
--private-key-path $(HTTPS_KEY_FILE_PATH)
4748
# Generate server certificate
48-
python -m proxy.common.pki gen_public_key \
49+
$(PYTHON) -m proxy.common.pki gen_public_key \
4950
--private-key-path $(HTTPS_KEY_FILE_PATH) \
5051
--public-key-path $(HTTPS_CERT_FILE_PATH)
5152

5253
sign-https-certificates:
5354
# Generate CSR request
54-
python -m proxy.common.pki gen_csr \
55+
$(PYTHON) -m proxy.common.pki gen_csr \
5556
--csr-path $(HTTPS_CSR_FILE_PATH) \
5657
--private-key-path $(HTTPS_KEY_FILE_PATH) \
5758
--public-key-path $(HTTPS_CERT_FILE_PATH)
5859
# Sign CSR with CA
59-
python -m proxy.common.pki sign_csr \
60+
$(PYTHON) -m proxy.common.pki sign_csr \
6061
--csr-path $(HTTPS_CSR_FILE_PATH) \
6162
--crt-path $(HTTPS_SIGNED_CERT_FILE_PATH) \
6263
--hostname localhost \
@@ -65,23 +66,23 @@ sign-https-certificates:
6566

6667
ca-certificates:
6768
# Generate CA key
68-
python -m proxy.common.pki gen_private_key \
69+
$(PYTHON) -m proxy.common.pki gen_private_key \
6970
--private-key-path $(CA_KEY_FILE_PATH)
70-
python -m proxy.common.pki remove_passphrase \
71+
$(PYTHON) -m proxy.common.pki remove_passphrase \
7172
--private-key-path $(CA_KEY_FILE_PATH)
7273
# Generate CA certificate
73-
python -m proxy.common.pki gen_public_key \
74+
$(PYTHON) -m proxy.common.pki gen_public_key \
7475
--private-key-path $(CA_KEY_FILE_PATH) \
7576
--public-key-path $(CA_CERT_FILE_PATH)
7677
# Generate key that will be used to generate domain certificates on the fly
7778
# Generated certificates are then signed with CA certificate / key generated above
78-
python -m proxy.common.pki gen_private_key \
79+
$(PYTHON) -m proxy.common.pki gen_private_key \
7980
--private-key-path $(CA_SIGNING_KEY_FILE_PATH)
80-
python -m proxy.common.pki remove_passphrase \
81+
$(PYTHON) -m proxy.common.pki remove_passphrase \
8182
--private-key-path $(CA_SIGNING_KEY_FILE_PATH)
8283

8384
lib-check:
84-
python check.py
85+
$(PYTHON) check.py
8586

8687
lib-clean:
8788
find . -name '*.pyc' -exec rm -f {} +
@@ -107,10 +108,10 @@ lib-dep:
107108
pip install "setuptools>=42"
108109

109110
lib-pre-commit:
110-
python -m pre_commit run --hook-stage manual --all-files -v
111+
$(PYTHON) -m pre_commit run --hook-stage manual --all-files -v
111112

112113
lib-lint:
113-
python -m tox -e lint
114+
$(PYTHON) -m tox -e lint
114115

115116
lib-flake8:
116117
tox -e lint -- flake8 --all-files
@@ -119,12 +120,12 @@ lib-mypy:
119120
tox -e lint -- mypy --all-files
120121

121122
lib-pytest:
122-
python -m tox -e python -- -v
123+
$(PYTHON) -m tox -e python -- -v
123124

124125
lib-test: lib-clean lib-check lib-lint lib-pytest
125126

126127
lib-package: lib-clean lib-check
127-
python -m tox -e cleanup-dists,build-dists,metadata-validation
128+
$(PYTHON) -m tox -e cleanup-dists,build-dists,metadata-validation
128129

129130
lib-release-test: lib-package
130131
twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/*
@@ -133,7 +134,7 @@ lib-release: lib-package
133134
twine upload dist/*
134135

135136
lib-doc:
136-
python -m tox -e build-docs && \
137+
$(PYTHON) -m tox -e build-docs && \
137138
$(OPEN) .tox/build-docs/docs_out/index.html || true
138139

139140
lib-coverage: lib-clean
@@ -145,7 +146,7 @@ lib-profile:
145146
sudo py-spy record \
146147
-o profile.svg \
147148
-t -F -s -- \
148-
python -m proxy \
149+
$(PYTHON) -m proxy \
149150
--hostname 127.0.0.1 \
150151
--num-acceptors 1 \
151152
--num-workers 1 \
@@ -161,7 +162,7 @@ lib-speedscope:
161162
-o profile.speedscope.json \
162163
-f speedscope \
163164
-t -F -s -- \
164-
python -m proxy \
165+
$(PYTHON) -m proxy \
165166
--hostname 127.0.0.1 \
166167
--num-acceptors 1 \
167168
--num-workers 1 \

tests/integration/test_integration.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Test the simplest proxy use scenario for smoke.
1212
"""
1313
import os
14+
import sys
1415
import time
1516
import tempfile
1617
import subprocess
@@ -130,10 +131,12 @@ def _tls_interception_flags(ca_cert_suffix: str = '') -> str:
130131
def _gen_https_certificates(request: Any) -> None:
131132
check_output([
132133
'make', 'https-certificates',
134+
'-e', 'PYTHON="%s"' % (sys.executable,),
133135
'-e', 'CERT_DIR=%s/' % (str(CERT_DIR)),
134136
])
135137
check_output([
136138
'make', 'sign-https-certificates',
139+
'-e', 'PYTHON="%s"' % (sys.executable,),
137140
'-e', 'CERT_DIR=%s/' % (str(CERT_DIR)),
138141
])
139142

@@ -142,15 +145,18 @@ def _gen_https_certificates(request: Any) -> None:
142145
def _gen_ca_certificates(request: Any) -> None:
143146
check_output([
144147
'make', 'ca-certificates',
148+
'-e', 'PYTHON="%s"' % (sys.executable,),
145149
'-e', 'CERT_DIR=%s/' % (str(CERT_DIR)),
146150
])
147151
check_output([
148152
'make', 'ca-certificates',
153+
'-e', 'PYTHON="%s"' % (sys.executable,),
149154
'-e', 'CA_CERT_SUFFIX=-chunk',
150155
'-e', 'CERT_DIR=%s/' % (str(CERT_DIR)),
151156
])
152157
check_output([
153158
'make', 'ca-certificates',
159+
'-e', 'PYTHON="%s"' % (sys.executable,),
154160
'-e', 'CA_CERT_SUFFIX=-post',
155161
'-e', 'CERT_DIR=%s/' % (str(CERT_DIR)),
156162
])
@@ -175,7 +181,7 @@ def proxy_py_subprocess(request: Any) -> Generator[int, None, None]:
175181
ca_cert_dir = TEMP_DIR / ('certificates-%s' % run_id)
176182
os.makedirs(ca_cert_dir, exist_ok=True)
177183
proxy_cmd = (
178-
'python', '-m', 'proxy',
184+
sys.executable, '-m', 'proxy',
179185
'--hostname', '127.0.0.1',
180186
'--port', '0',
181187
'--port-file', str(port_file),

0 commit comments

Comments
 (0)