compas-invocations2 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ ETH Zurich
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.1
2
+ Name: compas_invocations2
3
+ Version: 0.2.0
4
+ Summary: A collection of reusable pyinvoke tasks.
5
+ Author-email: Li Chen <li.chen@arch.ethz.ch>
6
+ License: MIT License
7
+
8
+ ETH Zurich
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://compas-dev.github.io/compas_invocations2
29
+ Project-URL: Documentation, https://compas-dev.github.io/compas_invocations2
30
+ Project-URL: Repository, https://github.com/compas-dev/compas_invocations2.git
31
+ Project-URL: Changelog, https://github.com/compas-dev/compas_invocations2/blob/main/CHANGELOG.md
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Topic :: Scientific/Engineering
34
+ Classifier: Programming Language :: Python
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.9
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Requires-Python: >=3.9
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Provides-Extra: dev
43
+ Requires-Dist: attrs>=17.4; extra == "dev"
44
+ Requires-Dist: black>=22.12.0; extra == "dev"
45
+ Requires-Dist: bump-my-version; extra == "dev"
46
+ Requires-Dist: compas_notebook; extra == "dev"
47
+ Requires-Dist: invoke>=0.14; extra == "dev"
48
+ Requires-Dist: ruff; extra == "dev"
49
+ Requires-Dist: sphinx_compas2_theme; extra == "dev"
50
+ Requires-Dist: twine; extra == "dev"
51
+ Requires-Dist: wheel; extra == "dev"
52
+
53
+ # compas_invocations2
54
+
55
+ [![pypi](https://img.shields.io/pypi/v/compas_invocations2.svg)](https://pypi.org/project/compas-invocations/)
56
+
57
+ A collection of reusable pyinvoke tasks
58
+
59
+ ## Usage
60
+
61
+ Import and add tasks to a collection in your project's `tasks.py` file:
62
+
63
+ import os
64
+ from invoke import Collection
65
+ from compas_invocations2 import style
66
+
67
+ ns = Collection(style.check, style.lint)
68
+ ns.configure(
69
+ {
70
+ "base_folder": os.path.dirname(__file__),
71
+ }
72
+ )
73
+
74
+ For a more complete example, check the [`tasks.py`](tasks.py) of this project.
@@ -0,0 +1,22 @@
1
+ # compas_invocations2
2
+
3
+ [![pypi](https://img.shields.io/pypi/v/compas_invocations2.svg)](https://pypi.org/project/compas-invocations/)
4
+
5
+ A collection of reusable pyinvoke tasks
6
+
7
+ ## Usage
8
+
9
+ Import and add tasks to a collection in your project's `tasks.py` file:
10
+
11
+ import os
12
+ from invoke import Collection
13
+ from compas_invocations2 import style
14
+
15
+ ns = Collection(style.check, style.lint)
16
+ ns.configure(
17
+ {
18
+ "base_folder": os.path.dirname(__file__),
19
+ }
20
+ )
21
+
22
+ For a more complete example, check the [`tasks.py`](tasks.py) of this project.
@@ -0,0 +1,121 @@
1
+ [build-system]
2
+ requires = ["setuptools>=66.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ # ============================================================================
6
+ # project info
7
+ # ============================================================================
8
+
9
+ [project]
10
+ name = "compas_invocations2"
11
+ description = "A collection of reusable pyinvoke tasks."
12
+ keywords = []
13
+ authors = [
14
+ { name = "Li Chen", email = "li.chen@arch.ethz.ch" },
15
+ ]
16
+ license = { file = "LICENSE" }
17
+ readme = "README.md"
18
+ requires-python = ">=3.9"
19
+ dynamic = ['dependencies', 'optional-dependencies', 'version']
20
+ classifiers = [
21
+ "Development Status :: 4 - Beta",
22
+ "Topic :: Scientific/Engineering",
23
+ "Programming Language :: Python",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://compas-dev.github.io/compas_invocations2"
32
+ Documentation = "https://compas-dev.github.io/compas_invocations2"
33
+ Repository = "https://github.com/compas-dev/compas_invocations2.git"
34
+ Changelog = "https://github.com/compas-dev/compas_invocations2/blob/main/CHANGELOG.md"
35
+
36
+ # ============================================================================
37
+ # setuptools config
38
+ # ============================================================================
39
+
40
+ [tool.setuptools]
41
+ package-dir = { "" = "src" }
42
+ include-package-data = true
43
+ zip-safe = false
44
+
45
+ [tool.setuptools.dynamic]
46
+ version = { attr = "compas_invocations2.__version__" }
47
+ dependencies = { file = "requirements.txt" }
48
+ optional-dependencies = { dev = { file = "requirements-dev.txt" } }
49
+
50
+ [tool.setuptools.packages.find]
51
+ where = ["src"]
52
+
53
+ # ============================================================================
54
+ # replace pytest.ini
55
+ # ============================================================================
56
+
57
+ [tool.pytest.ini_options]
58
+ minversion = "6.0"
59
+ testpaths = ["tests", "src/compas_invocations2"]
60
+ python_files = ["test_*.py", "*_test.py", "test.py"]
61
+ addopts = ["-ra", "--strict-markers", "--doctest-glob=*.rst", "--tb=short"]
62
+ doctest_optionflags = [
63
+ "NORMALIZE_WHITESPACE",
64
+ "IGNORE_EXCEPTION_DETAIL",
65
+ "ALLOW_UNICODE",
66
+ "ALLOW_BYTES",
67
+ "NUMBER",
68
+ ]
69
+
70
+ # ============================================================================
71
+ # replace bumpversion.cfg
72
+ # ============================================================================
73
+
74
+ [tool.bumpversion]
75
+ current_version = "0.2.0"
76
+ message = "Bump version to {new_version}"
77
+ commit = true
78
+ tag = true
79
+
80
+ [[tool.bumpversion.files]]
81
+ filename = "src/compas_invocations2/__init__.py"
82
+ search = "{current_version}"
83
+ replace = "{new_version}"
84
+
85
+ [[tool.bumpversion.files]]
86
+ filename = "CHANGELOG.md"
87
+ search = "Unreleased"
88
+ replace = "[{new_version}] {now:%Y-%m-%d}"
89
+
90
+ # ============================================================================
91
+ # replace setup.cfg
92
+ # ============================================================================
93
+
94
+ [tool.black]
95
+ line-length = 119
96
+
97
+ [tool.ruff]
98
+ line-length = 119
99
+ indent-width = 4
100
+ target-version = "py39"
101
+
102
+ [tool.ruff.lint]
103
+ select = ["E", "F", "I"]
104
+
105
+ [tool.ruff.lint.per-file-ignores]
106
+ "__init__.py" = ["I001"]
107
+ "tests/*" = ["I001"]
108
+ "tasks.py" = ["I001"]
109
+
110
+ [tool.ruff.lint.isort]
111
+ force-single-line = true
112
+
113
+ [tool.ruff.lint.pydocstyle]
114
+ convention = "numpy"
115
+
116
+ [tool.ruff.lint.pycodestyle]
117
+ max-doc-length = 179
118
+
119
+ [tool.ruff.format]
120
+ docstring-code-format = true
121
+ docstring-code-line-length = "dynamic"
@@ -0,0 +1,9 @@
1
+ attrs >=17.4
2
+ black >=22.12.0
3
+ bump-my-version
4
+ compas_notebook
5
+ invoke >=0.14
6
+ ruff
7
+ sphinx_compas2_theme
8
+ twine
9
+ wheel
File without changes
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ __author__ = ["Li Chen"]
2
+ __copyright__ = "ETH Zurich"
3
+ __license__ = "MIT License"
4
+ __email__ = "li.chen@arch.ethz.ch"
5
+ __version__ = "0.2.0"
@@ -0,0 +1,179 @@
1
+ import glob
2
+ import os
3
+ import shutil
4
+ import tempfile
5
+
6
+ import invoke
7
+
8
+ from compas_invocations2.console import chdir
9
+ from compas_invocations2.console import confirm
10
+
11
+
12
+ @invoke.task(
13
+ help={
14
+ "docs": "True to clean up generated documentation, otherwise False",
15
+ "bytecode": "True to clean up compiled python files, otherwise False.",
16
+ "builds": "True to clean up build/packaging artifacts, otherwise False.",
17
+ }
18
+ )
19
+ def clean(ctx, docs=True, bytecode=True, builds=True, ghuser=True):
20
+ """Cleans the local copy from compiled artifacts."""
21
+
22
+ with chdir(ctx.base_folder):
23
+ if bytecode:
24
+ for root, dirs, files in os.walk(ctx.base_folder):
25
+ for f in files:
26
+ if f.endswith(".pyc"):
27
+ os.remove(os.path.join(root, f))
28
+ if ".git" in dirs:
29
+ dirs.remove(".git")
30
+
31
+ folders = []
32
+
33
+ if docs:
34
+ folders.append("docs/api/generated")
35
+
36
+ folders.append("dist/")
37
+
38
+ if bytecode:
39
+ for t in ("src", "tests"):
40
+ folders.extend(glob.glob("{}/**/__pycache__".format(t), recursive=True))
41
+
42
+ if builds:
43
+ folders.append("build/")
44
+ folders.extend(glob.glob("src/**/*.egg-info", recursive=False))
45
+
46
+ if ghuser and ctx.get("ghuser"):
47
+ folders.append(os.path.abspath(ctx.ghuser.target_dir))
48
+
49
+ for folder in folders:
50
+ shutil.rmtree(os.path.join(ctx.base_folder, folder), ignore_errors=True)
51
+
52
+
53
+ @invoke.task(help={"release_type": "Type of release follows semver rules. Must be one of: major, minor, patch."})
54
+ def release(ctx, release_type):
55
+ """Releases the project in one swift command!"""
56
+ if release_type not in ("patch", "minor", "major"):
57
+ raise invoke.Exit("The release type parameter is invalid.\nMust be one of: major, minor, patch.")
58
+
59
+ # Run formatter
60
+ ctx.run("invoke format")
61
+
62
+ # Run checks
63
+ ctx.run("invoke test")
64
+
65
+ # Bump version and git tag it
66
+ ctx.run("bump-my-version bump %s --verbose" % release_type)
67
+
68
+ # Build project
69
+ ctx.run("python -m build")
70
+
71
+ # Prepare the change log for the next release
72
+ prepare_changelog(ctx)
73
+
74
+ # Clean up local artifacts
75
+ clean(ctx)
76
+
77
+ # Upload to pypi
78
+ if confirm(
79
+ "Everything is ready. You are about to push to git which will trigger a release to pypi.org. Are you sure?",
80
+ assume_yes=False,
81
+ ):
82
+ ctx.run("git push --tags && git push")
83
+ else:
84
+ raise invoke.Exit("You need to manually revert the tag/commits created.")
85
+
86
+
87
+ @invoke.task
88
+ def prepare_changelog(ctx):
89
+ """Prepare changelog for next release."""
90
+ UNRELEASED_CHANGELOG_TEMPLATE = "## Unreleased\n\n### Added\n\n### Changed\n\n### Removed\n\n\n## "
91
+
92
+ with chdir(ctx.base_folder):
93
+ # Preparing changelog for next release
94
+ with open("CHANGELOG.md", "r+") as changelog:
95
+ content = changelog.read()
96
+ changelog.seek(0)
97
+ changelog.write(content.replace("## ", UNRELEASED_CHANGELOG_TEMPLATE, 1))
98
+
99
+ ctx.run('git add CHANGELOG.md && git commit -m "Prepare changelog for next release"')
100
+
101
+
102
+ @invoke.task(
103
+ help={
104
+ "gh_io_folder": "Folder where GH_IO.dll is located. If not specified, it will try to download from NuGet.",
105
+ "ironpython": "Command for running the IronPython executable. Defaults to `ipy`.",
106
+ "prefix": "(Optional) Append this prefix to the names of the built components.",
107
+ }
108
+ )
109
+ def build_ghuser_components(ctx, gh_io_folder=None, ironpython=None, prefix=None):
110
+ """Builds Grasshopper components using GH Componentizer."""
111
+ prefix = prefix or getattr(ctx.ghuser, "prefix", None)
112
+ source_dir = os.path.abspath(ctx.ghuser.source_dir)
113
+ target_dir = os.path.abspath(ctx.ghuser.target_dir)
114
+ repo_url = "https://github.com/compas-dev/compas-actions.ghpython_components.git"
115
+
116
+ with chdir(ctx.base_folder):
117
+ shutil.rmtree(os.path.join(ctx.base_folder, target_dir), ignore_errors=True)
118
+
119
+ # Build IronPython Grasshopper user objects from source
120
+ with chdir(ctx.base_folder):
121
+ with tempfile.TemporaryDirectory("actions.ghcomponentizer") as action_dir:
122
+ ctx.run("git clone {} {}".format(repo_url, action_dir))
123
+
124
+ if not gh_io_folder:
125
+ gh_io_folder = tempfile.mkdtemp("ghio")
126
+ import compas_ghpython
127
+
128
+ compas_ghpython.fetch_ghio_lib(gh_io_folder)
129
+
130
+ if not ironpython:
131
+ ironpython = ctx.get("ironpython") or "ipy"
132
+
133
+ gh_io_folder = os.path.abspath(gh_io_folder)
134
+ componentizer_script = os.path.join(action_dir, "componentize_ipy.py")
135
+
136
+ cmd = "{} {} {} {}".format(ironpython, componentizer_script, source_dir, target_dir)
137
+ cmd += ' --ghio "{}"'.format(gh_io_folder)
138
+ if prefix:
139
+ cmd += ' --prefix "{}"'.format(prefix)
140
+
141
+ ctx.run(cmd)
142
+
143
+
144
+ @invoke.task(
145
+ help={
146
+ "gh_io_folder": "Folder where GH_IO.dll is located. If not specified, it will try to download from NuGet.",
147
+ "prefix": "(Optional) Append this prefix to the names of the built components.",
148
+ }
149
+ )
150
+ def build_cpython_ghuser_components(ctx, gh_io_folder=None, prefix=None):
151
+ """Builds CPython Grasshopper components using GH Componentizer."""
152
+ prefix = prefix or getattr(ctx.ghuser, "prefix", None)
153
+ source_dir = os.path.abspath(ctx.ghuser.source_dir)
154
+ target_dir = os.path.abspath(ctx.ghuser.target_dir)
155
+ repo_url = "https://github.com/compas-dev/compas-actions.ghpython_components.git"
156
+
157
+ with chdir(ctx.base_folder):
158
+ shutil.rmtree(os.path.join(ctx.base_folder, target_dir), ignore_errors=True)
159
+
160
+ # Build CPython Grasshopper user objects from source
161
+ with chdir(ctx.base_folder):
162
+ with tempfile.TemporaryDirectory("actions.ghcomponentizer") as action_dir:
163
+ ctx.run("git clone {} {}".format(repo_url, action_dir))
164
+
165
+ if not gh_io_folder:
166
+ gh_io_folder = tempfile.mkdtemp("ghio")
167
+ import compas_ghpython
168
+
169
+ compas_ghpython.fetch_ghio_lib(gh_io_folder)
170
+
171
+ gh_io_folder = os.path.abspath(gh_io_folder)
172
+ componentizer_script = os.path.join(action_dir, "componentize_cpy.py")
173
+
174
+ cmd = "{} {} {} {}".format("python", componentizer_script, source_dir, target_dir)
175
+ cmd += ' --ghio "{}"'.format(gh_io_folder)
176
+ if prefix:
177
+ cmd += ' --prefix "{}"'.format(prefix)
178
+
179
+ ctx.run(cmd)
@@ -0,0 +1,83 @@
1
+ """
2
+ ********************************************************************************
3
+ console
4
+ ********************************************************************************
5
+
6
+ Text console UI helpers and patterns, e.g. ‘Y/n’ prompts and the like.
7
+
8
+ .. currentmodule:: compas_invocations2.console
9
+
10
+ .. autosummary::
11
+ :toctree: generated/
12
+ :nosignatures:
13
+
14
+ confirm
15
+ chdir
16
+
17
+ """
18
+
19
+ import contextlib
20
+ import os
21
+ import sys
22
+
23
+
24
+ # NOTE: originally taken from invocations https://github.com/pyinvoke/invocations/blob/main/invocations/console.py
25
+ def confirm(question, assume_yes=True):
26
+ """
27
+ Ask user a yes/no question and return their response as a boolean.
28
+
29
+ ``question`` should be a simple, grammatically complete question such as
30
+ "Do you wish to continue?", and will have a string similar to ``" [Y/n] "``
31
+ appended automatically. This function will *not* append a question mark for
32
+ you.
33
+ By default, when the user presses Enter without typing anything, "yes" is
34
+ assumed. This can be changed by specifying ``assume_yes=False``.
35
+
36
+ .. note::
37
+
38
+ If the user does not supply input that is (case-insensitively) equal to
39
+ "y", "yes", "n" or "no", they will be re-prompted until they do.
40
+
41
+ Parameters
42
+ ----------
43
+ question : str
44
+ The question part of the prompt.
45
+ assume_yes : bool
46
+ Whether to assume the affirmative answer by default. Defaults to ``True``.
47
+
48
+ Returns
49
+ -------
50
+ bool
51
+ """
52
+ if assume_yes:
53
+ suffix = "Y/n"
54
+ else:
55
+ suffix = "y/N"
56
+
57
+ while True:
58
+ response = input("{} [{}] ".format(question, suffix))
59
+ response = response.lower().strip()
60
+
61
+ if not response:
62
+ return assume_yes
63
+
64
+ if response in ["y", "yes"]:
65
+ return True
66
+
67
+ if response in ["n", "no"]:
68
+ return False
69
+
70
+ err = "Focus, kid! It is either (y)es or (n)o"
71
+ print(err, file=sys.stderr)
72
+
73
+
74
+ @contextlib.contextmanager
75
+ def chdir(dirname=None):
76
+ """Context-manager syntax to change to a directory and return to the current one afterwards."""
77
+ current_dir = os.getcwd()
78
+ try:
79
+ if dirname is not None:
80
+ os.chdir(dirname)
81
+ yield
82
+ finally:
83
+ os.chdir(current_dir)
@@ -0,0 +1,43 @@
1
+ import invoke
2
+
3
+ from compas_invocations2.build import clean
4
+ from compas_invocations2.console import chdir
5
+
6
+
7
+ @invoke.task(default=True)
8
+ def help(ctx):
9
+ """Lists available tasks and usage."""
10
+ ctx.run("invoke --list")
11
+ print('Use "invoke -h <taskname>" to get detailed help for a task.')
12
+
13
+
14
+ @invoke.task(
15
+ help={
16
+ "rebuild": "True to clean all previously built docs before starting, otherwise False.",
17
+ "doctest": "True to run doctests, otherwise False.",
18
+ "check_links": "True to check all web links in docs for validity, otherwise False.",
19
+ }
20
+ )
21
+ def docs(ctx, doctest=False, rebuild=False, check_links=False):
22
+ """Builds the HTML documentation."""
23
+
24
+ if rebuild:
25
+ clean(ctx)
26
+
27
+ with chdir(ctx.base_folder):
28
+ if doctest:
29
+ ctx.run("pytest --doctest-modules")
30
+
31
+ opts = "-E" if rebuild else ""
32
+ ctx.run("sphinx-build {} -b html docs dist/docs".format(opts))
33
+
34
+ if check_links:
35
+ linkcheck(ctx, rebuild=rebuild)
36
+
37
+
38
+ @invoke.task()
39
+ def linkcheck(ctx, rebuild=False):
40
+ """Check links in documentation."""
41
+ print("Running link check...")
42
+ opts = "-E" if rebuild else ""
43
+ ctx.run("sphinx-build {} -b linkcheck docs dist/docs".format(opts))
@@ -0,0 +1,37 @@
1
+ import invoke
2
+
3
+ from compas_invocations2.console import chdir
4
+
5
+
6
+ @invoke.task()
7
+ def lint(ctx):
8
+ """Check the consistency of coding style."""
9
+
10
+ print("\nRunning ruff linter...")
11
+ ctx.run("ruff check --fix src tests")
12
+
13
+ print("\nRunning black linter...")
14
+ ctx.run("black --check --diff --color src tests")
15
+
16
+ print("\nAll linting is done!")
17
+
18
+
19
+ @invoke.task()
20
+ def format(ctx):
21
+ """Reformat the code base using black."""
22
+
23
+ print("\nRunning ruff formatter...")
24
+ ctx.run("ruff format src tests")
25
+
26
+ print("\nRunning black formatter...")
27
+ ctx.run("black src tests")
28
+
29
+ print("\nAll formatting is done!")
30
+
31
+
32
+ @invoke.task()
33
+ def check(ctx):
34
+ """Check the consistency of documentation, coding style and a few other things."""
35
+
36
+ with chdir(ctx.base_folder):
37
+ lint(ctx)
@@ -0,0 +1,27 @@
1
+ import invoke
2
+
3
+ from compas_invocations2.console import chdir
4
+
5
+
6
+ @invoke.task()
7
+ def test(ctx, doctest=False):
8
+ """Run all tests."""
9
+ with chdir(ctx.base_folder):
10
+ if doctest:
11
+ ctx.run("pytest --doctest-modules")
12
+ else:
13
+ ctx.run("pytest")
14
+
15
+
16
+ @invoke.task()
17
+ def testdocs(ctx):
18
+ """Test the examples in the docstrings."""
19
+ print("Running doctest...")
20
+ ctx.run("pytest --doctest-modules")
21
+
22
+
23
+ @invoke.task()
24
+ def testcodeblocks(ctx):
25
+ """Test the examples in the code blocks of the docs."""
26
+ print("Running tests on doc code blocks...")
27
+ ctx.run("pytest docs")
@@ -0,0 +1,74 @@
1
+ Metadata-Version: 2.1
2
+ Name: compas_invocations2
3
+ Version: 0.2.0
4
+ Summary: A collection of reusable pyinvoke tasks.
5
+ Author-email: Li Chen <li.chen@arch.ethz.ch>
6
+ License: MIT License
7
+
8
+ ETH Zurich
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://compas-dev.github.io/compas_invocations2
29
+ Project-URL: Documentation, https://compas-dev.github.io/compas_invocations2
30
+ Project-URL: Repository, https://github.com/compas-dev/compas_invocations2.git
31
+ Project-URL: Changelog, https://github.com/compas-dev/compas_invocations2/blob/main/CHANGELOG.md
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Topic :: Scientific/Engineering
34
+ Classifier: Programming Language :: Python
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.9
37
+ Classifier: Programming Language :: Python :: 3.10
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Requires-Python: >=3.9
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Provides-Extra: dev
43
+ Requires-Dist: attrs>=17.4; extra == "dev"
44
+ Requires-Dist: black>=22.12.0; extra == "dev"
45
+ Requires-Dist: bump-my-version; extra == "dev"
46
+ Requires-Dist: compas_notebook; extra == "dev"
47
+ Requires-Dist: invoke>=0.14; extra == "dev"
48
+ Requires-Dist: ruff; extra == "dev"
49
+ Requires-Dist: sphinx_compas2_theme; extra == "dev"
50
+ Requires-Dist: twine; extra == "dev"
51
+ Requires-Dist: wheel; extra == "dev"
52
+
53
+ # compas_invocations2
54
+
55
+ [![pypi](https://img.shields.io/pypi/v/compas_invocations2.svg)](https://pypi.org/project/compas-invocations/)
56
+
57
+ A collection of reusable pyinvoke tasks
58
+
59
+ ## Usage
60
+
61
+ Import and add tasks to a collection in your project's `tasks.py` file:
62
+
63
+ import os
64
+ from invoke import Collection
65
+ from compas_invocations2 import style
66
+
67
+ ns = Collection(style.check, style.lint)
68
+ ns.configure(
69
+ {
70
+ "base_folder": os.path.dirname(__file__),
71
+ }
72
+ )
73
+
74
+ For a more complete example, check the [`tasks.py`](tasks.py) of this project.
@@ -0,0 +1,18 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ requirements-dev.txt
5
+ requirements.txt
6
+ src/compas_invocations2/__init__.py
7
+ src/compas_invocations2/build.py
8
+ src/compas_invocations2/console.py
9
+ src/compas_invocations2/docs.py
10
+ src/compas_invocations2/style.py
11
+ src/compas_invocations2/tests.py
12
+ src/compas_invocations2.egg-info/PKG-INFO
13
+ src/compas_invocations2.egg-info/SOURCES.txt
14
+ src/compas_invocations2.egg-info/dependency_links.txt
15
+ src/compas_invocations2.egg-info/not-zip-safe
16
+ src/compas_invocations2.egg-info/requires.txt
17
+ src/compas_invocations2.egg-info/top_level.txt
18
+ tests/test_placeholder.py
@@ -0,0 +1,11 @@
1
+
2
+ [dev]
3
+ attrs>=17.4
4
+ black>=22.12.0
5
+ bump-my-version
6
+ compas_notebook
7
+ invoke>=0.14
8
+ ruff
9
+ sphinx_compas2_theme
10
+ twine
11
+ wheel
@@ -0,0 +1 @@
1
+ compas_invocations2
@@ -0,0 +1,2 @@
1
+ def test_placeholder():
2
+ assert True