diff --git a/gen/python/pyproject.toml b/gen/python/pyproject.toml new file mode 100644 index 000000000..5ceba9ee0 --- /dev/null +++ b/gen/python/pyproject.toml @@ -0,0 +1,24 @@ +# ----------------------------------------------------------------------------- +# This file was autogenerated by symforce from template: +# pyproject.toml.jinja +# Do NOT modify by hand. +# ----------------------------------------------------------------------------- + + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "symforce-sym" +description = "generated numerical python package (installed by SymForce)" +authors = [{ name = "Skydio, Inc.", email = "hayk@skydio.com" }] +license = { text = "Apache 2.0" } +version = "0.9.0" +dependencies = ["numpy"] +requires-python = ">=2.7" + +[project.urls] +SymForce = "https://symforce.org" +"Bug Tracker" = "https://github.com/symforce-org/symforce/issues" +Source = "https://github.com/symforce-org/symforce/tree/main/gen/python" diff --git a/gen/python/setup.py b/gen/python/setup.py deleted file mode 100644 index 9fc00ed59..000000000 --- a/gen/python/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -# ----------------------------------------------------------------------------- -# This file was autogenerated by symforce from template: -# setup.py.jinja -# Do NOT modify by hand. -# ----------------------------------------------------------------------------- - -from setuptools import find_packages -from setuptools import setup - -setup( - name="symforce-sym", - version="0.9.0", - description="generated numerical python package (installed by SymForce)", - license_file="LICENSE", - long_description="generated numerical python package (installed by SymForce)", - author="Skydio, Inc", - author_email="hayk@skydio.com", - install_requires=["numpy"], - license="Apache 2.0", - packages=find_packages(), - python_requires=">=2.7", - project_urls={ - "Bug Tracker": "https://github.com/symforce-org/symforce/issues", - "Source": "https://github.com/symforce-org/symforce/tree/main/gen/python", - }, - url="https://github.com/symforce-org/symforce", - zip_safe=False, -) diff --git a/gen/python/sym/py.typed b/gen/python/sym/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/setup.py b/setup.py index 6fd9f8bb8..5523fbd55 100644 --- a/setup.py +++ b/setup.py @@ -417,7 +417,7 @@ def fixed_readme() -> str: "symengine": "third_party/symenginepy/symengine", "lcmtypes": "lcmtypes_build/lcmtypes", }, - package_data={"": ["*.jinja", "*.mtx", "README*", ".clang-format"]}, + package_data={"": ["*.jinja", "*.mtx", "README*", ".clang-format", "py.typed"]}, # pyproject.toml doesn't allow specifying url or homepage separately, and if it's not # specified separately PyPI sorts all the links alphabetically # https://github.com/pypi/warehouse/issues/3097 diff --git a/symforce/codegen/backends/python/templates/pyproject.toml.jinja b/symforce/codegen/backends/python/templates/pyproject.toml.jinja new file mode 100644 index 000000000..e5acf6d25 --- /dev/null +++ b/symforce/codegen/backends/python/templates/pyproject.toml.jinja @@ -0,0 +1,22 @@ +{# ---------------------------------------------------------------------------- + # SymForce - Copyright 2022, Skydio, Inc. + # This source code is under the Apache 2.0 license found in the LICENSE file. + # ---------------------------------------------------------------------------- #} + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "{{ package_name }}" +description = "{{ description }} (installed by SymForce)" +authors = [{ name = "Skydio, Inc.", email = "hayk@skydio.com" }] +license = { text = "Apache 2.0" } +version = "{{ version }}" +dependencies = ["numpy"] +requires-python = ">=2.7" + +[project.urls] +SymForce = "https://symforce.org" +"Bug Tracker" = "https://github.com/symforce-org/symforce/issues" +Source = "https://github.com/symforce-org/symforce/tree/main/gen/python" diff --git a/symforce/codegen/backends/python/templates/setup.py.jinja b/symforce/codegen/backends/python/templates/setup.py.jinja deleted file mode 100644 index 13ec90dc4..000000000 --- a/symforce/codegen/backends/python/templates/setup.py.jinja +++ /dev/null @@ -1,26 +0,0 @@ -{# ---------------------------------------------------------------------------- - # SymForce - Copyright 2022, Skydio, Inc. - # This source code is under the Apache 2.0 license found in the LICENSE file. - # ---------------------------------------------------------------------------- #} -from setuptools import find_packages -from setuptools import setup - -setup( - name='{{ package_name }}', - version='{{ version }}', - description='{{ description }} (installed by SymForce)', - license_file="LICENSE", - long_description='{{ description }} (installed by SymForce)', - author='Skydio, Inc', - author_email='hayk@skydio.com', - install_requires=["numpy"], - license='Apache 2.0', - packages=find_packages(), - python_requires=">=2.7", - project_urls={ - "Bug Tracker": "https://github.com/symforce-org/symforce/issues", - "Source": "https://github.com/symforce-org/symforce/tree/main/gen/python", - }, - url="https://github.com/symforce-org/symforce", - zip_safe=False, -) diff --git a/symforce/codegen/template_util.py b/symforce/codegen/template_util.py index bc54fe023..792c06f4f 100644 --- a/symforce/codegen/template_util.py +++ b/symforce/codegen/template_util.py @@ -33,6 +33,7 @@ class FileType(enum.Enum): LCM = enum.auto() MAKEFILE = enum.auto() TYPESCRIPT = enum.auto() + TOML = enum.auto() @staticmethod def from_extension(extension: str) -> FileType: @@ -50,6 +51,8 @@ def from_extension(extension: str) -> FileType: return FileType.MAKEFILE elif extension == "ts": return FileType.TYPESCRIPT + elif extension == "toml": + return FileType.TOML else: raise ValueError(f"Could not get FileType from extension {extension}") @@ -68,7 +71,7 @@ def comment_prefix(self) -> str: """ if self in (FileType.CPP, FileType.CUDA, FileType.LCM): return "//" - elif self in (FileType.PYTHON, FileType.PYTHON_INTERFACE): + elif self in (FileType.PYTHON, FileType.PYTHON_INTERFACE, FileType.TOML): return "#" else: raise NotImplementedError(f"Unknown comment prefix for {self}") diff --git a/symforce/py.typed b/symforce/py.typed new file mode 100644 index 000000000..e69de29bb diff --git a/test/symforce_gen_codegen_test.py b/test/symforce_gen_codegen_test.py index ceadb2d96..26ad83f39 100644 --- a/test/symforce_gen_codegen_test.py +++ b/test/symforce_gen_codegen_test.py @@ -4,6 +4,7 @@ # ---------------------------------------------------------------------------- import asyncio +import dataclasses import math import sys from pathlib import Path @@ -93,24 +94,26 @@ def test_gen_package_codegen_python(self) -> None: cam_package_codegen.generate(config=config, output_dir=output_dir) template_util.render_template( template_dir=config.template_dir(), - template_path="setup.py.jinja", - output_path=output_dir / "setup.py", + template_path="pyproject.toml.jinja", + output_path=output_dir / "pyproject.toml", data=dict( package_name="symforce-sym", version=symforce.__version__, description="generated numerical python package", - long_description="generated numerical python package", ), - config=config.render_template_config, + config=dataclasses.replace(config.render_template_config, autoformat=False), ) + (output_dir / "sym" / "py.typed").touch() + # Test against checked-in geo package (only on SymEngine) if symforce.get_symbolic_api() == "symengine": self.compare_or_update_directory( actual_dir=output_dir / "sym", expected_dir=SYMFORCE_DIR / "gen" / "python" / "sym" ) self.compare_or_update_file( - new_file=output_dir / "setup.py", path=SYMFORCE_DIR / "gen" / "python" / "setup.py" + new_file=output_dir / "pyproject.toml", + path=SYMFORCE_DIR / "gen" / "python" / "pyproject.toml", ) # Compare against the checked-in tests diff --git a/third_party/skymarshal/pyproject.toml b/third_party/skymarshal/pyproject.toml new file mode 100644 index 000000000..725ea1215 --- /dev/null +++ b/third_party/skymarshal/pyproject.toml @@ -0,0 +1,29 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "skymarshal" +description = "Python implementation of marshalling for LCM messages" +version = "0.9.0" +authors = [{ name = "Skydio, Inc." }] +license = { text = "LGPL-2.1-or-later" } +readme = "README.md" +classifiers = [ + "Intended Audience :: Developers", + "Development Status :: 4 - Beta", + "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Code Generators", + "Topic :: Software Development :: Libraries :: Python Modules", + "Operating System :: OS Independent", +] +requires-python = ">=3.8" +dependencies = ["argh", "jinja2", "numpy", "ply"] + +[project.urls] +"Bug Tracker" = "https://github.com/symforce-org/symforce/issues" +Source = "https://github.com/symforce-org/symforce/tree/main/third_party/skymarshal" + +[tool.setuptools.packages.find] +include = ["skymarshal", "skymarshal.*"] diff --git a/third_party/skymarshal/setup.cfg b/third_party/skymarshal/setup.cfg deleted file mode 100644 index 6ac953f74..000000000 --- a/third_party/skymarshal/setup.cfg +++ /dev/null @@ -1,35 +0,0 @@ -[metadata] -name = skymarshal -description = Python implementation of marshalling for LCM messages -long_description = file: README.md -long_description_content_type = text/markdown -author = "Skydio, Inc" -classifiers = - Intended Audience :: Developers - Development Status :: 4 - Beta - License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) - Programming Language :: Python :: 3 - Topic :: Software Development :: Code Generators - Topic :: Software Development :: Libraries :: Python Modules - Operating System :: OS Independent -license = LGPL-2.1-or-later -license_file = LICENSE -url = https://github.com/symforce-org/symforce/tree/main/third_party/skymarshal -project_urls = - Bug Tracker = https://github.com/symforce-org/symforce/issues - Source = https://github.com/symforce-org/symforce/tree/main/third_party/skymarshal - -[options] -packages = find_namespace: -python_requires = >= 3.8 -include_package_data = True -install_requires = - argh - jinja2 - numpy - ply - -[options.packages.find] -include = - skymarshal - skymarshal.* diff --git a/third_party/skymarshal/setup.py b/third_party/skymarshal/setup.py deleted file mode 100644 index 8617f910f..000000000 --- a/third_party/skymarshal/setup.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env python - -import setuptools - -if __name__ == "__main__": - setuptools.setup( - version="0.9.0", - ) diff --git a/third_party/skymarshal/skymarshal/py.typed b/third_party/skymarshal/skymarshal/py.typed new file mode 100644 index 000000000..e69de29bb