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

Ignore DESTDIR when installing to _skbuild #475

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jokva
Copy link
Contributor

@jokva jokva commented Mar 30, 2020

The cmake --build --target install command is used to move built
artefacts to _skbuild/, but when used in an environment with staged
installs (DESTDIR [1] [2]) the _skbuild directory also ends up there.
This is never desired as the _skbuild is an internal detail to the
scikit-build process, and DESTDIR is not meant to be used to specify the
build location.

[1] Happens in larger projects where scikit-build is not the only player
[2] https://github.com/equinor/segyio/blob/0c791d0f0ae4973058a51e2014837946e668902b/python/setup.py

@jokva jokva force-pushed the ignore-destdir-internal-install branch 2 times, most recently from 5613734 to a8cec5f Compare March 30, 2020 12:30
@jokva
Copy link
Contributor Author

jokva commented Mar 30, 2020

Alright, this should be more-or-less complete now. I'm not sure about the failing tests, they shouldn't be affected at all by this patch.

@thewtex thewtex requested a review from jcfr March 30, 2020 20:42
skbuild/cmaker.py Outdated Show resolved Hide resolved
@@ -491,6 +519,8 @@ def make(self, clargs=(), config="Release", source_dir=".", env=None):
shlex.split(os.environ.get("SKBUILD_BUILD_OPTIONS", "")))
)

env = env_without_destdir(env)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, you would then update

def make(self, clargs=(), config="Release", source_dir=".", env=None):

to be something like this

@env_without_destdir
def make(self, clargs=(), config="Release", source_dir=".", env=None):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will work out well, at least not without breaking the interface. The env= parameter is forwarded to subprocess.call, which expects either None (inherit parent's environment), or a specific environment as a dict. Unless the context decorator implements dict as well, some translation is needed.

Also, it would have to quietly hijack the env= argument. I ended up writing it as a context manager though, but with an explicit with. One benefit I think is the communication of intent, it's really just for the internal install target the environment variables should be ignored.

The cmake --build --target install command is used to move built
artefacts to _skbuild/, but when used in an environment with staged
installs (DESTDIR [1] [2]) the _skbuild directory also ends up there.
This is never desired as the _skbuild is an internal detail to the
scikit-build process, and DESTDIR is not meant to be used to specify the
build location.

[1] Happens in larger projects where scikit-build is not the only player
[2] https://github.com/equinor/segyio/blob/0c791d0f0ae4973058a51e2014837946e668902b/python/setup.py
Running a command in a specific, modified environment, and then
restoring the original environment, is useful also outside a testing
context.

Move the push_env to skbuild.units and update the imports. At the same
time, make it derive from the ContextDecorator for some extra bells and
whistles.
@jokva jokva force-pushed the ignore-destdir-internal-install branch from a8cec5f to 12a9399 Compare March 31, 2020 02:37
Copy link
Contributor

@jcfr jcfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙏 for the quick turnaround.

skbuild/cmaker.py Show resolved Hide resolved
skbuild/cmaker.py Show resolved Hide resolved
@jcfr
Copy link
Contributor

jcfr commented Mar 31, 2020

Waiting the CI issues are fixed, I will manually test on windows and then integrate. Thanks for your patience.

@jokva
Copy link
Contributor Author

jokva commented Mar 31, 2020

Not a problem :---) I've applied the same hack in my downstream problems, which I can revert when this is integrated (and released) here.

@hobu
Copy link

hobu commented Nov 24, 2020

Just to chime in that I ran into this and it was very confusing. If this can't be merged, a simple warning shouting to the user that DESTDIR is set would hopefully give them the hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants