Skip to content

Treating traitsui as optional#86

Closed
stewbond wants to merge 2 commits into
enthought:mainfrom
stewbond:ignore_traitui
Closed

Treating traitsui as optional#86
stewbond wants to merge 2 commits into
enthought:mainfrom
stewbond:ignore_traitui

Conversation

@stewbond
Copy link
Copy Markdown
Contributor

@stewbond stewbond commented Feb 3, 2019

If users don't have traitsui, then GUI-specific functions now do nothing instead of crashing the application. This really helps for running unit tests on build machines without any X-server which have problems when running traitsui functions.

Note that there probably some other places where traitsui could be removed, but this at least gets the CI tests working.

Also helps with issue #70.

@corranwebster
Copy link
Copy Markdown
Contributor

Have you tried running your headless tests with ETS_TOOLKIT=null environment variable set?

@stewbond
Copy link
Copy Markdown
Contributor Author

stewbond commented Feb 3, 2019

Thanks for the response.

When I run the tests in a debian unstable chroot without python-traitsui installed, I get an ImportError [1]

When I run the tests in a debian unstable chroot with python-traitsui installed, I get Unable to access the X Display, is $DISPLAY set properly? [2]

It's also worth noting that python3-traitsui is not available in debian yet so if we did solve the $DISPLAY issue, we would still have a problem when running the tests with python3.

[1]:

export ETS_TOOLKIT=null
cd /root/python-apptools/.pybuild/cpython2_2.7_apptools/build; python2.7 -m nose -v 
apptools.io.h5.tests.test_dict_node.test_create ... ok
apptools.io.h5.tests.test_dict_node.test_is_dict_node ... ok
...
apptools.lru_cache.tests.test_lru_cache.test_cache_get ... ok
apptools.lru_cache.tests.test_lru_cache.test_updated_event ... ok
Failure: ImportError (No module named traitsui.api) ... ERROR
bind ... ok
bind with make contexts ... ok
...
test_undo_redo_1_command (apptools.undo.tests.test_command_stack.TestCommandStack) ... ok
test_undo_unnamed_command (apptools.undo.tests.test_command_stack.TestCommandStack) ... ok

======================================================================
ERROR: Failure: ImportError (No module named traitsui.api)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/root/python-apptools/.pybuild/cpython2_2.7_apptools/build/apptools/naming/trait_defs/__init__.py", line 17, in <module>
    from api import *
  File "/root/python-apptools/.pybuild/cpython2_2.7_apptools/build/apptools/naming/trait_defs/api.py", line 13, in <module>
    from naming_traits import NamingInstance
  File "/root/python-apptools/.pybuild/cpython2_2.7_apptools/build/apptools/naming/trait_defs/naming_traits.py", line 25, in <module>
    from traitsui.api \
ImportError: No module named traitsui.api

----------------------------------------------------------------------
Ran 398 tests in 0.550s

FAILED (SKIP=1, errors=1)

[2]:

export ETS_TOOLKIT=null
cd /root/python-apptools/.pybuild/cpython2_2.7_apptools/build; python2.7 -m nose -v 
Unable to access the X Display, is $DISPLAY set properly?

@mdickinson
Copy link
Copy Markdown
Member

Closing in favour of #351

@mdickinson mdickinson closed this Jun 28, 2024
mdickinson added a commit that referenced this pull request Jul 4, 2024
Apptools contains several disparate packages with different needs. While
it's somewhat reasonable to regard Traits as a core dependency, not all
subpackages need a GUI, and only the preferences package makes use of
configobj.

This PR:

* makes all three of TraitsUI, Pyface and configobj optional
dependencies
* adds a "gui" entry for `extras_require` in `setup.py`
* adds a test workflow that runs the test suite with only the core
dependencies (i.e., Traits), to make sure that other tests are skipped
appropriately rather than failing

Closes #70 

Makes #86 obsolete.
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