Skip to content

Commit 16b4f24

Browse files
committed
Cleaned up __main__; addressed review comments
1 parent eaef734 commit 16b4f24

File tree

2 files changed

+8
-254
lines changed

2 files changed

+8
-254
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ open a `Terminal`/`Powershell`/`Cmd Prompt`/ and navigate to the folder
3737
where the repo was cloned. Enter the following command to create a
3838
dedicated Python environment and install all dependencies in it:
3939
```commandline
40-
python ci install
40+
python ci build
4141
```
4242

4343
### Conda users

ci/__main__.py

Lines changed: 7 additions & 253 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
python etstool.py test_all
5252
5353
Currently supported runtime values are ``3.6``, and currently
54-
supported toolkits are ``null``, ``pyqt5``, ``pyside2`` and ``wx``.
54+
supported toolkits are ``null``, ``pyqt5``, ``pyside2``.
5555
Not all combinations of toolkits and runtimes will work, but the tasks will
5656
fail with a clear error if that is the case.
5757
@@ -101,7 +101,7 @@
101101
import click
102102

103103
supported_combinations = {
104-
'3.6': {'pyside2', 'pyside6', 'pyqt5', 'pyqt6', 'wx', 'null'},
104+
'3.6': {'pyside2', 'pyside6', 'pyqt5', 'pyqt6', 'null'},
105105
}
106106

107107
# Default Python version to use in the commands below if none is specified.
@@ -116,6 +116,7 @@
116116
"matplotlib",
117117
"pandas",
118118
"pillow",
119+
"pyface",
119120
"pyqt5",
120121
"scikits.image",
121122
"traits",
@@ -130,70 +131,14 @@
130131
"traits": "git+http://github.com/enthought/traits.git#egg=traits",
131132
}
132133

133-
# # The following should match extras_require in setup.py but with package
134-
# # names compatible with EDM
135-
# extra_dependencies = {
136-
# 'pyside2': {
137-
# 'pygments',
138-
# },
139-
# 'pyside6': {
140-
# 'pygments',
141-
# },
142-
# 'pyqt5': {
143-
# 'pyqt5',
144-
# 'pygments',
145-
# },
146-
# 'pyqt6': {
147-
# 'pygments',
148-
# },
149-
# # XXX once wxPython 4 is available in EDM, we will want it here
150-
# 'wx': {
151-
# 'numpy',
152-
# },
153-
# 'null': set(),
154-
# # Toolkit-independent dependencies for demo testing.
155-
# 'examples': {
156-
# 'apptools',
157-
# 'chaco',
158-
# 'h5py',
159-
# 'numpy',
160-
# 'pandas',
161-
# 'pytables',
162-
# },
163-
# # Optional dependencies for some editors
164-
# 'editors': {
165-
# 'numpy',
166-
# 'pandas',
167-
# 'pillow',
168-
# },
169-
# # Test dependencies also applied to installation from PYPI
170-
# 'test': {
171-
# 'packaging',
172-
# },
173-
# }
174-
175-
# Dependencies for CI jobs using this file.
176134
ci_dependencies = {
177135
"coverage",
178136
"flake8",
179137
"flake8_ets",
180138
}
181139

182-
# doc_dependencies = {
183-
# "sphinx",
184-
# "enthought_sphinx_theme",
185-
# "pyface",
186-
# }
187-
188-
#: Paths to ignore in Sphinx-apidoc
189-
# doc_ignore = {
190-
# "traitsui/qt4/*",
191-
# "traitsui/wx/*",
192-
# "*/tests",
193-
# }
194-
195140
environment_vars = {
196-
# 'pyside2': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside2'},
141+
'pyside2': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside2'},
197142
# 'pyside6': {'ETS_TOOLKIT': 'qt', 'QT_API': 'pyside6'},
198143
'pyqt5': {"ETS_TOOLKIT": "qt", "QT_API": "pyqt5"},
199144
# 'pyqt6': {"ETS_TOOLKIT": "qt", "QT_API": "pyqt6"},
@@ -237,8 +182,7 @@ def cli():
237182
default=False,
238183
help="Install main package in 'editable' mode? [default: --not-editable]",
239184
)
240-
@click.option('--source/--no-source', default=False)
241-
def install(runtime, toolkit, environment, editable, source):
185+
def build(runtime, toolkit, environment, editable):
242186
"""Install project and dependencies into a clean EDM environment."""
243187
parameters = get_parameters(runtime, toolkit, environment)
244188
packages = (dependencies | ci_dependencies)
@@ -257,11 +201,7 @@ def install(runtime, toolkit, environment, editable, source):
257201
]
258202
)
259203

260-
# pip install pyqt5, pyqt6, pyside2 and pyside6, because we don't have them
261-
# in EDM yet
262-
if toolkit == 'pyside2':
263-
commands.append("edm run -e {environment} -- pip install pyside2")
264-
elif toolkit == 'pyqt6':
204+
if toolkit == 'pyqt6':
265205
commands.append("edm run -e {environment} -- pip install pyqt6")
266206
elif toolkit == 'pyside6':
267207
# On Linux and macOS, some versions of PySide6 between 6.2.2 and 6.3.0
@@ -273,40 +213,10 @@ def install(runtime, toolkit, environment, editable, source):
273213
"edm run -e {environment} -- pip install pyside6<6.2.2")
274214
else:
275215
commands.append("edm run -e {environment} -- pip install pyside6")
276-
elif toolkit == 'wx':
277-
if sys.platform != 'linux':
278-
commands.append("edm run -e {environment} -- pip install wxPython")
279-
else:
280-
# XXX this is mainly for TravisCI workers; need a generic solution
281-
commands.append(
282-
"edm run -e {environment} -- pip install -f "
283-
"https://extras.wxpython.org/wxPython4/extras/linux/gtk3"
284-
"/ubuntu-16.04/ wxPython"
285-
)
286216

287217
click.echo("Creating environment '{environment}'".format(**parameters))
288218
execute(commands, parameters)
289219

290-
if source:
291-
cmd_fmt = (
292-
"edm plumbing remove-package --environment {environment} --force "
293-
)
294-
commands = [
295-
cmd_fmt + dependency for dependency in source_dependencies.keys()
296-
]
297-
execute(commands, parameters)
298-
source_pkgs = source_dependencies.values()
299-
# Without the --no-dependencies flag such that new dependencies on
300-
# main branch are brought in.
301-
commands = [
302-
"python -m pip install --force-reinstall {pkg}".format(pkg=pkg)
303-
for pkg in source_pkgs
304-
]
305-
commands = [
306-
"edm run -e {environment} -- " + command for command in commands
307-
]
308-
execute(commands, parameters)
309-
310220
# Always install local source again with no dependencies
311221
# to mitigate risk of testing against a distributed release.
312222
install_local = (
@@ -392,7 +302,7 @@ def test_clean(runtime, toolkit):
392302
"""Run tests in a clean environment, cleaning up afterwards"""
393303
args = ['--toolkit={}'.format(toolkit), '--runtime={}'.format(runtime)]
394304
try:
395-
install(args=args, standalone_mode=False)
305+
build(args=args, standalone_mode=False)
396306
test(args=args, standalone_mode=False)
397307
finally:
398308
cleanup(args=args, standalone_mode=False)
@@ -411,59 +321,6 @@ def update(runtime, toolkit, environment):
411321
click.echo('Done update')
412322

413323

414-
# @cli.command()
415-
# @click.option('--runtime', default=DEFAULT_RUNTIME)
416-
# @click.option('--toolkit', default=DEFAULT_TOOLKIT)
417-
# @click.option('--environment', default=None)
418-
# def docs(runtime, toolkit, environment):
419-
# """Autogenerate documentation"""
420-
# parameters = get_parameters(runtime, toolkit, environment)
421-
# packages = ' '.join(doc_dependencies)
422-
# ignore = " ".join(doc_ignore)
423-
# commands = [
424-
# "edm install -y -e {environment} " + packages,
425-
# ]
426-
# click.echo(
427-
# "Installing documentation tools in '{environment}'".format(
428-
# **parameters
429-
# )
430-
# )
431-
# execute(commands, parameters)
432-
# click.echo('Done installing documentation tools')
433-
#
434-
# click.echo(
435-
# "Regenerating API docs in '{environment}'".format(**parameters)
436-
# )
437-
# output_path = os.path.join("docs", "source", "api")
438-
# if not os.path.exists(output_path):
439-
# os.makedirs(output_path)
440-
# commands = [
441-
# "edm run -e {environment} -- sphinx-apidoc "
442-
# "-e "
443-
# "-M "
444-
# "--no-toc "
445-
# "-o " + output_path + " traitsui " + ignore
446-
# ]
447-
# execute(commands, parameters)
448-
# click.echo("Done regenerating API docs")
449-
#
450-
# os.chdir('docs')
451-
# command = (
452-
# "edm run -e {environment} -- sphinx-build -b html "
453-
# "-d build/doctrees "
454-
# "source "
455-
# "build/html"
456-
# )
457-
# click.echo(
458-
# "Building documentation in '{environment}'".format(**parameters)
459-
# )
460-
# try:
461-
# execute([command], parameters)
462-
# finally:
463-
# os.chdir('..')
464-
# click.echo('Done building documentation')
465-
466-
467324
@cli.command()
468325
def test_all():
469326
"""Run test_clean across all supported environment combinations."""
@@ -506,109 +363,6 @@ def flake8(runtime, toolkit, environment, strict):
506363
execute(commands, parameters)
507364

508365

509-
@cli.group("changelog")
510-
@click.pass_context
511-
def changelog(ctx):
512-
"""Group of commands related to creating changelog."""
513-
514-
ctx.obj = {
515-
# Mapping from news fragment type to their description in
516-
# the changelog.
517-
"type_to_description": {
518-
"feature": "Features",
519-
"bugfix": "Fixes",
520-
"deprecation": "Deprecations",
521-
"removal": "Removals",
522-
"doc": "Documentation changes",
523-
"test": "Test suite",
524-
"build": "Build System",
525-
}
526-
}
527-
528-
529-
@changelog.command("create")
530-
@click.pass_context
531-
def create_news_fragment(ctx):
532-
"""Create a news fragment for your PR."""
533-
534-
pr_number = click.prompt('Please enter the PR number', type=int)
535-
type_ = click.prompt(
536-
"Choose a fragment type:",
537-
type=click.Choice(ctx.obj["type_to_description"]),
538-
)
539-
540-
filepath = os.path.join(NEWS_FRAGMENT_DIR, f"{pr_number}.{type_}.rst")
541-
542-
if os.path.exists(filepath):
543-
click.echo("FAILED: File {} already exists.".format(filepath))
544-
ctx.exit(1)
545-
546-
content = click.prompt(
547-
"Describe the changes to the END USERS.\n"
548-
"Example: 'Remove subpackage xyz.'\n",
549-
type=str,
550-
)
551-
if not os.path.exists(NEWS_FRAGMENT_DIR):
552-
os.makedirs(NEWS_FRAGMENT_DIR)
553-
with open(filepath, "w", encoding="utf-8") as fp:
554-
fp.write(content + f" (#{pr_number})")
555-
556-
click.echo("Please commit the file created at: {}".format(filepath))
557-
558-
559-
@changelog.command("build")
560-
@click.pass_context
561-
def build_changelog(ctx):
562-
"""Build Changelog created from all the news fragments."""
563-
# This is a rather simple first-cut generation of the changelog.
564-
# It removes the laborious concatenation, but the end results might
565-
# still require some tweaking.
566-
contents = []
567-
568-
# Collect news fragment files as we go, and then optionally remove them.
569-
handled_file_paths = []
570-
571-
for type_, description in ctx.obj["type_to_description"].items():
572-
pattern = os.path.join(NEWS_FRAGMENT_DIR, f"*.{type_}.rst")
573-
file_paths = sorted(glob.glob(pattern))
574-
575-
if file_paths:
576-
contents.append("")
577-
contents.append(description)
578-
contents.append("-" * len(description))
579-
580-
for filename in file_paths:
581-
with open(filename, "r", encoding="utf-8") as fp:
582-
contents.append("* " + fp.read())
583-
handled_file_paths.append(filename)
584-
585-
# Prepend content to the changelog file.
586-
587-
with open(CHANGELOG_PATH, "r", encoding="utf-8") as fp:
588-
original_changelog = fp.read()
589-
590-
with open(CHANGELOG_PATH, "w", encoding="utf-8") as fp:
591-
if contents:
592-
print(*contents, sep="\n", file=fp)
593-
fp.write(original_changelog)
594-
595-
click.echo(f"Changelog is updated. Please review it at {CHANGELOG_PATH}")
596-
597-
# Optionally clean up collected news fragments.
598-
should_clean = click.confirm("Do you want to remove the news fragments?")
599-
if should_clean:
600-
for file_path in handled_file_paths:
601-
os.remove(file_path)
602-
603-
# Report any leftover for developers to inspect.
604-
leftovers = sorted(glob.glob(os.path.join(NEWS_FRAGMENT_DIR, "*")))
605-
if leftovers:
606-
click.echo("These files are not collected:")
607-
click.echo("\n ".join([""] + leftovers))
608-
609-
click.echo("Done")
610-
611-
612366
# ----------------------------------------------------------------------------
613367
# Utility routines
614368
# ----------------------------------------------------------------------------

0 commit comments

Comments
 (0)