You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[build] Fix flatc (#8816)
* [build] Fix flatc
We need to install `build/pip_data_bin_init.py.in` into `<executorch
root>/data/bin/__init__.py`. This PR rewrite the logic into a
`BuiltFile` so that it works well in editable mode.
Test:
```
python -c "from executorch.data.bin import flatc"
```
Will add unit test in next PR.
[ghstack-poisoned]
* Update on "[build] Fix flatc"
Fixes#8784
We need to install `build/pip_data_bin_init.py.in` into `<executorch
root>/data/bin/__init__.py`. This PR rewrite the logic into a
`BuiltFile` so that it works well in editable mode.
Since `BuiltFile` by default looks into cmake cache directory, this PR adds a placeholder `%CMAKE_CACHE_DIR%` for those are actually built by CMake and for `build/pip_data_bin_init.py.in` we don't add this placeholder.
Test:
```
python -c "from executorch.data.bin import flatc"
```
Will add unit test in next PR.
[ghstack-poisoned]
* Update on "[build] Fix flatc"
Fixes#8784
We need to install `build/pip_data_bin_init.py.in` into `<executorch
root>/data/bin/__init__.py`. This PR rewrite the logic into a
`BuiltFile` so that it works well in editable mode.
Since `BuiltFile` by default looks into cmake cache directory, this PR adds a placeholder `%CMAKE_CACHE_DIR%` for those are actually built by CMake and for `build/pip_data_bin_init.py.in` we don't add this placeholder.
Test:
```
python -c "from executorch.data.bin import flatc"
```
Will add unit test in next PR.
[ghstack-poisoned]
* Update on "[build] Fix flatc"
Fixes#8784
We need to install `build/pip_data_bin_init.py.in` into `<executorch
root>/data/bin/__init__.py`. This PR rewrite the logic into a
`BuiltFile` so that it works well in editable mode.
Since `BuiltFile` by default looks into cmake cache directory, this PR adds a placeholder `%CMAKE_CACHE_DIR%` for those are actually built by CMake and for `build/pip_data_bin_init.py.in` we don't add this placeholder.
Test:
```
python -c "from executorch.data.bin import flatc"
```
Will add unit test in next PR.
[ghstack-poisoned]
(cherry picked from commit d0b27b5)
Co-authored-by: Mengwei Liu <[email protected]>
This directory is used to host binaries installed during pip wheel build time.
4
+
5
+
## How to add a binary into pip wheel
6
+
7
+
1. Update `[project.scripts]` section of `pyproject.toml` file. Add the new binary name and it's corresponding module name similar to:
8
+
9
+
```
10
+
flatc = "executorch.data.bin:flatc"
11
+
```
12
+
13
+
For example, `flatc` is built during wheel packaging, we first build `flatc` through CMake and copy the file to `<executorch root>/data/bin/flatc` and ask `setuptools` to generate a commandline wrapper for `flatc`, then route it to `<executorch root>/data/bin/flatc`.
14
+
15
+
This way after installing `executorch`, a user will be able to call `flatc` directly in commandline and it points to `<executorch root>/data/bin/flatc`
16
+
17
+
2. Update `setup.py` to include the logic of building the new binary and copying the binary to this directory.
This means find `flatc` in `CMAKE_CACHE_DIR` and copy it to `<executorch root>/data/bin`. Notice that this works for both pip wheel packaging as well as editable mode install.
28
+
29
+
## Why we can't create this directory at wheel build time?
30
+
31
+
The reason is without `data/bin/` present in source file, we can't tell `setuptools` to generate a module `executorch.data.bin` in editable mode, partially because we don't have a good top level module `executorch` and have to enumerate all the second level modules, including `executorch.data.bin`.
# Replace %BUILD_TYPE% with the current build type.
233
-
self.src=self.src.replace("%BUILD_TYPE%", cfg)
243
+
src_path=src_path.replace("%BUILD_TYPE%", cfg)
234
244
else:
235
245
# Remove %BUILD_TYPE% from the path.
236
-
self.src=self.src.replace("/%BUILD_TYPE%", "")
246
+
src_path=src_path.replace("/%BUILD_TYPE%", "")
237
247
238
248
# Construct the full source path, resolving globs. If there are no glob
239
249
# pattern characters, this will just ensure that the source file exists.
240
-
srcs=tuple(cmake_cache_dir.glob(self.src))
250
+
srcs=tuple(build_dir.glob(src_path))
241
251
iflen(srcs) !=1:
242
252
raiseValueError(
243
-
f"""Expected exactly one file matching '{self.src}' in {cmake_cache_dir}; found {repr(srcs)}.
244
-
245
-
If that file is a CMake-built extension module file, and we are installing in editable mode, please disable the corresponding build option since it's not supported yet.
0 commit comments