|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | from setuptools import setup, find_packages |
| 4 | +from setuptools.command.build_py import build_py |
4 | 5 | from pathlib import Path |
5 | 6 |
|
6 | 7 | from jupyter_packaging import ( |
|
102 | 103 | ), |
103 | 104 | ] |
104 | 105 |
|
105 | | -cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec) |
106 | | -cmdclass["jsdeps"] = combine_commands( |
107 | | - install_npm(JS_DIR, npm=["yarn"], build_cmd="build:prod"), |
108 | | - ensure_targets(jstargets), |
109 | | -) |
110 | | -package["cmdclass"] = cmdclass |
| 106 | +package["cmdclass"] = { |
| 107 | + **create_cmdclass("jsdeps", data_files_spec=data_files_spec), |
| 108 | + "jsdeps": combine_commands( |
| 109 | + install_npm(JS_DIR, npm=["yarn"], build_cmd="build:prod"), |
| 110 | + ensure_targets(jstargets), |
| 111 | + ), |
| 112 | +} |
| 113 | + |
| 114 | +# -------------------------------------------------------------------------------------- |
| 115 | +# Build Pth File |
| 116 | +# -------------------------------------------------------------------------------------- |
| 117 | + |
| 118 | +BuildPyBase: type[build_py] = package["cmdclass"]["build_py"] |
| 119 | + |
| 120 | + |
| 121 | +class BuildPy(BuildPyBase): |
| 122 | + """Include the .pth file for this project, in the generated wheel.""" |
| 123 | + |
| 124 | + def run(self): |
| 125 | + super().run() |
| 126 | + pth_file = f"{NAME}.pth" |
| 127 | + self.copy_file( |
| 128 | + str(ROOT_DIR / pth_file), |
| 129 | + str(Path(self.build_lib) / pth_file), |
| 130 | + preserve_mode=0, |
| 131 | + ) |
| 132 | + |
| 133 | + |
| 134 | +package["cmdclass"] = {**package["cmdclass"], "build_py": BuildPy} |
111 | 135 |
|
112 | 136 | # ----------------------------------------------------------------------------- |
113 | 137 | # Install It |
|
0 commit comments