Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PEP-517 compliant build requirement specification #807

Closed
wants to merge 1 commit into from

Conversation

ReeceStevens
Copy link

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!

PEP 517 [1] provides a new standard format for specifying build-time
dependencies for Python packages. This format supercedes previous
formats, such as the `setup_requirements` argument in setuptools[2].

In order for this package to be installable by systems that expect PEP
517-compliant formatting, such as Poetry, a minimal pyproject.toml file
must be added specifying the build-time requirements. This file does not
trigger any other changes to the build system or require the adoption of
any new tools; recent versions of setuptools support referencing the
pyproject.toml `build-system` header information.

[1]: https://peps.python.org/pep-0517/
[2]: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#build-system-requirement
@ReeceStevens
Copy link
Author

cc: @Radiomics/developers

@fedorov
Copy link
Collaborator

fedorov commented Dec 29, 2022

@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
Copy link

pchlap commented Mar 7, 2023

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
Copy link
Collaborator

fedorov commented Mar 7, 2023

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

@JoostJM
Copy link
Collaborator

JoostJM commented May 17, 2023

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
Copy link

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)"'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants