diff --git a/conjure-python-core/src/main/java/com/palantir/conjure/python/ConjurePythonGenerator.java b/conjure-python-core/src/main/java/com/palantir/conjure/python/ConjurePythonGenerator.java index 6bbdce5d9..38b94cc37 100644 --- a/conjure-python-core/src/main/java/com/palantir/conjure/python/ConjurePythonGenerator.java +++ b/conjure-python-core/src/main/java/com/palantir/conjure/python/ConjurePythonGenerator.java @@ -164,6 +164,7 @@ private PythonFile getImplPythonFile( .pythonPackage(rootPackage) .fileName(IMPL_PY) .contents(pythonSnippets) + .generatorVersion(config.generatorVersion()) .build()) .values() .collect(Collectors.toList()); @@ -214,6 +215,7 @@ private List getInitFiles( .pythonPackage(pythonPackage) .fileName(INIT_PY) .contents(pythonSnippets) + .generatorVersion(config.generatorVersion()) .build()) .values() .collect(Collectors.toList()); @@ -224,6 +226,7 @@ private PythonFile getRootInit(Set packageNames, PythonPackage ro PythonFile.Builder builder = PythonFile.builder() .pythonPackage(PythonPackage.of(config.pythonicPackageName().orElse("."))) .fileName(INIT_PY) + .generatorVersion(config.generatorVersion()) .addContents(AllSnippet.builder() .pythonPackage(rootPackage) .contents(packageNames.stream() @@ -266,6 +269,7 @@ private PythonFile buildPythonSetupFile(PythonPackage rootPackage) { .pythonPackage(PythonPackage.of(".")) .fileName("setup.py") .addContents(builder.build()) + .generatorVersion(config.generatorVersion()) .build(); } @@ -276,6 +280,7 @@ private PythonFile buildPyTypedFile() { return PythonFile.builder() .pythonPackage(PythonPackage.of(config.pythonicPackageName().get())) .fileName("py.typed") + .generatorVersion(config.generatorVersion()) .build(); } @@ -292,6 +297,7 @@ private PythonFile buildCondaMetaYamlFile(PythonPackage rootPackage) { "conjure-python-client >=%s,<%s", config.minConjureClientVersion(), config.maxConjureClientVersion())) .build()) + .generatorVersion(config.generatorVersion()) .build(); } diff --git a/conjure-python-core/src/main/java/com/palantir/conjure/python/poet/PythonFile.java b/conjure-python-core/src/main/java/com/palantir/conjure/python/poet/PythonFile.java index 0b3cc89a4..1c2867243 100644 --- a/conjure-python-core/src/main/java/com/palantir/conjure/python/poet/PythonFile.java +++ b/conjure-python-core/src/main/java/com/palantir/conjure/python/poet/PythonFile.java @@ -34,9 +34,15 @@ public interface PythonFile extends Emittable { List contents(); + String generatorVersion(); + @Override default void emit(PythonPoetWriter poetWriter) { poetWriter.writeLine("# coding=utf-8"); + poetWriter.writeIndentedLine("# This file has been generated by conjure-python version %s", generatorVersion()); + poetWriter.writeIndentedLine("# https://github.com/palantir/conjure-python"); + poetWriter.writeLine(); + poetWriter.maintainingIndent(() -> { Map> imports = contents().stream() .flatMap(pythonSnippet -> pythonSnippet.imports().stream()) diff --git a/conjure-python-core/src/test/resources/services/expected/conda_recipe/meta.yaml b/conjure-python-core/src/test/resources/services/expected/conda_recipe/meta.yaml index 253fc76be..8a01f3bf4 100644 --- a/conjure-python-core/src/test/resources/services/expected/conda_recipe/meta.yaml +++ b/conjure-python-core/src/test/resources/services/expected/conda_recipe/meta.yaml @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + package: name: package-name version: 0.0.0 diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/__init__.py b/conjure-python-core/src/test/resources/services/expected/package_name/__init__.py index 12abd7683..3a1f2cc61 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/__init__.py +++ b/conjure-python-core/src/test/resources/services/expected/package_name/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + __all__ = [ 'another', 'package_name', diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/_impl.py b/conjure-python-core/src/test/resources/services/expected/package_name/_impl.py index ab406a88a..53eb8643a 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/_impl.py +++ b/conjure-python-core/src/test/resources/services/expected/package_name/_impl.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + import builtins from conjure_python_client import ( BinaryType, diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/another/__init__.py b/conjure-python-core/src/test/resources/services/expected/package_name/another/__init__.py index 920db9460..6364f8487 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/another/__init__.py +++ b/conjure-python-core/src/test/resources/services/expected/package_name/another/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( another_TestService as TestService, ) diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/package_name/__init__.py b/conjure-python-core/src/test/resources/services/expected/package_name/package_name/__init__.py index 06be51fbb..965f6b0e5 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/package_name/__init__.py +++ b/conjure-python-core/src/test/resources/services/expected/package_name/package_name/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( package_name_TypeInPackageWithTheSameNameAsRootPackage as TypeInPackageWithTheSameNameAsRootPackage, ) diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/product/__init__.py b/conjure-python-core/src/test/resources/services/expected/package_name/product/__init__.py index 367d9bf1a..17e824133 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/product/__init__.py +++ b/conjure-python-core/src/test/resources/services/expected/package_name/product/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( product_CreateDatasetRequest as CreateDatasetRequest, ) diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/product_datasets/__init__.py b/conjure-python-core/src/test/resources/services/expected/package_name/product_datasets/__init__.py index 766bae880..73f00ac18 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/product_datasets/__init__.py +++ b/conjure-python-core/src/test/resources/services/expected/package_name/product_datasets/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( product_datasets_BackingFileSystem as BackingFileSystem, product_datasets_Dataset as Dataset, diff --git a/conjure-python-core/src/test/resources/services/expected/package_name/py.typed b/conjure-python-core/src/test/resources/services/expected/package_name/py.typed index 9bad5790a..5fe5c71e9 100644 --- a/conjure-python-core/src/test/resources/services/expected/package_name/py.typed +++ b/conjure-python-core/src/test/resources/services/expected/package_name/py.typed @@ -1 +1,4 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + diff --git a/conjure-python-core/src/test/resources/services/expected/setup.py b/conjure-python-core/src/test/resources/services/expected/setup.py index 90f0f5f52..e7ff3471c 100644 --- a/conjure-python-core/src/test/resources/services/expected/setup.py +++ b/conjure-python-core/src/test/resources/services/expected/setup.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from setuptools import ( find_packages, setup, diff --git a/conjure-python-core/src/test/resources/types/expected/conda_recipe/meta.yaml b/conjure-python-core/src/test/resources/types/expected/conda_recipe/meta.yaml index 253fc76be..8a01f3bf4 100644 --- a/conjure-python-core/src/test/resources/types/expected/conda_recipe/meta.yaml +++ b/conjure-python-core/src/test/resources/types/expected/conda_recipe/meta.yaml @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + package: name: package-name version: 0.0.0 diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/__init__.py index 84425f7d5..f2e6a3f7e 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + __all__ = [ 'another', 'nested_deeply_nested_service', diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/_impl.py b/conjure-python-core/src/test/resources/types/expected/package_name/_impl.py index bec68ef4d..cd802e226 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/_impl.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/_impl.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from abc import ( abstractmethod, ) diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/another/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/another/__init__.py index 920db9460..6364f8487 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/another/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/another/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( another_TestService as TestService, ) diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/nested_deeply_nested_service/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/nested_deeply_nested_service/__init__.py index 65c4e376c..02a58f4c3 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/nested_deeply_nested_service/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/nested_deeply_nested_service/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( nested_deeply_nested_service_DeeplyNestedService as DeeplyNestedService, ) diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/nested_service/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/nested_service/__init__.py index 3e0053e01..ab7881f00 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/nested_service/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/nested_service/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( nested_service_SimpleNestedService as SimpleNestedService, nested_service_SimpleObject as SimpleObject, diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/nested_service2/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/nested_service2/__init__.py index 3c42949ee..ca9792530 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/nested_service2/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/nested_service2/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( nested_service2_SimpleNestedService2 as SimpleNestedService2, ) diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/package_name/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/package_name/__init__.py index 06be51fbb..965f6b0e5 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/package_name/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/package_name/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( package_name_TypeInPackageWithTheSameNameAsRootPackage as TypeInPackageWithTheSameNameAsRootPackage, ) diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/product/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/product/__init__.py index d92acf564..d57f37e5b 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/product/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/product/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( product_AliasAsMapKeyExample as AliasAsMapKeyExample, product_AnyExample as AnyExample, diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/product_datasets/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/product_datasets/__init__.py index 766bae880..73f00ac18 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/product_datasets/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/product_datasets/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( product_datasets_BackingFileSystem as BackingFileSystem, product_datasets_Dataset as Dataset, diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/py.typed b/conjure-python-core/src/test/resources/types/expected/package_name/py.typed index 9bad5790a..5fe5c71e9 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/py.typed +++ b/conjure-python-core/src/test/resources/types/expected/package_name/py.typed @@ -1 +1,4 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + diff --git a/conjure-python-core/src/test/resources/types/expected/package_name/with_imports/__init__.py b/conjure-python-core/src/test/resources/types/expected/package_name/with_imports/__init__.py index 9893c46e5..3f2039aed 100644 --- a/conjure-python-core/src/test/resources/types/expected/package_name/with_imports/__init__.py +++ b/conjure-python-core/src/test/resources/types/expected/package_name/with_imports/__init__.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from .._impl import ( with_imports_AliasImportedObject as AliasImportedObject, with_imports_AliasImportedPrimitiveAlias as AliasImportedPrimitiveAlias, diff --git a/conjure-python-core/src/test/resources/types/expected/setup.py b/conjure-python-core/src/test/resources/types/expected/setup.py index 90f0f5f52..e7ff3471c 100644 --- a/conjure-python-core/src/test/resources/types/expected/setup.py +++ b/conjure-python-core/src/test/resources/types/expected/setup.py @@ -1,4 +1,7 @@ # coding=utf-8 +# This file has been generated by conjure-python version 0.0.0 +# https://github.com/palantir/conjure-python + from setuptools import ( find_packages, setup,