Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build directory for editable installations #370

Closed
dnicolodi opened this issue Mar 29, 2023 · 18 comments · Fixed by #387
Closed

Build directory for editable installations #370

dnicolodi opened this issue Mar 29, 2023 · 18 comments · Fixed by #387
Labels
enhancement New feature or request release-blocker
Milestone

Comments

@dnicolodi
Copy link
Member

dnicolodi commented Mar 29, 2023

The build directory for editable build is currently .mesonpy/editable/build in the source directory. I don't see a reason why the build directory is nested two levels deep into otherwise empty directories . A flatter directory structure could be used.

While doing so, attaching a Python API tag to the build directory name would allow to have multiple parallel installations of the same package for different interpreters.

Isn't there prior art for choosing the name of the build directory? I don't like something specific to meson-python much. Python uses __pycache__ for its cache. Is it allowed to add tool specific stuff in there? distutils uses a build folder, IIRC. What about other build backends?

It would be nice to have this decided before we release a version with the editable support.

EDIT: reworded for politeness

@dnicolodi dnicolodi added this to the v0.13.0 milestone Mar 29, 2023
@rgommers
Copy link
Contributor

Isn't there prior art for choosing the name of the build directory?

I'd say build/ in the root dir is the one more or less standard name - not just distutils/setuptools, but also Sphinx (also that also uses _build sometimes). Not sure about other backends, never had a need to actually use them.

The downside of build is that it may clash with a standard choice for using Meson directly (meson setup build, ninja -C build is already mostly muscle memory for me).

Reusing __pycache__ is a no no I'd say.

Also attaching a Python API tag to the build directory name would allow to have multiple parallel installations of the same package for different interpreters.

Hmm, that is an interesting point.

@rgommers
Copy link
Contributor

I'd say that whatever we choose here is a private implementation detail though - the user has no business doing anything with it beyond adding it to .gitignore, so we should be fine tweaking it later.

@rgommers
Copy link
Contributor

Thinking about this some more:

  • a hidden dir isn't nice, it's already tricked me once or twice, and I kinda knew it should be there
  • build is the standard name
  • separate interpreters can already be supported via the builddir option (I tested it with pip install -e . --no-build-isolation --config-settings=builddir=build-py310 and it works)
  • build clashing with the distutils default may actually be a good thing; having in-tree remnants from a distutils build can in some cases cause problems

tl;dr let's use build?

@dnicolodi
Copy link
Member Author

I like build too. I like supporting multiple interpreters out of the box. Having a two level directory structure solves this: build/cp311 or build/cpython-3.11/ but I don't know if this is a common enough use case that is worth supporting.

@rgommers
Copy link
Contributor

I'd prefer to not special-case interpreters I think. Different builds can also happen with different compilers (e.g., using GCC and Clang in parallel), different sets of build dependencies (on SciPy testing with 2 numpy versions is much more interesting than testing with 2 cpython versions), and so on.

Plus it does bring up questions like "what if we have regular and a debug 3.11 interpreters".

Matrix'ed environment testing is for tools like tox/nox or custom scripts I'd say, and they can easily pass a builddir for anything like this.

@FFY00

This comment was marked as off-topic.

@FFY00 FFY00 added the enhancement New feature or request label Mar 31, 2023
@FFY00
Copy link
Member

FFY00 commented Mar 31, 2023

Other possible option would be putting the build directory on the installation path, instead of the project source. This would also allow installations to different interpreters without any conflicts.

@dnicolodi

This comment was marked as off-topic.

@rgommers

This comment was marked as off-topic.

@rgommers
Copy link
Contributor

Also attaching a Python API tag to the build directory name would allow to have multiple parallel installations of the same package for different interpreters.

+1 on this.

Okay, you both agree on this, so let's go that way.

For the other choices, how about I make an editorial decision here? Seems preferred over lots more discussion.

@dnicolodi
Copy link
Member Author

I proposed tagging the build directory with the python interpreter API tag in some form because the editable wheel documentation page prominently warns (or at least I remember it this way) to the fact that being able to have editable wheels for multiple interpreters as a limitation. I thought that, if the limitation was felt so important, adding a tiny amount of complexity to allow it could have been a good compromise.

However, I'm a big fan of keeping things simple unless necessary, thus I'm happy without this feature and a paragraph in the documentation that mentions how to achieve the same using the builddir config setting.

I'm fine with @rgommers picking the build directory name that he prefers. I opened this issue only because the nested directories are not required to exist anymore and I thought we could simplify what we present to the users before releasing editable wheel support in the next release.

@FFY00

This comment was marked as off-topic.

@FFY00

This comment was marked as off-topic.

@dnicolodi

This comment was marked as off-topic.

@dnicolodi

This comment was marked as off-topic.

@FFY00

This comment was marked as off-topic.

@dnicolodi
Copy link
Member Author

I'd say that whatever we choose here is a private implementation detail though - the user has no business doing anything with it beyond adding it to .gitignore, so we should be fine tweaking it later.

We can use the same trick that Meson uses and place a .gitignore containing * in the build directory. Meson does not do that when the build directory is not empty, and we add the native file to the build directory before invoking meson setup, thus Meson does not do that for us.

@dnicolodi
Copy link
Member Author

setuptools uses a build/__editable__.* directory for editable installs in strict mode https://setuptools.pypa.io/en/latest/userguide/development_mode.html#strict-editable-installs I haven't checked yet what .* should be replaced with

dnicolodi added a commit to dnicolodi/meson-python that referenced this issue Apr 11, 2023
Change the editable install build directory to a subdirectory named
after the ABI tag for the target Python interpreter placed in the
``build`` directory in the project source directory.

Add .gitignode and .hgignore files with catch all glob patterns to the
``build`` directory, if it is empty, to have the major VCS systems
ignore it.

Fixes mesonbuild#370, mesonbuild#380.
rgommers pushed a commit that referenced this issue Apr 12, 2023
Change the editable install build directory to a subdirectory named
after the ABI tag for the target Python interpreter placed in the
``build`` directory in the project source directory.

Add .gitignode and .hgignore files with catch all glob patterns to the
``build`` directory, if it is empty, to have the major VCS systems
ignore it.

Fixes #370, #380.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request release-blocker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants