Skip to content

Add setup_python_venv function - #1245

Merged
jmlapre merged 12 commits into
sstsimulator:develfrom
jmlapre:1244-use-python-dependencies-installed-in-virtual-environment
Jul 24, 2026
Merged

Add setup_python_venv function#1245
jmlapre merged 12 commits into
sstsimulator:develfrom
jmlapre:1244-use-python-dependencies-installed-in-virtual-environment

Conversation

@jmlapre

@jmlapre jmlapre commented Jun 23, 2026

Copy link
Copy Markdown
Member

No description provided.

@nab880

nab880 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

I encountered similar errors. By installing sympy we enable the polarfly/polarstar tests, which then fail on macOS. I found the root cause, which turns out to be macOS-CI-specific problem.

The polarfly/polarstar python topology generators write their adjacency list to os.getcwd()/topo_data/ and the C++ topology components read it back. On the macOS runner the working directory isn't writable.

I have a tested a fix in sst-elements that changes the write directory the to a tempfile.mkdtemp(). I can create a pull request if we don't want these tests skipped on macOS.

I'm not sure if we'd rather have the CI continue to skip the these tests? -- it we want to skip the tests we just don't install sympy on macOS.

@jmlapre

jmlapre commented Jun 24, 2026

Copy link
Copy Markdown
Member Author

I have a tested a fix in sst-elements that changes the write directory the to a tempfile.mkdtemp(). I can create a pull request if we don't want these tests skipped on macOS.

Yeah, let's go that route. Let me know when that PR is available so we can get it merged quickly. Then we can continue with this change.

Comment thread buildsys/bamboo.sh Outdated
Comment thread buildsys/bamboo.sh Outdated
@nab880

nab880 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The elements PR went through, this should pass testing now.

@nab880

nab880 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Seems the issue is now related to the bamboo.sh not putting the site-packages on the PYTHONPATH (in addition to the activation path).
after the line:
export SST_PYTHON_HOME="${venv_dir}"
I think if we add:

venv_site_packages="$("${venv_dir}/bin/python" -c 'import sysconfig; print(sysconfig.get_path("purelib"))')"
export PYTHONPATH="${venv_site_packages}${PYTHONPATH:+:${PYTHONPATH}}"

It will fix the issue.

Confirmed locally on macOS: SST's sstsim.x embedded Python doesn't pick up the venv via activation (sys.prefix stays at the base python), so import sympy fails in the simulation subprocess → polarfly/polarstar construction aborts → empty output. Putting the venv site-packages on PYTHONPATH fixes it. Not sure why we see this on mac, but not Linux though.

@berquist

berquist commented Jul 1, 2026

Copy link
Copy Markdown
Member

I can confirm that I don't see this on Linux but do on macOS. I would like to understand why.

$ less /private/var/folders/mv/cxdf9v7s4tj9_xrqn0bjmmhw0046c5/T/tmp.EzbpMuWSau/home/runner/work/sst-sqe/sst-deps-user-dir/devel/trunk/sst_test_outputs/run_data/test_merlin_polarfly_455_test.err
Traceback (most recent call last):
  File "/private/var/folders/mv/cxdf9v7s4tj9_xrqn0bjmmhw0046c5/T/tmp.EzbpMuWSau/home/runner/work/sst-sqe/sst-deps-user-dir/devel/trunk/sst-elements/src/sst/elements/merlin/tests/polarfly_455_test.py", line 67, in <module>
    system.build()
    ~~~~~~~~~~~~^^
  File "pymerlin-base.py", line 967, in build
  File "pymerlin-base.py", line 635, in build
  File "topology/pymerlin-topo-polarfly.py", line 455, in _build_impl
  File "topology/pymerlin-topo-polarfly.py", line 402, in generate
  File "topology/pymerlin-topo-polarfly.py", line 329, in make
  File "topology/pymerlin-topo-polarfly.py", line 45, in __init__
Exception: --> Did not load Sympy Polys Galoistools : module required for field construction
FATAL: # SSTPythonModel: Execution of model construction function failed
SST Fatal Backtrace Information:
    0 : 0   sstsim.x                            0x0000000104da5584 _ZNK3SST6Output5fatalEjPKcS2_iS2_z + 660
    1 : 1   sstsim.x                            0x0000000104f06aa4 _ZN3SST4Core24SSTPythonModelDefinition17createConfigGraphEv + 504
    2 : 2   sstsim.x                            0x0000000104d35500 main + 2728
    3 : 3   dyld                                0x000000018498fe00 start + 6992

@berquist

berquist commented Jul 1, 2026

Copy link
Copy Markdown
Member

It looks like my addition of galois is triggering a different unrelated (but real) test failure on Linux. If https://sst-jenkins.sandia.gov/job/SST__AnyBranch_Combo_Tester_sst-test/560/console fails then there is a problem with the reference data for that particular test; I bet the test is being skipped in the Autotester. I will probably need to revert that commit in this PR until that fix is in.

@berquist

berquist commented Jul 1, 2026

Copy link
Copy Markdown
Member

It's failing in Jenkins because of pip install not being set up for the SSL cert/PyPI mirror...there is a ~/.config/pip/pip.conf that would need to be added, or maybe environment variables, for it to work.

@jmlapre
jmlapre force-pushed the 1244-use-python-dependencies-installed-in-virtual-environment branch from 59f8cbf to 3f81a18 Compare July 6, 2026 21:17
@berquist

berquist commented Jul 8, 2026

Copy link
Copy Markdown
Member

Current status is basically the last two comments:

  1. I can replicate the GitHub Actions test failures locally: the reference for test_merlin_anytopo_jellyfish needs to be updated.
  2. For internal testing, in the Ubuntu 26.04 VM as the CI user, I can pip install dependencies from PyPI into a venv just fine, but when triggered through Jenkins there are SSL problems.

Next steps:

  1. Update test reference in elements repo
  2. Investigate the env difference with Jenkins

@berquist

berquist commented Jul 8, 2026

Copy link
Copy Markdown
Member
  1. Updating the test reference works but is blocked upstream from being submitted by Apply pre-commit fixes sst-elements#2702
  2. By using the fact that Jenkins can use the pip cache, I've determined that it is the older version of setuptools or wheel that is actually causing problems in Jenkins; when those are updated, the rest of the PyPI dependencies install in Jenkins without modification to the environment. It would temporarily work to use the local pip cache but it's better to solve the underlying problem.

@jmlapre
jmlapre force-pushed the 1244-use-python-dependencies-installed-in-virtual-environment branch from 3f81a18 to 85038e5 Compare July 14, 2026 15:25
@jmlapre
jmlapre force-pushed the 1244-use-python-dependencies-installed-in-virtual-environment branch from 5bb2e9b to 6920fb9 Compare July 22, 2026 17:16
@jmlapre
jmlapre requested a review from berquist July 22, 2026 18:13
@jmlapre
jmlapre force-pushed the 1244-use-python-dependencies-installed-in-virtual-environment branch from a0d6826 to 601e477 Compare July 23, 2026 18:58
@jmlapre
jmlapre merged commit d10e108 into sstsimulator:devel Jul 24, 2026
12 checks passed
@jmlapre
jmlapre deleted the 1244-use-python-dependencies-installed-in-virtual-environment branch July 24, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants