Building python package out of source directory

I was wondering if there was a way to build the tvm python package without doing this in the source directory. Right now it seems to only work if you call

python setup.py build_ext

From the TVM_DIR/python folder.

Since we try to separate our build folders from our source folders, it would be helpful if the setup script was portable.

Hi @samcha, thanks for the post.

I think at the moment there is no mechanism to allow an out of tree Python package building in TVM. I think it would require copying some directories and files around, namely “standalone_crt”, “configs”, that are currently encoded in the setup.py (reference) configuration.

This setup script follows Python setuptools (reference), so I’m not sure to what extent we can make it to be portable in the way you describe.

What I think would be an easier solution, would be to have a separate script, to create that package on a given location, and then cleanup the Python tree. Sorry I certainly don’t have a definitive solution.

cc @areusch @Mousius @driazati for more suggestions and ideas

@samcha do you just need setup.py to work when cwd is a different dir, or do you need to physically move it in your fork of tvm?

Hello @leandron and @areusch. Thanks for your quick answers.

Basically, we are trying to enable a workflow with several projects including a fork of TVM. We want to setup our workflow so that the source files are kept in a directory of the type

workspace/ ├─ src/ │ ├─ tvm/ │ ├─ other/ ├─ build/ │ ├─ tvm/ │ ├─ other/

Ideally all build artifacts would be generated in build/. I’ve also tried this command from stack overflow but it looks like there are still some hardcoded relative paths in setup.py.

I will probably keep doing as we’re doing as @leandron suggested: building the artifacts under the python directory in source and then cleaning up the artifacts with a script. Thanks anyways for your suggestions.

1 Like