Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging: Add pex_binary BUILD metadata for building st2 venv #6307

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Pants: Use **parametrize(...) groups in packaging/BUILD
  • Loading branch information
cognifloyd committed Feb 26, 2025
commit 709518f87eb64127674ab210f663b6daab34dac6
78 changes: 48 additions & 30 deletions packaging/BUILD
Original file line number Diff line number Diff line change
@@ -1,32 +1,50 @@
# We use st2-py*.pex to quickly build a venv (like /opt/stackstorm/st2)
# that includes all requirements and our wheels.
for ic_name, ic in supported_python_interpreter_constraints().items():
pex_binary(
name=f"st2-{ic_name}.pex",
output_path=f"st2-{ic_name}.pex",
interpreter_constraints=ic,
dependencies=[
# this should depend on all python_distribution targets
"//st2actions",
"//st2api",
"//st2auth",
"//st2client",
"//st2common",
"//st2reactor",
"//st2stream",
"//st2tests",
"//contrib/runners/action_chain_runner",
"//contrib/runners/announcement_runner",
"//contrib/runners/http_runner",
"//contrib/runners/inquirer_runner",
"//contrib/runners/local_runner",
"//contrib/runners/noop_runner",
"//contrib/runners/orquesta_runner",
"//contrib/runners/python_runner",
"//contrib/runners/remote_runner",
"//contrib/runners/winrm_runner",
],
include_tools=True, # include pex.tools to populate a venv from the pex
include_sources=False, # always includes generated wheels, so transitive sources not needed
venv_hermetic_scripts=False, # do not add -sE to script shebangs
)
pex_binary(
name="st2.pex",
dependencies=[
# this should depend on all python_distribution targets
"//st2actions",
"//st2api",
"//st2auth",
"//st2client",
"//st2common",
"//st2reactor",
"//st2stream",
"//st2tests",
"//contrib/runners/action_chain_runner",
"//contrib/runners/announcement_runner",
"//contrib/runners/http_runner",
"//contrib/runners/inquirer_runner",
"//contrib/runners/local_runner",
"//contrib/runners/noop_runner",
"//contrib/runners/orquesta_runner",
"//contrib/runners/python_runner",
"//contrib/runners/remote_runner",
"//contrib/runners/winrm_runner",
],
include_tools=True, # include pex.tools to populate a venv from the pex
include_sources=False, # always includes generated wheels, so transitive sources not needed
venv_hermetic_scripts=False, # do not add -sE to script shebangs
# 1 parametrize group per python minor version in [DEFAULT].st2_interpreter_constraints in pants.toml
**parametrize(
"py38",
output_path="st2-py38.pex",
interpreter_constraints=["CPython==3.8.*"],
),
**parametrize(
"py39",
output_path="st2-py39.pex",
interpreter_constraints=["CPython==3.9.*"],
),
**parametrize(
"py310",
output_path="st2-py310.pex",
interpreter_constraints=["CPython==3.10.*"],
),
**parametrize(
"py311",
output_path="st2-py311.pex",
interpreter_constraints=["CPython==3.11.*"],
),
)
10 changes: 0 additions & 10 deletions pants-plugins/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@
# limitations under the License.


# use this to parametrize targets as necessary.
# eg: interpreter_constraints=parametrize(**supported_python_interpreter_constraints)
def supported_python_interpreter_constraints():
return dict(
py36=["CPython==3.6.*"],
py37=["CPython==3.7.*"],
py38=["CPython==3.8.*"],
)


def st2_publish_repos():
"""Return the list of repos twine should publish to.

Expand Down
3 changes: 1 addition & 2 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ root_patterns = [
# DEFAULT has values that we can reuse/interpolate below
[DEFAULT]
# This is the range of python versions that we support.
# Make sure to also update supported_interpreter_constraints in pants-plugins/macros.py
# (which is for use in parametrize() and similar ic-specific use-cases).
# On update, make sure to also update parametrizations in packaging/BUILD.
st2_interpreter_constraints = "CPython>=3.8.1,<3.12"

# This should match the pants interpreter_constraints:
Expand Down