build icon indicating copy to clipboard operation
build copied to clipboard

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist

Open rvernica opened this issue 2 years ago • 2 comments

The build module fails for sdist or wheel. This is an existing project and this build step used to work properly.

> python3 -m build --sdist
* Creating venv isolated environment...
* Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
* Getting build dependencies for sdist...
Traceback (most recent call last):
  File "/root/.local/lib/python3.6/site-packages/pep517/in_process/_in_process.py", line 351, in <module>
    main()
  File "/root/.local/lib/python3.6/site-packages/pep517/in_process/_in_process.py", line 333, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/root/.local/lib/python3.6/site-packages/pep517/in_process/_in_process.py", line 285, in get_requires_for_build_sdist
    return hook(config_settings)
  File "/tmp/build-env-zul88ngt/lib64/python3.6/site-packages/setuptools/build_meta.py", line 167, in get_requires_for_build_sdist
    return self._get_build_requires(config_settings, requirements=[])
  File "/tmp/build-env-zul88ngt/lib64/python3.6/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
    self.run_setup()
  File "/tmp/build-env-zul88ngt/lib64/python3.6/site-packages/setuptools/build_meta.py", line 268, in run_setup
    self).run_setup(setup_script=setup_script)
  File "/tmp/build-env-zul88ngt/lib64/python3.6/site-packages/setuptools/build_meta.py", line 158, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 31, in <module>
    import scidbbridge
  File "/foo/__init__.py", line 24, in <module>
    import boto3
ModuleNotFoundError: No module named 'boto3'

ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist

boto3 in listed in setup.py:

setup(
    name=NAME,
    version=VERSION,
    description=DESCRIPTION,
    long_description=LONG_DESCRIPTION,
    author=AUTHOR,
    author_email=AUTHOR_EMAIL,
    download_url=DOWNLOAD_URL,
    license=LICENSE,
    packages=['scidbbridge'],
    install_requires=[
        'boto3>=1.14.12',

This is the package source and here is the package on PyPI.

I tired the build on both Python 3.10.8 with build 0.10.0 and Python 3.6.8 with build 0.9.0. The boto3 package is installed on the host system.

rvernica avatar Jan 31 '23 20:01 rvernica

You can't import boto3 inside the isolated environment unless you install it inside the isolated environment (in pyproject.toml). Though do you really need to? Usually, to make the SDist/wheel, you should not need the imports (which are only install requirements). Perhaps you are trying to import your own package inside setup.py? This is an antipattern; setuptools and most other backends provide ways to single-source the version without loading your package during the SDist/wheel build, which I'd guess is what you might be trying to do? Oh, yes, you linked the source, that's exactly why. I'd either use setuptool's setup.cfg version = attr: scridbbridge.__version__ option for version (and hope it can read the AST), or use a backend like hatchling that can read the version via regex.

henryiii avatar Jan 31 '23 20:01 henryiii