Skip to content

Commit

Permalink
Prefer pep517.meta to setuptools conventions for loading package meta…
Browse files Browse the repository at this point in the history
…data.
  • Loading branch information
jaraco committed Feb 11, 2022
1 parent 68e3adf commit 278f825
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v8.3.0
======

Use pep517.meta to load package metadata. Adds support
for packages without setup.py.

v8.2.1
======

Expand Down
20 changes: 6 additions & 14 deletions jaraco/packaging/sphinx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
import subprocess
import pep517.meta

try:
import importlib.metadata as imp_meta
Expand All @@ -26,19 +26,11 @@ def load_config_from_setup(app):
"""
# for now, assume project root is one level up
root = os.path.join(app.confdir, '..')
setup_script = os.path.join(root, 'setup.py')
fields = ['--name', '--version', '--url', '--author']
dist_info_cmd = [sys.executable, setup_script] + fields
output = subprocess.check_output(dist_info_cmd, cwd=root, universal_newlines=True)
outputs = output.strip().split('\n')
try:
project, version, url, author = outputs
except ValueError:
raise ValueError("Unexpected metadata output", output)
app.config.project = project
app.config.version = app.config.release = version
app.config.package_url = url
app.config.author = app.config.copyright = author
meta = pep517.meta.load(root).metadata
app.config.project = meta['Name']
app.config.version = app.config.release = meta['Version']
app.config.package_url = meta['Home-page']
app.config.author = app.config.copyright = meta['Author']


def configure_substitutions(app):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ python_requires = >=3.6
install_requires =
setuptools
importlib_metadata; python_version < "3.8"
pep517
setup_requires = setuptools_scm[toml] >= 3.4.1

[options.packages.find]
Expand Down

0 comments on commit 278f825

Please sign in to comment.