Skip to content

Commit 141e475

Browse files
committed
Re-organize and tidy up codegen packages
1 parent 4a10737 commit 141e475

File tree

98 files changed

+2540
-2550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2540
-2550
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ jobs:
7878
architecture: x64
7979

8080
- name: clean and build without python
81-
run: cd codegen && ./gradlew clean build -Plog-tests
81+
run: cd codegen && ./gradlew clean build
8282

8383
- name: Set Up Python for CI - ${{ matrix.python-version }}
8484
uses: actions/setup-python@v5
@@ -98,18 +98,18 @@ jobs:
9898
make install-python-components
9999
100100
- name: clean and build without formatting/linting installed
101-
run: cd codegen && ./gradlew clean build -Plog-tests
101+
run: cd codegen && ./gradlew clean build
102102

103103
- name: Install black
104104
run: |
105105
python${{ matrix.python-version }} -m pip install --upgrade black
106106
107107
- name: clean and build without linting installed
108-
run: cd codegen && ./gradlew clean build -Plog-tests
108+
run: cd codegen && ./gradlew clean build
109109

110110
- name: Install mypy and other libraries necessary for typing
111111
run: |
112112
python${{ matrix.python-version }} -m pip install --upgrade mypy pytest pytest-asyncio
113113
114114
- name: clean and build with all optional tools installed
115-
run: cd codegen && ./gradlew clean build -Plog-tests
115+
run: cd codegen && ./gradlew clean build

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ target/
1919
**/dependency-reduced-pom.xml
2020

2121
# Gradle
22-
/.gradle
22+
**/.gradle
2323
build/
2424
*/out/
25-
*/*/out/
25+
**/*/out/
2626

2727
# Python
2828
__pycache__

Makefile

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,46 @@
1-
help: ## Show this help.
2-
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
1+
.DEFAULT_GOAL:=help
32

3+
help: ## Show this help.
4+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-25s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
45

5-
## Installs pants launcher binary using the get-pants script.
6-
## If $CI is true, assume it's installed already (through GHA), so just copy the wrapper script.
7-
pants:
6+
pants: ## Installs pants launcher binary using the get-pants script. If $CI is true, assume it's installed already (through GHA), so just copy the wrapper script.
87
ifeq ($(CI),true)
98
cp scripts/pantsw pants
109
else
1110
./get-pants --bin-dir .
1211
endif
1312

1413

15-
## Packages and installs the python packages.
16-
install-python-components: pants
14+
install-python-components: pants ## Packages and installs the python packages.
1715
./pants package ::
1816
python3 -m pip install dist/*.whl --force-reinstall
1917

2018

21-
## Publishes java packages to maven local.
22-
install-java-components:
19+
install-java-components: ## Publishes java packages to maven local.
2320
cd codegen && ./gradlew publishToMavenLocal
2421

2522

26-
## Installs java and python components locally.
27-
install-components: install-python-components install-java-components
23+
install-components: install-python-components install-java-components ## Installs java and python components locally.
2824

2925

30-
## Builds the Java code generation packages.
31-
smithy-build:
26+
smithy-build: ## Builds the Java code generation packages.
3227
cd codegen && ./gradlew clean build
3328

3429

35-
## Generates the protocol tests, rebuilding necessary Java packages.
36-
generate-protocol-tests:
37-
cd codegen && ./gradlew clean :smithy-python-protocol-test:build
30+
generate-protocol-tests: ## Generates the protocol tests, rebuilding necessary Java packages.
31+
cd codegen && ./gradlew :protocol-test:build
3832

3933

40-
## Runs already-generated protocol tests.
41-
run-protocol-tests:
42-
cd codegen/smithy-python-protocol-test/build/smithyprojections/smithy-python-protocol-test/rest-json-1/python-client-codegen && \
34+
run-protocol-tests: ## Runs already-generated protocol tests.
35+
cd codegen/protocol-test/build/smithyprojections/protocol-test/rest-json-1/python-client-codegen && \
4336
python3 -m pip install '.[tests]' && \
4437
python3 -m pytest tests
4538

4639

47-
## Generates and runs protocol tests.
48-
test-protocols: install-python-components generate-protocol-tests run-protocol-tests
40+
test-protocols: install-python-components generate-protocol-tests run-protocol-tests ## Generates and runs protocol tests.
4941

5042

51-
## Runs formatters/fixers/linters for the python packages.
52-
lint-py: pants
43+
lint-py: pants ## Runs formatters/fixers/linters for the python packages.
5344
./pants fix lint python-packages/smithy-core::
5445
./pants fix lint python-packages/smithy-http::
5546
./pants fix lint python-packages/smithy-aws-core::
@@ -58,8 +49,7 @@ lint-py: pants
5849
./pants fix lint python-packages/aws-event-stream::
5950

6051

61-
## Runs checkers for the python packages.
62-
check-py: pants
52+
check-py: pants ## Runs checkers for the python packages.
6353
./pants check python-packages/smithy-core::
6454
./pants check python-packages/smithy-http::
6555
./pants check python-packages/smithy-aws-core::
@@ -68,8 +58,7 @@ check-py: pants
6858
./pants check python-packages/aws-event-stream::
6959

7060

71-
## Runs tests for the python packages.
72-
test-py: pants
61+
test-py: pants ## Runs tests for the python packages.
7362
./pants test python-packages/smithy-core::
7463
./pants test python-packages/smithy-http::
7564
./pants test python-packages/smithy-aws-core::
@@ -78,11 +67,9 @@ test-py: pants
7867
./pants test python-packages/aws-event-stream::
7968

8069

81-
## Runs formatters/fixers/linters/checkers/tests for the python packages.
82-
build-py: lint-py check-py test-py
70+
build-py: lint-py check-py test-py ## Runs formatters/fixers/linters/checkers/tests for the python packages.
8371

8472

85-
## Clean up generated code, artifacts, and remove pants.
86-
clean:
87-
rm -rf pants dist/
73+
clean: ## Clean up generated code and artifacts.
74+
rm -rf dist/
8875
cd codegen && ./gradlew clean

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ With both files your project directory should look like this:
110110
```
111111

112112

113-
The code generator, `smithy-python-codegen`, hasn't been published yet, so
114-
you'll need to build it yourself. To build and run the generator you will need
113+
The code generator libraries have not been published yet, so
114+
you'll need to build it yourself. To build and run the generator, you will need
115115
the following prerequisites:
116116

117117
* Python 3.12 or newer
@@ -121,11 +121,23 @@ the following prerequisites:
121121
* JDK 17 or newer
122122
* make
123123

124-
Now run `make install-components` from the root of this repository. This will
124+
Now, run `make install-components` from the root of this repository. This will
125125
install the python dependencies in your environment and make the code generator
126126
available locally. For more information on the underlying build process, see the
127127
"Using repository tooling" section.
128128

129+
> [!TIP]
130+
> To make development easier, run the following command from the root:
131+
>```shell
132+
> ./pants export --resolve=python-default
133+
> ```
134+
> This will generate a [virtualenv](https://docs.python.org/3/library/venv.html) containing all python dependencies
135+
> and tools needed to build this project. There should be output in your terminal, denoting where pants
136+
> created the environment. Make sure to activate it by running:
137+
>```shell
138+
> source dist/export/python/virtualenvs/python-default/<version>/bin/activate
139+
> ```
140+
129141
Now from your project directory run `smithy build` and you'll have a generated
130142
client! The client can be found in `build/smithy/client/python-client-codegen`.
131143
The following is a snippet showing how you might use it:

0 commit comments

Comments
 (0)