Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ tomli

# build and upload
build
setuptools
setuptools >= 77.0.3
twine
wheel

# tests
mypy
Expand Down
73 changes: 42 additions & 31 deletions stub_uploader/build_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,40 @@
"""
from setuptools import setup
setup(package_data={package_data})
"""
)

PYPROJECT_TEMPLATE = dedent(
"""
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=77.0.3"]
[project]
name = "{stub_distribution}"
version = "{version}"
license = "Apache-2.0"
license-files = ["LICENSE"]
description = "Typing stubs for {distribution}"
long_description = '''
{long_description}
'''.lstrip()
setup(name=name,
version="{version}",
description=description,
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/python/typeshed",
project_urls={{
"GitHub": "https://github.com/python/typeshed",
"Changes": "https://github.com/typeshed-internal/stub_uploader/blob/main/data/changelogs/{distribution}.md",
"Issue tracker": "https://github.com/python/typeshed/issues",
"Chat": "https://gitter.im/python/typing",
}},
install_requires={requires},
packages={packages},
package_data={package_data},
license="Apache-2.0",
python_requires="{requires_python}",
classifiers=[
"Programming Language :: Python :: 3",
"Typing :: Stubs Only",
]
)
readme = {{ text = \"\"\"\\\n{long_description}\n\"\"\", content-type = "text/markdown" }}
classifiers = [
"Programming Language :: Python :: 3",
"Typing :: Stubs Only",
]
requires-python = "{requires_python}"
dependencies = {requires}
[project.urls]
"Homepage" = "https://github.com/python/typeshed"
"GitHub" = "https://github.com/python/typeshed"
"Changes" = "https://github.com/typeshed-internal/stub_uploader/blob/main/data/changelogs/{distribution}.md"
"Issue tracker" = "https://github.com/python/typeshed/issues"
"Chat" = "https://gitter.im/python/typing"
[tool.setuptools]
packages = {packages}
include-package-data = false
"""
).lstrip()

Expand Down Expand Up @@ -339,7 +345,12 @@ def is_ignored_distribution_file(entry: Path) -> bool:
return False


def generate_setup_file(
def generate_setup_file(pkg_data: PackageData) -> str:
"""Auto-generate a setup.py file for given distribution using a template."""
return SETUP_TEMPLATE.format(package_data=pkg_data.package_data)


def generate_pyproject_file(
ts_data: TypeshedData,
build_data: BuildData,
pkg_data: PackageData,
Expand All @@ -355,7 +366,7 @@ def generate_setup_file(
if metadata.requires_python is not None
else f">={ts_data.oldest_supported_python}"
)
return SETUP_TEMPLATE.format(
return PYPROJECT_TEMPLATE.format(
distribution=build_data.distribution,
stub_distribution=metadata.stub_distribution,
long_description=generate_long_description(
Expand All @@ -364,7 +375,6 @@ def generate_setup_file(
version=version,
requires=all_requirements,
packages=pkg_data.top_level_packages,
package_data=pkg_data.package_data,
requires_python=requires_python,
)

Expand Down Expand Up @@ -440,8 +450,9 @@ def main(
else:
tmpdir = Path(tempfile.mkdtemp())

(tmpdir / "setup.py").write_text(
generate_setup_file(ts_data, build_data, pkg_data, metadata, version)
(tmpdir / "setup.py").write_text(generate_setup_file(pkg_data))
(tmpdir / "pyproject.toml").write_text(
generate_pyproject_file(ts_data, build_data, pkg_data, metadata, version)
)
copy_stubs(build_data.stub_dir, tmpdir)
create_py_typed(metadata, pkg_data, tmpdir)
Expand Down