scikit-build icon indicating copy to clipboard operation
scikit-build copied to clipboard

Support out-of-source build

Open henryborchers opened this issue 6 years ago • 12 comments

I'm trying to make an out of source build. but I can't set the build path. It's always builds to the directory, _skbuild.

I've tried using --bdist-dir c:\some\other\path\on\my\system when generating a wheel but this seems to be ignored.

henryborchers avatar Mar 29 '18 17:03 henryborchers

Thanks for the report.

The option --bdist-dir is not supported yet.

It's always builds to the directory, _skbuild.

If that helps, in the next release, build directory will be like _skbuild/platform-X.Y where platform and X.Y matches the python version used to build the wheel.

See http://scikit-build.readthedocs.io/en/latest/changes.html#next-release

jcfr avatar Mar 29 '18 18:03 jcfr

I notices that. Unfortunately, it doesn't help me in my case.

In the meantime, is it possible to create _skbuild as a subdirectory inside the default "build" folder just like the other Python build system do, for consistency.

henryborchers avatar Mar 29 '18 19:03 henryborchers

In the meantime, is it possible to create _skbuild as a subdirectory inside the default "build" folder just like the other Python build system do, for consistency.

Good idea

The following code would have to be updated along with the tests:

https://github.com/scikit-build/scikit-build/blob/d5fa09fb28caddad73f7a7f141969cdda28266b4/skbuild/constants.py#L10-L13

Would be great if you could contribute a patch.

it doesn't help me in my case.

Now to support --bdist-dir, you would have to update _parse_setuptools_arguments and update the variable SKBUILD_DIR referenced above.

https://github.com/scikit-build/scikit-build/blob/d5fa09fb28caddad73f7a7f141969cdda28266b4/skbuild/setuptools_wrap.py#L117-L144

jcfr avatar Mar 29 '18 19:03 jcfr

Also, could you describe your use case ?

Waiting this feature is implemented, that would help identify a workaround and/or update the documentation.

jcfr avatar Mar 29 '18 19:03 jcfr

Good idea. I'll take a look and see if I can write and contribute a patch.

For my use case... I'm using my main CMake script to call python setup.py as a custom_target to generate a bdist wheel with compiled extensions.

Basically my workflow:

  1. Run my main CMakelists which executes Python on my setup.py as a custom target with the flags so that they build and destination folders reside in the CMAKE_BINARY_DIR
  2. Scikit build uses the CMakeLists.txt to build and link my c++ extension.
  3. A Wheel in generated.
  4. I use that wheel as part of my larger project or do whatever with it.

This works very well for the most part, except when I'm using CMake directly, I want to keep my source tree clean while having all binary and generated files placed into another directory located elsewhere. If I have to wipe everything out and start a build over from scratch, I can just delete the projects build folder and start again . This workflow hasn't been a problem with setuptools based projects with the correct flags set. However, since the current version of Scikit Build always generates a build folder in the same folder as the source, I have to manually clean it up. It's not a huge deal but it can sometimes be annoying if I forget.

henryborchers avatar Mar 30 '18 16:03 henryborchers

with setuptools based projects with the correct flags set

Are you only using --bdist-dir ? Or are you also specifying flags like --egg-base, --dist-dir, ... ?

Would it work for you with scikit-build accept a parameter named --skbuild-dir=/path/to/skbuild ?

You could then ensure the source tree remains clean by specifying --skbuild-dir, --egg-base and --dist-dir

jcfr avatar Jun 20 '18 05:06 jcfr

To simplify, we could also have --egg-base automatically set if --skbuild-dir is provided.

jcfr avatar Jun 26 '18 00:06 jcfr

I’m only creating a bdist wheel and an sdist. I’ve never used —egg-base.

henryborchers avatar Jun 26 '18 00:06 henryborchers

Thanks for clarifying.

I mentioned —egg-base because without specifying it, a directory ending with .egg-info is always created in the source directory.

To ensure the source directory remains untouched, based on my experiment it needs to be specified when building wheels.

jcfr avatar Jun 26 '18 00:06 jcfr

I am expecting this feature also. In my case, there are three python (conda) environments (py3.6, py3.6, py3.7) and there is a need to use skbuild to install cpp/py code in all these envi's. But the generated _skbuild dir will be the same if the python versions are the same.

Thanks.

7starsea avatar Aug 16 '19 01:08 7starsea

I'm also running into a use case where having the ability to override "_skbuild" would be useful.

I'm building manylinux2010 wheels, so the docker container ends up writing to _skbuild with root permissions. I currently work around this by simply changing the permissions of the _skbuild folder inside docker, but it would be nice if I could simply tell scikit-build to write the build files to a different directory. (of course I could always copy the source directory somewhere do all the docker build there and selectively copy things back, but I think a scikit-build option might be cleaner)

Erotemic avatar Nov 08 '19 15:11 Erotemic

Ugly, but you can monkey patch this with something like:

import skbuild.constants

def SKBUILD_DIR():
    return os.path.join(
        "/tmp",
        "{}-{}".format(skbuild.constants._SKBUILD_PLAT_NAME, '.'.join(map(str, sys.version_info[:2]))),
    )

aws-taylor avatar Oct 15 '20 20:10 aws-taylor