xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
347 stars 58 forks source link

is there a procedure to install xtensor-python via standard pip on windows ? #96

Open stonebig opened 7 years ago

stonebig commented 7 years ago

maybe it's impossible...

SylvainCorlay commented 7 years ago

At the moment we have not provided one. We could do this via the install_headers directive.

My idea on this was to create an xtensor-pip package that would vendor xtensor and xtensor-python and install the headers the install_headers pip directive.

The drawback is that the headers are then (typically) installed under the python include directory - which is genrally different from the general include directory of the prefix (include vs include/pythonX.Y).

Maybe we could do this with python wheels' data files instead. If you have a suggestion, that would be great?

SylvainCorlay commented 7 years ago

cc @ghisvail .

If there is a reliable means with python wheels to install into the prefix include directory, that might be the solution, and we could simply add a setup.py to the repository.

alexandrebrilhante commented 4 years ago

Any update on this?

PerretB commented 4 years ago

One could do it in pybind11 or numpy style. First, define header files as package data : they will be copied in the package directory during install. Then define a method get_include that returns the path to the local include files, see eg. get_include in pybind11.

Of course this does not follow the classical system way to do it, but it is indeed pretty convenient and OS independent in a python context.

StefanUlbrich commented 4 years ago

Hi, I created a pull request where I copied the respective files from pybind11. Not finished yet but works for me already: #236

StefanUlbrich commented 4 years ago

I drafted a meta package that provides the headers.

https://github.com/StefanUlbrich/xtensor-cpp

Maybe this is a useful extension to the xtensor-stack?

JohanMabille commented 4 years ago

Hi @StefanUlbrich ,

Thank you for tackling this! I'm not sure yet, but I wonder if building the wheel with scikit-build and CMake could simplify the process:

@SylvainCorlay any thought on this?

StefanUlbrich commented 4 years ago

@JohanMabille what about conan? most of the xtensor stack is already there

JohanMabille commented 4 years ago

I am not sure if these packages are still maintained. Anyway this is orthogonal to pip, right? I mean, having a package for conan is independent from having / building a wheel for pip, or is there some bridge that makes it easy to have one when we already have the other?

StefanUlbrich commented 4 years ago

@JohanMabille The packages are still maintained but you are right. My idea was to have a simple package that can be installed and a numeric extension can be set up with minimal effort using setuptools. CMake is of course standard but might be overkill for those not familiar with it–I personally never became comfortable with it when I met it 10yrs ago. In addition, some projects might require lapack and blas installation and static linking (xtensor-blas). Do you think a cookie cutter would be more adequate? I am more than willing to contribute to an "official" endorsed "starter kit"

StefanUlbrich commented 4 years ago

Maybe this thread is a good way to start?

JohanMabille commented 4 years ago

CMake is of course standard but might be overkill for those not familiar with it

I totally agree, especially for people coming from Python and not having a lot of experience with C++ projects. What I meant is that we (developers and package maintainers) should leverage on existing CMake to build packages in order to make the process easier to maintain (no need to duplicate list of files, build flags, etc).

Do you think a cookie cutter would be more adequate?

We already provide a [cookie cutter] for authoring python extensions based on xtensor, but it might be broken (I haven't tried it for a while) and anyway it deserves some love ;). I think this (cookie cutter) and a wheel are complementary since the cookie cutter does not vendor the dependencies.

I am more than willing to contribute to an "official" endorsed "starter kit"

Thanks that is much appreciated! We have already experienced with scikit-build for building a more complicated stack. The process should be simpler for xtensor since it's a header-only library an it as fewer dependencies.

We split the R-bindings and Julia bindings in two packages, one pure C++ package, and one that vendors the C++ package and its dependencies (see https://github.com/xtensor-stack/Xtensor.R and https://github.com/xtensor-stack/xtensor-r for instance). As per in person conversation with @SylvainCorlay, we should do the same with xtensor-python: keep the headers and pure C++ stuff in xtensor-python and move the Python-related stuff in a new repo xtensor.py, that would vendor the dependencies and build the wheel based on scikit-build

Let us know what you prefer, you can create this xtensor.py repo and iterate on it until you have soething that works, then transfer it to the xtensor-stack organization, or we can create it directly here. In both cases I would be super happy to help with CMake and scikit-build.

SylvainCorlay commented 4 years ago

We already provide a [cookie cutter] for authoring python extensions based on xtensor, but it might be broken (I haven't tried it for a while) and anyway it deserves some love ;)

CI is set up for the cookiecutters. We should definitely give it a run.

We should do the same with xtensor-python: keep the headers and pure C++ stuff in xtensor-python and move the Python-related stuff in a new repo xtensor.py, that would vendor the dependencies and build the wheel based on scikit-build.

👍 we have done this for both Julia and R.

Coderx7 commented 4 years ago

Hey everyone, Any update on this?

JohanMabille commented 4 years ago

We are swamped with a lot of other tasks and don't have the time to implement it for now. We can provide some guidance if you want to tackle this.

StefanUlbrich commented 4 years ago

Just switched jobs. I'd love to continue within the next few weeks.

benbovy commented 1 year ago

That would be great to have, so that nowadays we could just use scikit-build-core with:

[build-system]
requires = ["scikit-build-core", "pybind11", "xtensor-python"]
build-backend = "scikit_build_core.build"

[project]
name = "my_python_extension"
version = "0.0.1"
dependencies = ["numpy"]

And then python -m pip install .

I'm already using scikit-build-core with xtensor(-python) installed via conda/mamba, which works well although it is slightly less convenient (I need to run python -m pip install . --no-build-isolation).

benbovy commented 1 year ago

I did some experiment here: https://github.com/benbovy/xtensor-python-wheel

I used scikit-build-core together with simple pyproject.toml files and CMake's FetchContent to create wheels for the xtensor projects. It is actually very straightforward! The repository also contains a small example that is built from the installed wheels in a github action.

Caveats: