dhermes / bezier

Helper for Bézier Curves, Triangles, and Higher Order Objects
Apache License 2.0
266 stars 36 forks source link

`...` as path (e.g. `BUILD_DIR=".../libbezier-debug/build"`) in Development doc is confusing #284

Open Cilyan opened 2 years ago

Cilyan commented 2 years ago

First, ... is not a "valid" path under Linux (it would create a ... folder, which is a hidden folder, so probably not what we want).

Then, CMAKE_INSTALL_PREFIX:PATH seems to be relative to BUILD_DIR, so with

BUILD_DIR="../libbezier-release/build"
INSTALL_PREFIX="../libbezier-release/usr"

the installation path is effectively ../libbezier-release/libbezier-release/usr (= ../libbezier-release/build/../libbezier-release/usr). Although, in the docs, the way the same pattern is repeated for both variables (.../libbezier-release/) lets the user think that both paths are relative to the current directory. In any case, BEZIER_INSTALL_PREFIX cannot be set to INSTALL_PREFIX but should rather be set to $BUILD_DIR/$INSTALL_PREFIX.

... is, I believe, the Windows equivalent for ../.. (go up two folders), and it would somehow work if one would just replace ... with ../.. (because you go down two folders, then up two folders). But it works only in this very specific case and in a real situation, going up two folders may not be possible (location not writable, for example if you are working in /home/user/bezier, /tmp/bezier, ...).

Finally, it seems that I still get some issues, despite my best effort to convert the snippets from the docs to something Linux would accept:

$ BEZIER_INSTALL_PREFIX=../libbezier-release/libbezier-release/usr python -m pip wheel .
Collecting numpy>=1.21.4
  File was already downloaded /***/bezier/numpy-1.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Building wheels for collected packages: bezier
  Building wheel for bezier (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-q6skltn4/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-q6skltn4/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-0gana1og
       cwd: /tmp/pip-req-build-q6skltn4/
  Complete output (55 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.10
  creating build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/triangle.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/curved_polygon.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/curve.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_triangle_intersection.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_triangle_helpers.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_symbolic.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_plot_helpers.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_intersection_helpers.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_helpers.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_geometric_intersection.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_curve_helpers.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_base.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/__init__.py -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/__config__.py -> build/lib.linux-x86_64-3.10/bezier
  creating build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/triangle_intersection.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/triangle_helpers.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/intersection_helpers.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/helpers.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/geometric_intersection.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/curve_helpers.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/clipping.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/algebraic_intersection.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/hazmat/__init__.py -> build/lib.linux-x86_64-3.10/bezier/hazmat
  copying src/python/bezier/_triangle_intersection.pxd -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_triangle.pxd -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_status.pxd -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_helpers.pxd -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_curve_intersection.pxd -> build/lib.linux-x86_64-3.10/bezier
  copying src/python/bezier/_curve.pxd -> build/lib.linux-x86_64-3.10/bezier
  running build_ext
  building 'bezier._speedup' extension
  creating build/temp.linux-x86_64-3.10
  creating build/temp.linux-x86_64-3.10/src
  creating build/temp.linux-x86_64-3.10/src/python
  creating build/temp.linux-x86_64-3.10/src/python/bezier
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fPIC -I/usr/lib/python3.10/site-packages/numpy/core/include -I../libbezier-release/libbezier-release/usr/include -I/usr/include/python3.10 -c src/python/bezier/_speedup.c -o build/temp.linux-x86_64-3.10/src/python/bezier/_speedup.o
  In file included from /usr/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1969,
                   from /usr/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                   from /usr/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from src/python/bezier/_speedup.c:621:
  /usr/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     17 | #warning "Using deprecated NumPy API, disable it with " \
        |  ^~~~~~~
  src/python/bezier/_speedup.c:623:10: fatal error: bezier/curve.h: No such file or directory
    623 | #include "bezier/curve.h"
        |          ^~~~~~~~~~~~~~~~
  compilation terminated.
  error: command '/usr/bin/gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for bezier
  Running setup.py clean for bezier
Failed to build bezier
ERROR: Failed to build one or more wheels

despite the files being there:

$ find ../libbezier-release/libbezier-release/usr/include
../libbezier-release/libbezier-release/usr/include
../libbezier-release/libbezier-release/usr/include/bezier.h
../libbezier-release/libbezier-release/usr/include/bezier
../libbezier-release/libbezier-release/usr/include/bezier/curve.h
../libbezier-release/libbezier-release/usr/include/bezier/curve_intersection.h
../libbezier-release/libbezier-release/usr/include/bezier/helpers.h
../libbezier-release/libbezier-release/usr/include/bezier/status.h
../libbezier-release/libbezier-release/usr/include/bezier/triangle.h
../libbezier-release/libbezier-release/usr/include/bezier/triangle_intersection.h

Version used:

$ git describe --always --tags
2021.2.12-63-ge6925aad
dhermes commented 2 years ago

@Cilyan It is not intended to be a valid path. It is intended to be a "fill in the blanks" for the reader. I thought it was clear that it's "fill in the blanks" since it isn't a valid path (as you are pointing out here). Clearly I was mistaken on the clarity.

Do you have any suggestions on how to improve this block so that it's actual advice along the lines of:


For context, this is what he is referring to https://bezier.readthedocs.io/en/2021.2.12/development.html#libbezier

dhermes commented 2 years ago

The fact that python -m pip wheel . fails for you is curious. It seems like it should for your chosen build root. Try two different things to see if it fixes the issue:

Cilyan commented 2 years ago

I finally had time to dive a bit more into it. Indeed, it works only if you set the path as absolute. For the documentation, it is more common to find something like BEZIER_INSTALL_PREFIX="/<absolute-path-to>/build/usr" python -m pip wheel ..

Also, people often expect that these kind of lines can simply be copied and pasted, so this could work:

$ SRC_DIR="src/fortran/"
$ BUILD_DIR="$(pwd)/build"
$ INSTALL_PREFIX="usr"
$ mkdir -p "${BUILD_DIR}"
$ cmake \
    -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_INSTALL_PREFIX:PATH="${INSTALL_PREFIX}" \
    -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
    -S "${SRC_DIR}" \
    -B "${BUILD_DIR}"
$ cmake \
    --build "${BUILD_DIR}" \
    --config Debug \
    --target install

and

$ BEZIER_INSTALL_PREFIX="${BUILD_DIR}/${INSTALL_PREFIX}" python -m pip wheel .

Note that I removed the chevrons, they get copied together with the command and when pasted in a terminal, this doesn't work. The dollar signs are properly placed apart by the code-block directive, so they do not get copied when selecting multiple lines.