Moved examples inside project directory#2045
Merged
j9ac9k merged 3 commits intopyqtgraph:masterfrom Oct 30, 2021
Merged
Conversation
c507d19 to
69bc263
Compare
NilsNemitz
reviewed
Oct 28, 2021
By adding the project root directory to PYTHONPATH and passing that environment variable to the subprocess.Popen call, we can get pyqtgraph to be importable despite it not being installed. By extension, we can do the same thing within test_examples so the examples can be tested without pyqtgraph needing to be installed as well
69bc263 to
1bf49a7
Compare
Member
Author
|
Made more progress, by passing along |
Member
Author
|
I think this PR is ready for merging; I'll give folks a bit to see if they spot any issues; otherwise I'll merge over the weekend. |
e2e7d16 to
826fac4
Compare
NilsNemitz
reviewed
Nov 8, 2021
| proc = subprocess.Popen([sys.executable, '-'], stdin=subprocess.PIPE, cwd=path, env=env) | ||
| code = str(self.ui.codeView.toPlainText()).encode('UTF-8') |
Contributor
There was a problem hiding this comment.
This encoding still seems to be required, see issue #2060 .
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2042
This PR moves the examples from the
{project_dir}/examplesto{project_dir}/pyqtgraph/examples.This change was prompted by #2042 which @ksunden pointed out that some of the examples didn't work when pyqtgraph was installed in non-editable mode and the examples were run from outside the project directory. Given the extensive path manipulation via
import initExampleon every example, and in other places, figured this would be a good time to take out some of the custom code written for pyqtgraph'ssetup.pyand use standardsetuptoolsfunctionality instead.I also took the opportunity to update
MANIFEST.inwhich only effects source distributions.A by-product of this change means that examples may not work if pyqtgraph is not installed via pip. Given that I'd like to phase out support for pyqtgraph to be used when not via a package manager, I'm good with this change (but others may not be).
The testing I did was as follows
I launched the example app via
python -m pyqtgraph.examplesand then ran the parameter tree example ensuring it ran successfully (this example is good because it imports other python modules in the example directory, and imports from pyqtgraph)I did this for editable and non-editable installs, from both the root project directory and a directory not within the project.
Furthermore, I ran through the test suite
pytest -n auto pyqtgraph/examplesWhat no longer works is runningthis works nowpython -m pyqtgraph.examplesfrom the project directory (example app pops up) but almost all examples fail as they attempt to importpyqtgraphwhich reports package not found.The only use-case I can identify where examples do not work is if a user attempts to run an example directly (ex:
python pyqtgraph/examples/PlotSpeedTest.pyand pyqtgraph is not installed; the user will get an ImportError.EDIT: slight oddity; somewhere in the development process here, I managed to break pyopengl to the point that I would get an import error; after force-reinstalling it, I could no longer replicate