The issue I have is, that the CMakeLists.txt is in the src/ directory while the setup.py it at the root.
During the build step I either get the error message that buildPythonPackage can not find the CMakeLists.txt or if I change the directory in the preConfigure step, but then it can not see the setup.py file.
Is there some way I can let the buildPythonPackage pipeline know that it should expect the CMakeLists.txt at a different location? I tried setting some cmake flags. But that hasn’t worked either so far.
# This is from an override section hence the super ...
rhino3dm = super.python.pkgs.buildPythonPackage {
pname = "rhino3dm";
version = "8.9.0";
src = super.python.pkgs.fetchPypi {
# inherit pname version format;
pname = "rhino3dm";
version = "8.9.0";
sha256 = "sha256-sB4J26Va/QDX89w9UlR9PFETBKpH/M+yoElUJ+rU/7I=";
# sha256 = lib.fakeSha256;
};
nativeBuildInputs = with super; [
setuptools
cmake
];
cmakeFlags = [
# "-DROOT_PATH=src/"
];
# preConfigure = ''
# cp src/CMakeLists.txt CMakeLists.txt
# '';
doCheck = false;
};
... More configuration
You could try setting the root directory option, or symlinking one file to the other place.
Another solution would be to declare root dir, and then in prebuild phase create a new directory, copy/mv all files into the new directory to prepare the env for the build and configure phase
I’m not sure what you mean by setting the root directory.
If it’s with a cmake variable then -DROOT_PATH=src/ did not work.
If it’s as an option ( sourceRoot) inside buildPythonPackage then that too does not work.
If I move/symlink the CMakeLists file then the paths to its submodules are incorrect and it can’t import them.
and setting.
preConfigure = ''
ln -s setup.py src/setup.py
cd src
'';
results in:
error: builder for '/nix/store/pyb5h1n21wiwnrqwpx7ck1mqab032bdq-python3.12-rhino3dm-8.9.0.drv' failed with exit code 1;
last 25 log lines:
> --- Running combined CXX flags test, flags: -Wno-deprecated-declarations
> --- Passed combined CXX flags test
> -- Configuring done (1.7s)
> -- Generating done (0.1s)
> CMake Warning:
> Manually-specified variables were not used by the project:
>
> BUILD_TESTING
> CMAKE_EXPORT_NO_PACKAGE_REGISTRY
> CMAKE_POLICY_DEFAULT_CMP0025
>
>
> -- Build files have been written to: /build/rhino3dm-8.9.0/src/build
> cmake: enabled parallel building
> cmake: enabled parallel installing
> Running phase: buildPhase
> Executing setuptoolsBuildPhase
> Traceback (most recent call last):
> File "/build/rhino3dm-8.9.0/src/build/nix_run_setup", line 8, in <module>
> exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> File "/nix/store/c9m6yd8fg1flz2j5r4bif1ib5j20a0cy-python3-3.12.8/lib/python3.12/tokenize.py", line 449, in open
> buffer = _builtin_open(filename, 'rb')
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> FileNotFoundError: [Errno 2] No such file or directory: 'setup.py'
For full logs, run 'nix-store -l /nix/store/pyb5h1n21wiwnrqwpx7ck1mqab032bdq-python3.12-rhino3dm-8.9.0.drv'.
error: 1 dependencies of derivation '/nix/store/d7i3pyyhgy3mrnzvq3qlmxsdhsdiw35r-python3.12-ReUseX-0.0.1.drv' failed to build
However, their github repos suggest that I should not need to change the directory.
Compile
(All platforms) run python setup.py bdist in the root directory to compile and configure. The library will compile for the version of python that you are executing.
For reference, for any one else stumbling over a similar issue.
What figured out was that I could move in to the src directory in the preConfigure step and then move back down to the root directory as well as move the build folder to the correct location in the postConfigure step like so:
buildPythonPackage rec {
preConfigure = ''
echo changing in to src directory
cd src
'';
postConfigure = ''
cd ..
echo "moving $cmakeBuildDir one level up (should be the project root)"
mv $cmakeBuildDir ../
echo changing current directory back to root.
cd ..
'';
# The rest of the config
};