jaraco / jaraco.packaging

MIT License
4 stars 4 forks source link

sphinx: pep517.meta breaks building docs offline (tries to install setup_requires locally?) #7

Closed mgorny closed 1 year ago

mgorny commented 2 years ago

E.g. when trying to build docs for rst.linker:

$ python -m sphinx . out
Running Sphinx v4.4.0
loading pickled environment... done
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f307115d600>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f307115d930>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f307115dbd0>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f307115dd80>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f307115df30>: Failed to establish a new connection: [Errno -2] Name or service not known')': /simple/setuptools/
ERROR: Could not find a version that satisfies the requirement setuptools>=42 (from versions: none)
ERROR: No matching distribution found for setuptools>=42

Extension error (jaraco.packaging.sphinx):
Handler <function load_config_from_setup at 0x7f1c9e576560> for event 'builder-inited' threw an exception (exception: Command '['/tmp/rst.linker/.venv/bin/python', '-m', 'pip', 'install', '--ignore-installed', '--prefix', '/tmp/pep517-build-env-pv491ltb', 'setuptools>=42', 'wheel', 'setuptools_scm[toml]>=3.4.1']' returned non-zero exit status 1.)

…while (obviously) the venv has setuptools installed. If I'm guessing correctly, pep517.meta.load() is making a local venv and installing pyproject.toml requirements there. It feels like a bit of an overkill to build docs, and I don't see any easy way to make it work without direct Internet access.

mgorny commented 2 years ago

Ping.

papoteur-mga commented 2 years ago

Hello, Same problem here when packaging jaraco.text and jaraco.collections for Mageia and others.

Handler <function load_config_from_setup at 0x7f3c8d4de290> for event 'builder-inited' threw an exception (exception: Command '['/usr/bin/python3', '-m', 'pip', 'install', '--ignore-installed', '--prefix', '/tmp/pep517-build-env-ns9z2zgw', 'setuptools>=56', 'setuptools_scm[toml]>=3.4.1']' returned non-zero exit status 1.)
jaraco commented 1 year ago

The latest version switches from using pep517 to build, although I don't expect this situation to be any better. In order to load metadata from an unbuilt package, it's necessary to at least nominally build that package or at least build its metadata.

It feels like a bit of an overkill to build docs, and I don't see any easy way to make it work without direct Internet access.

That's right. It's not even just to build docs, it's to load metadata for a package. This approach is the best practice as recommended by Python packaging designs. I don't know a better way to load metadata for an unbuilt (or potentially unbuilt) source tree reliably. I suggest to bring it up with pypa/packaging-problems.

If there's something this project can do not to require installing a project's build dependencies in order to build its metadata, I'd like to honor that, but I'm aware of no way to do that.

mgorny commented 1 year ago

isolated=False sounds about the right solution to me.

bnavigator commented 1 year ago

Since the main motivation for this feature request/regression report is building the documentation package for Linux distributions, how about the possibility to provide an already built wheel to the metadata extraction? If the distribution packager has already built that one offline it should be possible to reuse it.