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

Make example run from any directory #377

Merged
merged 4 commits into from
Dec 1, 2020
Merged

Make example run from any directory #377

merged 4 commits into from
Dec 1, 2020

Conversation

kitchoi
Copy link
Contributor

@kitchoi kitchoi commented Nov 30, 2020

This approach may provide for solving #320 and resolves the import issues seen in #359.

This PR changes the main scripts in the examples such that they can be run from another directory while still be able to import the local packages. The (dirty) trick is to temporarily insert the directory path where the script is to sys.path (which is how it works when one runs the script from that directory).

Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we're missing __init__ files in envisage.examples and envisage.examples.tests. Apart from that the examples ran as expected.

Did you also test if these work as expected when run via etsdemo?

@kitchoi
Copy link
Contributor Author

kitchoi commented Dec 1, 2020

Looks like we're missing init files in envisage.examples and envisage.examples.tests. Apart from that the examples ran as expected.

Thank you! Will be adding them back.

Did you also test if these work as expected when run via etsdemo?

Yes, and the examples can be run from there. However since this PR does not move the files into envisage and does not add an entry point, it does not close #320 outright. I tested with the etsdemo using a local script like this:

import os
from etsdemo.main import main
main(
    [
        {
            "version": 1,
            "name": "Envisage Examples",
            "root": os.path.dirname(__file__),
        },
    ]
)

(where the script sits in the examples folder).

Copy link
Contributor

@rahulporuri rahulporuri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Do you have time to also work on a PR contributing the examples to etsdemo? If it can be done within a couple of days, i think it's worth holding the 5.0.0 release of envisage.

@kitchoi
Copy link
Contributor Author

kitchoi commented Dec 1, 2020

Do you have time to also work on a PR contributing the examples to etsdemo? If it can be done within a couple of days, i think it's worth holding the 5.0.0 release of envisage.

Yes it can be done in a couple of days. I can give this a try. Sorry for visiting the issue this late.

@kitchoi kitchoi merged commit e0ae02a into master Dec 1, 2020
@kitchoi kitchoi deleted the make-example-run branch December 1, 2020 10:22
aaronayres35 pushed a commit that referenced this pull request Dec 2, 2020
* Make it possible to run example scripts from anywhere.

* Add a docstring for the test case

* Add missing __init__.py

* Import abcdefg...
aaronayres35 added a commit that referenced this pull request Dec 2, 2020
* Fix index slice in ExtensionPointChangedEvent when plugin changes (#357)

* Turn off macOS builds on Travis CI (#375)

This PR turns off expensive macOS builds on Travis CI. We'll eventually use GitHub Actions to replace these.

* update changelog with backported PRs

* Make example run from any directory (#377)

* Make it possible to run example scripts from anywhere.

* Add a docstring for the test case

* Add missing __init__.py

* Import abcdefg...

* Refactor documentation links to source on GitHub (#379)

* Refactor external links to demo examples from extension_points.rst

* Update links to github in introduction.rst

* Refactor substitutions

* Group substitutions

* Update other references to github links

* Flake8

* Remove two other links to github that point to TraitsGUI

* Remove redundant newlines

* Maintain all substituions in the same place

* Remove two redundant lines

* Contribute examples to etsdemo (#380)

* remove logging from hello world and motd

* remove logging from other examples

* move examples into envisage

* update the single URL in docs/conf.py

* add examples as package_data

* add entry point

* flake8

* add demo folder and update package_data based off code review suggestion

* Update docs/source/conf.py

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* rename and add test for entry point

* move GUI_Application example into envisage/examples

* move old examples into envisage/examples/demo/legacy

* Revert "move old examples into envisage/examples/demo/legacy"

This reverts commit c026040.

* move old examples into a new subdirectory called legacy

* add a readme to reference new location for examples

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* more changelog updates

* more changes to changelog

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
aaronayres35 added a commit that referenced this pull request Dec 4, 2020
* Fix index slice in ExtensionPointChangedEvent when plugin changes (#357)

* Turn off macOS builds on Travis CI (#375)

This PR turns off expensive macOS builds on Travis CI. We'll eventually use GitHub Actions to replace these.

* update changelog with backported PRs

* Make example run from any directory (#377)

* Make it possible to run example scripts from anywhere.

* Add a docstring for the test case

* Add missing __init__.py

* Import abcdefg...

* Refactor documentation links to source on GitHub (#379)

* Refactor external links to demo examples from extension_points.rst

* Update links to github in introduction.rst

* Refactor substitutions

* Group substitutions

* Update other references to github links

* Flake8

* Remove two other links to github that point to TraitsGUI

* Remove redundant newlines

* Maintain all substituions in the same place

* Remove two redundant lines

* Contribute examples to etsdemo (#380)

* remove logging from hello world and motd

* remove logging from other examples

* move examples into envisage

* update the single URL in docs/conf.py

* add examples as package_data

* add entry point

* flake8

* add demo folder and update package_data based off code review suggestion

* Update docs/source/conf.py

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* rename and add test for entry point

* move GUI_Application example into envisage/examples

* move old examples into envisage/examples/demo/legacy

* Revert "move old examples into envisage/examples/demo/legacy"

This reverts commit c026040.

* move old examples into a new subdirectory called legacy

* add a readme to reference new location for examples

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* more changelog updates

* more changes to changelog

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
aaronayres35 added a commit that referenced this pull request Dec 4, 2020
* Backports for 5.0.0 and update changelog (#378)

* Fix index slice in ExtensionPointChangedEvent when plugin changes (#357)

* Turn off macOS builds on Travis CI (#375)

This PR turns off expensive macOS builds on Travis CI. We'll eventually use GitHub Actions to replace these.

* update changelog with backported PRs

* Make example run from any directory (#377)

* Make it possible to run example scripts from anywhere.

* Add a docstring for the test case

* Add missing __init__.py

* Import abcdefg...

* Refactor documentation links to source on GitHub (#379)

* Refactor external links to demo examples from extension_points.rst

* Update links to github in introduction.rst

* Refactor substitutions

* Group substitutions

* Update other references to github links

* Flake8

* Remove two other links to github that point to TraitsGUI

* Remove redundant newlines

* Maintain all substituions in the same place

* Remove two redundant lines

* Contribute examples to etsdemo (#380)

* remove logging from hello world and motd

* remove logging from other examples

* move examples into envisage

* update the single URL in docs/conf.py

* add examples as package_data

* add entry point

* flake8

* add demo folder and update package_data based off code review suggestion

* Update docs/source/conf.py

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* rename and add test for entry point

* move GUI_Application example into envisage/examples

* move old examples into envisage/examples/demo/legacy

* Revert "move old examples into envisage/examples/demo/legacy"

This reverts commit c026040.

* move old examples into a new subdirectory called legacy

* add a readme to reference new location for examples

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>

* more changelog updates

* more changes to changelog

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>

* add release date

Co-authored-by: Kit Choi <kitchoi@users.noreply.github.com>
Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
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