Skip to content

Commit 1abff9d

Browse files
cccclaifacebook-github-bot
authored andcommitted
Simplify pip install process (#19)
Summary: Pull Request resolved: #19 setup.py is noted as legacy (https://pip.pypa.io/en/stable/reference/build-system/setup-py/) however there are many features not supported with pyprojects.toml, and it's more handy to have do `pip install executorch` directly as we can set up examples in colab directly as part of the demos. pytorch core also users [`setup.py`](https://github.com/pytorch/pytorch/blob/main/setup.py) so I think it should be ok Differential Revision: D47722560 fbshipit-source-id: a4d62a19b4bac88d97a31fe30a94614a787fd634
1 parent 59c31eb commit 1abff9d

File tree

4 files changed

+64
-11
lines changed

4 files changed

+64
-11
lines changed

.github/workflows/pull.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ jobs:
2626
pushd "${HOME}"
2727
# Create the softlink to the workspace as install.sh requires to run from its parent directory
2828
ln -s "${WORKSPACE}" executorch
29-
# Install executorch
30-
source executorch/install.sh
29+
30+
ls
31+
pip install executorch
3132
3233
# Just print out the list of packages for debugging
3334
pip list

docs/website/docs/tutorials/setting_up_executorch.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,27 @@ pip install --pre torch -i https://download.pytorch.org/whl/nightly/cpu
2121

2222
**Step 2: Set up Executorch**. This will install an `executorch` pip package to your conda environment.
2323
```bash
24-
mkdir -p ~/src/
25-
cd ~/src/
2624

2725
# Do one of these, depending on how your auth is set up
2826
git clone https://github.com/pytorch/executorch.git
2927
git clone [email protected]:pytorch/executorch.git
3028

31-
# Run the following to get all submodules
29+
# [Runtime requirement] Run the following to get all submodules, only need for runtime setup
3230
git submodule update --init --recursive
3331

34-
./executorch/install.sh
32+
pip install executorch
3533

3634
# cd into a directory that doesn't contain a `./executorch/exir` directory, since
3735
# otherwise python will try using it for `import executorch.exir...` instead of using the
3836
# installed pip package.
39-
cd ~/
37+
cd executorch
4038
```
4139

4240
**Step 3: Try it out**
4341

4442
Via python script:
4543
```
46-
python ~/src/executorch/examples/export/export_example.py -m "add"
44+
python ~/executorch/examples/export/export_example.py -m "add"
4745
```
4846

4947
Or via python interpreter:

pyproject.toml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ dependencies=[
1111
"sympy",
1212
]
1313

14-
[tool.setuptools.packages.find]
15-
where = ["src"]
16-
1714
[tool.setuptools.package-data]
1815
"*" = ["*.fbs", "*.yaml"]
1916

setup.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# from setuptools import setup, find_packages
2+
import os
3+
import shutil
4+
5+
from setuptools import setup
6+
from setuptools.command.develop import develop
7+
from setuptools.command.egg_info import egg_info
8+
from setuptools.command.install import install
9+
10+
11+
def custom_command():
12+
src_dst_list = [
13+
("schema/scalar_type.fbs", "exir/serialize/scalar_type.fbs"),
14+
("schema/schema.fbs", "exir/serialize/schema.fbs"),
15+
]
16+
for src, dst in src_dst_list:
17+
print(f"copying from {src} to {dst}")
18+
shutil.copyfile(src, dst)
19+
20+
for _, dst in src_dst_list:
21+
if not os.path.isfile(dst):
22+
raise FileNotFoundError(
23+
f"Could not find {dst}, copying file from {src} fails."
24+
)
25+
26+
27+
class CustomInstallCommand(install):
28+
def run(self):
29+
custom_command()
30+
install.run(self)
31+
32+
33+
class CustomDevelopCommand(develop):
34+
def run(self):
35+
custom_command()
36+
develop.run(self)
37+
38+
39+
class CustomEggInfoCommand(egg_info):
40+
def run(self):
41+
custom_command()
42+
egg_info.run(self)
43+
44+
45+
setup(
46+
package_dir={
47+
"executorch/backends": "backends",
48+
"executorch/exir": "exir",
49+
"executorch/schema": "schema",
50+
"executorch/extension": "extension",
51+
},
52+
cmdclass={
53+
"install": CustomInstallCommand,
54+
"develop": CustomDevelopCommand,
55+
"egg_info": CustomEggInfoCommand,
56+
},
57+
)

0 commit comments

Comments
 (0)