Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
architecture: x64

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

- name: Set Up Python for CI - ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand All @@ -98,18 +98,18 @@ jobs:
make install-python-components

- name: clean and build without formatting/linting installed
run: cd codegen && ./gradlew clean build -Plog-tests
run: cd codegen && ./gradlew clean build

- name: Install black
run: |
python${{ matrix.python-version }} -m pip install --upgrade black

- name: clean and build without linting installed
run: cd codegen && ./gradlew clean build -Plog-tests
run: cd codegen && ./gradlew clean build

- name: Install mypy and other libraries necessary for typing
run: |
python${{ matrix.python-version }} -m pip install --upgrade mypy pytest pytest-asyncio

- name: clean and build with all optional tools installed
run: cd codegen && ./gradlew clean build -Plog-tests
run: cd codegen && ./gradlew clean build
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ target/
**/dependency-reduced-pom.xml

# Gradle
/.gradle
**/.gradle
build/
*/out/
*/*/out/
**/*/out/

# Python
__pycache__
Expand Down
51 changes: 19 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,55 +1,46 @@
help: ## Show this help.
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
.DEFAULT_GOAL:=help

help: ## Show this help.
@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)

## 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.
pants:
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.
ifeq ($(CI),true)
cp scripts/pantsw pants
else
./get-pants --bin-dir .
endif


## Packages and installs the python packages.
install-python-components: pants
install-python-components: pants ## Packages and installs the python packages.
./pants package ::
python3 -m pip install dist/*.whl --force-reinstall


## Publishes java packages to maven local.
install-java-components:
install-java-components: ## Publishes java packages to maven local.
cd codegen && ./gradlew publishToMavenLocal


## Installs java and python components locally.
install-components: install-python-components install-java-components
install-components: install-python-components install-java-components ## Installs java and python components locally.


## Builds the Java code generation packages.
smithy-build:
smithy-build: ## Builds the Java code generation packages.
cd codegen && ./gradlew clean build


## Generates the protocol tests, rebuilding necessary Java packages.
generate-protocol-tests:
cd codegen && ./gradlew clean :smithy-python-protocol-test:build
generate-protocol-tests: ## Generates the protocol tests, rebuilding necessary Java packages.
cd codegen && ./gradlew :protocol-test:build


## Runs already-generated protocol tests.
run-protocol-tests:
cd codegen/smithy-python-protocol-test/build/smithyprojections/smithy-python-protocol-test/rest-json-1/python-client-codegen && \
run-protocol-tests: ## Runs already-generated protocol tests.
cd codegen/protocol-test/build/smithyprojections/protocol-test/rest-json-1/python-client-codegen && \
python3 -m pip install '.[tests]' && \
python3 -m pytest tests


## Generates and runs protocol tests.
test-protocols: install-python-components generate-protocol-tests run-protocol-tests
test-protocols: install-python-components generate-protocol-tests run-protocol-tests ## Generates and runs protocol tests.


## Runs formatters/fixers/linters for the python packages.
lint-py: pants
lint-py: pants ## Runs formatters/fixers/linters for the python packages.
./pants fix lint python-packages/smithy-core::
./pants fix lint python-packages/smithy-http::
./pants fix lint python-packages/smithy-aws-core::
Expand All @@ -58,8 +49,7 @@ lint-py: pants
./pants fix lint python-packages/aws-event-stream::


## Runs checkers for the python packages.
check-py: pants
check-py: pants ## Runs checkers for the python packages.
./pants check python-packages/smithy-core::
./pants check python-packages/smithy-http::
./pants check python-packages/smithy-aws-core::
Expand All @@ -68,8 +58,7 @@ check-py: pants
./pants check python-packages/aws-event-stream::


## Runs tests for the python packages.
test-py: pants
test-py: pants ## Runs tests for the python packages.
./pants test python-packages/smithy-core::
./pants test python-packages/smithy-http::
./pants test python-packages/smithy-aws-core::
Expand All @@ -78,11 +67,9 @@ test-py: pants
./pants test python-packages/aws-event-stream::


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


## Clean up generated code, artifacts, and remove pants.
clean:
rm -rf pants dist/
clean: ## Clean up generated code and artifacts.
rm -rf dist/
cd codegen && ./gradlew clean
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ With both files your project directory should look like this:
```


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

* Python 3.12 or newer
Expand All @@ -121,11 +121,23 @@ the following prerequisites:
* JDK 17 or newer
* make

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

> [!TIP]
> To make development easier, run the following command from the root:
>```shell
> ./pants export --resolve=python-default
> ```
> This will generate a [virtualenv](https://docs.python.org/3/library/venv.html) containing all python dependencies
> and tools needed to build this project. There should be output in your terminal, denoting where pants
> created the environment. Make sure to activate it by running:
>```shell
> source dist/export/python/virtualenvs/python-default/<version>/bin/activate
> ```

Now from your project directory run `smithy build` and you'll have a generated
client! The client can be found in `build/smithy/client/python-client-codegen`.
The following is a snippet showing how you might use it:
Expand Down
Loading