NotADirectoryError when installing from source distribution #1180
Replies: 2 comments 2 replies
-
A word of caution, as of now this suggested layout would require |
Beta Was this translation helpful? Give feedback.
-
@thegamecracks Would you be interested in PRing your suggested fix? |
Beta Was this translation helpful? Give feedback.
-
When attempting to install the package specifically using its source distribution rather than the built wheels, the following error occurs:
After some debugging, it appears that hatch is trying to build the JavaScript client and assumes
src/js/
is present, but in the source distribution that directory is missing. Here is the build configuration in question:reactpy/src/py/reactpy/pyproject.toml
Lines 127 to 136 in 3a3ad3f
Right now, both the sdist and wheels uploaded on PyPI contain the
reactpy/_static/
files generated bynpm run build
(inspector), but hatch is configured to build the client even when the source distribution already has the output files. This isn't a major issue since reactpy's wheels aren't dependent on system architecture, but it would be nice to have this part of the build process fixed (or at least documented).The ideal solution would be to include the JS client's source code in the sdist and only build it when installing from source / generating the wheel. I thought of suggesting this:
However it breaks installing from source (
pip install src/py/reactpy
) as pip skips building the sdist and therefore won't copyjs/
to the correct place. I also don't know if there's an alternative toforce-include
which can map paths outside of the project root while respecting .gitignore. Absent that, it would be easy to accidentally pollute the sdist withnode_modules
.In theory a symbolic link to
src/js/
could remedy this along with slightly different changes to pyproject.toml, specifically the use ofonly-include
:But while it works when generating the sdist / building from sdist (
python -m build
), thenpm run build
command fails when installing from source or building the wheel from source (hatch build
/python -m build --wheel
):FWIW, in an unrelated package, sardine-web, I structured it so the JS client's source code was inside the package itself, but setup.py would build the client and remove the source code afterwards, leaving only the source code in the sdist and its compiled result in the wheel. In hindsight, it probably would have been easier had I left the client source code outside of the package and only included it in the sdist via MANIFEST.in. Given hatch's own mechanisms for controlling distributions, plus the convenience of
hatch-build-scripts
, it might be easier to movesrc/js/
beside thesrc/py/reactpy/reactpy/
package and follow the previous suggestion to pyproject.toml, rather than try to find a workaround with the current layout.Beta Was this translation helpful? Give feedback.
All reactions