AIM-Harvard / pyradiomics

Open-source python package for the extraction of Radiomics features from 2D and 3D images and binary masks. Support: https://discourse.slicer.org/c/community/radiomics
http://pyradiomics.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.11k stars 485 forks source link

Add PEP-517 compliant build requirement specification #807

Closed ReeceStevens closed 1 year ago

ReeceStevens commented 1 year ago

cc: @Radiomics/developers

Hello pyradiomics team! Thanks for the great open source software you are building here.

I am working on a project using pyradiomics that is transitioning to using poetry for dependency management. During the migration, I ran into issues installing pyradiomics due to the build-time dependency of numpy not being present. After doing some research, I realized this is because poetry expects a PEP-517 style build dependency specification, which is basically just a stub pyproject.toml file with the build-time requirements specified.

It looks like this new format for build-time dependencies is now the standard in the Python ecosystem, and setuptools (the packaging solution used in this project) also recommends the use of the toml file approach now (see https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#build-system-requirement). This is in contrast to the current use of the setup_requirements kwarg in setup.py.

I have confirmed that with the addition of this stub pyproject.toml file, installation with poetry works as expected. Since this is now an accepted PEP and tools are moving towards expectation of this format, I wanted to propose the addition of this file to enable using pyradiomics in poetry-based python projects. This should have no other side effects in the build system and require no changes to any existing build tools.

In addition to merging this in to master, I am hoping it would be possible to cut a v3.0.2 patch release that will add support for PEP-517 builds to the version of pyradiomics available on pypi.

I'm happy to answer any questions you have and discuss further! Thanks!

ReeceStevens commented 1 year ago

cc: @Radiomics/developers

fedorov commented 1 year ago

@ReeceStevens thank you for your contribution and detailed explanation! @JoostJM is maintaining the repository, and I think it would be best to wait for him to respond. I see CI tests are failing, but they have also been failing for the latest commit, so this is probably not because of a problem with your PR. If we don't hear back from Joost after the holidays, I can merge your PR.

pchlap commented 1 year ago

Hi @fedorov, @ReeceStevens,

just curious what the status of this PR is?

In addition to merging this in to master, I am hoping it would be possible to cut a v3.0.2 patch release that will add support for PEP-517 builds to the version of pyradiomics available on pypi.

Having this merge along with a patch release would really help us with our build pipelines for a tool we are developing (https://github.com/AustralianCancerDataNetwork/pydicer). Curious to hear what the next steps are to have this resolved. Thanks!

fedorov commented 1 year ago

@pchlap I will defer to @hugoaerts who is the director of the lab behind this software package.

JoostJM commented 1 year ago

Sorry for the late reply. I have been struggling with updating the entire CI pipeline in my spare time, to get PyRadiomics up-to-date again. This is nearly done, and I'm about to make the new release, which already includes (a more extensive) pyproject.toml. Therefore I'm closing this PR.

abdrysdale commented 3 weeks ago

Has this been solved, I'm still getting the same error - also using poetry.

  - Installing pyradiomics (3.1.0)

  ChefBuildError

  Backend subprocess exited when trying to invoke build_wheel

  C:\Users\USER\AppData\Local\Temp\tmp8hvthk42\.venv\Lib\site-packages\setuptools\dist.py:320: InformationOnly: Normalizing 'v3.1.0' to '3.1.0'
    self.metadata.version = self._normalize_version(self.metadata.version)
  C:\Users\USER\AppData\Local\Temp\tmp8hvthk42\.venv\Lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:79: SetuptoolsWarning: `install_requires` overwritten in `pyproject.toml` (dependencies)
    corresp(dist, value, root_dir)
  Failed to load config from C:\Users\USER\AppData\Local\Temp\tmpb8dm6z7s\pyradiomics-3.1.0\pyproject.toml: 'tool'
  Try to load it from setup.cfg
  running bdist_wheel
  running build
  running build_py
  Failed to load config from C:\Users\USER\AppData\Local\Temp\tmpb8dm6z7s\pyradiomics-3.1.0\pyproject.toml: 'tool'
  Try to load it from setup.cfg
  Failed to load config from C:\Users\USER\AppData\Local\Temp\tmpb8dm6z7s\pyradiomics-3.1.0\pyproject.toml: 'tool'
  Try to load it from setup.cfg
  creating build
  creating build\lib.win-amd64-cpython-312
  creating build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\base.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\featureextractor.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\firstorder.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\generalinfo.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\glcm.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\gldm.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\glrlm.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\glszm.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\imageoperations.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\ngtdm.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\shape.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\shape2D.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\_version.py -> build\lib.win-amd64-cpython-312\radiomics
  copying radiomics\__init__.py -> build\lib.win-amd64-cpython-312\radiomics
  creating build\lib.win-amd64-cpython-312\radiomics\scripts
  copying radiomics\scripts\segment.py -> build\lib.win-amd64-cpython-312\radiomics\scripts
  copying radiomics\scripts\voxel.py -> build\lib.win-amd64-cpython-312\radiomics\scripts
  copying radiomics\scripts\__init__.py -> build\lib.win-amd64-cpython-312\radiomics\scripts
  creating build\lib.win-amd64-cpython-312\radiomics\schemas
  copying radiomics\schemas\paramSchema.yaml -> build\lib.win-amd64-cpython-312\radiomics\schemas
  copying radiomics\schemas\schemaFuncs.py -> build\lib.win-amd64-cpython-312\radiomics\schemas
  UPDATING build\lib.win-amd64-cpython-312\radiomics/_version.py
  set build\lib.win-amd64-cpython-312\radiomics/_version.py to 'v3.1.0'
  running build_ext
  Failed to load config from C:\Users\USER\AppData\Local\Temp\tmpb8dm6z7s\pyradiomics-3.1.0\pyproject.toml: 'tool'
  Try to load it from setup.cfg
  Failed to load config from C:\Users\USER\AppData\Local\Temp\tmpb8dm6z7s\pyradiomics-3.1.0\pyproject.toml: 'tool'
  Try to load it from setup.cfg
  building 'radiomics._cmatrices' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

  at ~\scoop\apps\poetry\1.8.3\venv\Lib\site-packages\poetry\installation\chef.py:164 in _prepare
      160| 
      161|                 error = ChefBuildError("\n\n".join(message_parts))
      162| 
      163|             if error is not None:
    > 164|                 raise error from None
      165| 
      166|             return path
      167| 
      168|     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with pyradiomics (3.1.0) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "pyradiomics (==3.1.0)"'.