-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Make sure that 'tox -erust' fails on bad RC. #13753
Merged
+50
−32
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1715e32
Make sure that 'tox -erust' fails on bad RC.
kevinhartman 663eaa8
Use script to run cargo test, simplify subprocess call.
kevinhartman 56a5252
Use PYTHONPATH instead of PYTHONUSERBASE.
kevinhartman 5ffe847
Add CWD to search path when running run_cargo_test.py
kevinhartman af78b0f
Update docs.
kevinhartman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading status checks…
Use script to run cargo test, simplify subprocess call.
commit 663eaa8b9169895f694c12c198c4c899222197cf
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# This code is part of Qiskit. | ||
# | ||
# (C) Copyright IBM 2025. | ||
# | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
""" | ||
Utility script to invoke cargo test within the current Python environment. | ||
|
||
Notably, this sets up the environment variables necessary for Qiskit to be | ||
found by PyO3 / our Rust test executable. | ||
""" | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
import sysconfig | ||
|
||
# This allows the Python interpreter baked into our test executable to find the | ||
# Qiskit installed in the active environment. | ||
os.environ["PYTHONUSERBASE"] = sys.prefix | ||
|
||
# On Linux, the test executable's RPATH doesn't contain libpython, so we add it | ||
# to the dlopen search path here. | ||
os.environ["LD_LIBRARY_PATH"] = os.pathsep.join( | ||
filter(None, [sysconfig.get_config_var("LIBDIR"), os.getenv("LD_LIBRARY_PATH")]) | ||
) | ||
|
||
# The '--no-default-features' flag is used here to disable PyO3's | ||
# 'extension-module' when running the tests (which would otherwise cause link | ||
# errors). | ||
subprocess.run(["cargo", "test", "--no-default-features"], check=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to not just do?:
I've always found the
filter(None, ...)
pattern a bit odd when you can just use a generator expression.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I did that was to filter out
None
in the case that"LD_LIBRARY_PATH"
isn't actually set to anything. I can do something different if you prefer!