Skip to content

Commit

Permalink
build: prevent extensions from being duplicated in the wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobuikhuizen committed Feb 28, 2024
1 parent fd8361b commit f95f13a
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ ipyvuetify/generated
js/src/generated

# Compiled javascript
ipyvuetify/labextension/
ipyvuetify/nbextension/
prefix/share
js/lib

# Unit test / coverage reports
Expand Down
4 changes: 1 addition & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
include LICENSE
recursive-include ipyvuetify/nbextension *.*
recursive-include ipyvuetify/labextension *.*
include jupyter-vuetify.json
recursive-include prefix *.*
recursive-include ipyvuetify/extra *.vue
recursive-include ipyvuetify/generated *.*
16 changes: 14 additions & 2 deletions ipyvuetify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@
from .VuetifyTemplate import VuetifyTemplate


def _prefix():
import sys
from pathlib import Path

prefix = sys.prefix
here = Path(__file__).parent
# for when in dev mode
if (here.parent / "prefix").exists():
prefix = str(here.parent)
return prefix


def _jupyter_labextension_paths():
return [
{
"src": "labextension",
"src": f"{_prefix()}/prefix/share/jupyter/labextensions/jupyter-vuetify/",
"dest": "jupyter-vuetify",
}
]
Expand All @@ -18,7 +30,7 @@ def _jupyter_nbextension_paths():
return [
{
"section": "notebook",
"src": "nbextension",
"src": f"{_prefix()}/prefix/share/jupyter/nbextensions/jupyter-vuetify/",
"dest": "jupyter-vuetify",
"require": "jupyter-vuetify/extension",
}
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
},
"jupyterlab": {
"extension": "lib/labplugin",
"outputDir": "../ipyvuetify/labextension",
"outputDir": "../prefix/share/jupyter/labextensions/jupyter-vuetify",
"webpackConfig": "webpack.config.lab3.js",
"sharedPackages": {
"@jupyter-widgets/base": {
Expand Down
30 changes: 27 additions & 3 deletions js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ module.exports = [
entry: "./lib/extension.js",
output: {
filename: "extension.js",
path: path.resolve(__dirname, "..", "ipyvuetify", "nbextension"),
path: path.resolve(
__dirname,
"..",
"prefix",
"share",
"jupyter",
"nbextensions",
"jupyter-vuetify"
),
libraryTarget: "amd",
},
mode: "production",
Expand All @@ -39,7 +47,15 @@ module.exports = [
entry: "./lib/notebook.js",
output: {
filename: "index.js",
path: path.resolve(__dirname, "..", "ipyvuetify", "nbextension"),
path: path.resolve(
__dirname,
"..",
"prefix",
"share",
"jupyter",
"nbextensions",
"jupyter-vuetify"
),
libraryTarget: "amd",
},
devtool: "source-map",
Expand All @@ -62,7 +78,15 @@ module.exports = [
entry: "./lib/nodeps.js",
output: {
filename: "nodeps.js",
path: path.resolve(__dirname, "..", "ipyvuetify", "nbextension"),
path: path.resolve(
__dirname,
"..",
"prefix",
"share",
"jupyter",
"nbextensions",
"jupyter-vuetify"
),
libraryTarget: "amd",
},
devtool: "source-map",
Expand Down
File renamed without changes.
13 changes: 8 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ def run(self):

def get_data_files():
"""files that need to be installed in specific locations upon installation."""

nbext = [rel(f) for f in ROOT.glob("ipyvuetify/nbextension/*")]
package = [rel(f) for f in ROOT.glob("ipyvuetify/labextension/package.json")]
labext = [rel(f) for f in ROOT.glob("ipyvuetify/labextension/static/*")]
nbconfig = [rel(f) for f in ROOT.glob("jupyter-vuetify.json")]
nbext = [rel(f) for f in ROOT.glob("prefix/share/jupyter/nbextensions/jupyter-vuetify/*")]
package = [
rel(f) for f in ROOT.glob("prefix/share/jupyter/labextensions/jupyter-vuetify/package.json")
]
labext = [
rel(f) for f in ROOT.glob("prefix/share/jupyter/labextensions/jupyter-vuetify/static/*")
]
nbconfig = [rel(f) for f in ROOT.glob("prefix/etc/nbconfig/notebook.d/jupyter-vuetify.json")]

return [
("share/jupyter/nbextensions/jupyter-vuetify", nbext),
Expand Down

0 comments on commit f95f13a

Please sign in to comment.