Skip to content

Commit

Permalink
Merge pull request #9 from blink1073/editable-build-kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed May 21, 2022
2 parents 9a95d5e + 850ca9d commit 3990b4e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- <START NEW CHANGELOG ENTRY> -->

## 0.2.1
## 0.2.2

([Full Changelog](https://github.com/blink1073/hatch_jupyter_builder/compare/v0.2.0...880241f6537ecd3e1ad7fc202cb410dc8545f9fc))

Expand Down
28 changes: 23 additions & 5 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
MIT License
Copyright (c) 2022 Project Jupyter Contributors
All rights reserved.

Copyright (c) 2022-present Steven Silvester <steven.silvester@ieee.org>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ The optional `ensured-targets` is a list of expected file paths after building a
The optional `build-kwargs` is a set of keyword arguments to pass to the build
function.

You can also use `editable-build-kwargs` if the parameters should differ
in editable mode. If only the build command is different, you can use
`editable_build_cmd` in `build-kwargs` instead.

The optional `install-pre-commit-hook` boolean causes a `pre-commit` hook to be installed during an editable install.

### Npm Builder Function
Expand Down
5 changes: 5 additions & 0 deletions hatch_jupyter_builder/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ def initialize(self, version, build_data):
# Get the configuration options.
build_function = self.config.get("build-function")
build_kwargs = self.config.get("build-kwargs", {})
editable_build_kwargs = self.config.get("editable-build-kwargs")
ensured_targets = self.config.get("ensured-targets", [])

if not build_function:
return

# Get build function and call it with normalized parameter names.
build_func = get_build_func(build_function)

if version == "editable":
build_kwargs = editable_build_kwargs or build_kwargs

build_kwargs = normalize_kwargs(build_kwargs)
build_func(self.target_name, version, **build_kwargs)

Expand Down
6 changes: 6 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ def foo(target_name, version, foo_bar=None, fizz_buzz=None):
hook = JupyterBuildHook(tmp_path, {}, {}, {}, tmp_path, "wheel")
hook.initialize("standard", {})
hook.initialize("editable", {})

config["editable-build-kwargs"] = {"foo-bar": "2", "fizz_buzz": "3"}
hook.initialize("editable", {})

hook = JupyterBuildHook(tmp_path, config, {}, {}, tmp_path, "foo")
hook.initialize("standard", {})

0 comments on commit 3990b4e

Please sign in to comment.