Skip to content

Commit

Permalink
Migrate to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
missingcharacter committed Dec 25, 2021
1 parent f4650b7 commit c9466e2
Show file tree
Hide file tree
Showing 10 changed files with 856 additions and 452 deletions.
30 changes: 0 additions & 30 deletions Pipfile

This file was deleted.

415 changes: 0 additions & 415 deletions Pipfile.lock

This file was deleted.

13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### How to use

```bash
$ AWS_PROFILE=awsprofile pipenv run python setup_account.py --help
$ AWS_PROFILE=awsprofile poetry run python setup_account.py --help
usage: setup_account.py [-h] -a ACCOUNT_NAME -f SAML_FILE [-s SAML_PROVIDER] -c PHASE -p PURPOSE [-r REGIONS] [-e EMAIL] [-t IVY_TAG] [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}]

1. Creates new sub-account, if email is provided 2. Removes default VPCs 3. Sets account alias 4. Configures SAML 5. Creates default roles and allows access via SAML only
Expand Down Expand Up @@ -60,3 +60,14 @@ TOTAL 454 141 69%

...
```
## About poetry
### Why we use `poethepoet`
One area poetry lags behind poetry is that shell scripts cannot be ran from `poetry run <task>` so we use poe instead.
Maybe after `poetry` version `1.0.0` is released we may stop using it.
See links:
- https://github.com/python-poetry/poetry/pull/591#issuecomment-504762152
- https://github.com/python-poetry/poetry/issues/2496
2 changes: 1 addition & 1 deletion infra_buckets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```
$ cd path/to/this/repo
$ AWS_PROFILE=profile-to-use pipenv run python infra_buckets/infra_buckets.py --help
$ AWS_PROFILE=profile-to-use poetry run python infra_buckets/infra_buckets.py --help
usage: infra_buckets.py [-h] -c PHASE -p PURPOSE [-t IVY_TAG] [-r REGIONS] [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
Creates infrastructure s3 buckets per sysenv
Expand Down
2 changes: 1 addition & 1 deletion new_sub_account/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```
$ cd path/to/this/repo
$ AWS_PROFILE=profile-to-use pipenv run python new_sub_account/new_sub_account.py --help
$ AWS_PROFILE=profile-to-use poetry run python new_sub_account/new_sub_account.py --help
usage: new_sub_account.py [-h] -a SUB_ACCOUNT_NAME -e EMAIL [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
Creates new AWS sub-account
Expand Down
800 changes: 800 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[tool.poetry]
name = "ivy-accounts-tools"
version = "0.1.0"
description = "Multiple scripts used when creating new accounts"
authors = ["abvikg", "thecubed","missingcharacter"]
license = "Mozilla Public License 2.0"

[tool.poetry.dependencies]
python = "^3.8"
boto3 = "==1.11.7"
botocore = "==1.14.7"
click = "^8.0.3"
docutils = "==0.15.2"
jmespath = "==0.9.4"
python-dateutil = "==2.8.1"
s3transfer = "==0.3.1"
six = "==1.14.0"
urllib3 = "==1.25.8"
boto3-stubs = {extras = ["iam", "organizations"], version = "==1.14.60.0"}
datadog-api-client = "==1.7.0"

[tool.poetry.dev-dependencies]
pytest = "==6.2.5"
black = "^21.12b0"
pytest-cov = "==3.0.0"
# one area poetry lags behind poetry is that shell scripts cannot be ran from `poetry run <task>`
# so we use poe instead.
# Maybe after
poethepoet = "^0.11.0"

[tool.poe.tasks]
lint = { cmd = "black --check --line-length 120 *.py app/", help = "Use `black` to check the style of the application" }
lint-fix = { cmd = "black --line-length 120 *.py app/", help = "Same as `lint`, but will fix the application's style to conform with PEP8" }
test = { cmd = "python -m pytest -v --log-file=tests.log --log-file-level=INFO --cov=. tests/ -o junit_family=xunit2 --junitxml=tmp/test-output/pytest.xml" }

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
4 changes: 2 additions & 2 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ function start_localstack() {
bash -c '${IF_SUDO} docker logs -f lstack 2>&1 | { sed "/^RUN TESTS NOW$/ q" && kill -9 $$ ;}' || true
}

pipenv sync --dev
poetry install
start_localstack
pipenv run test
poetry run poe test
2 changes: 1 addition & 1 deletion setup_sso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```
$ cd path/to/this/repo
$ AWS_PROFILE=profile-to-use pipenv run python setup_sso/setup_sso.py --help
$ AWS_PROFILE=profile-to-use poetry run python setup_sso/setup_sso.py --help
usage: setup_sso.py [-h] -a SUB_ACCOUNT_NAME -f SAML_FILE [-s SAML_PROVIDER] [-t IVY_TAG] [-l {CRITICAL,ERROR,WARNING,INFO,DEBUG}]
Sets up an AWS account's alias, SAML provider, Admin role and Read-Only role
Expand Down
2 changes: 1 addition & 1 deletion vpc_cleaner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

```shell
$ cd path/to/this/repo
$ AWS_PROFILE=profile-to-use pipenv run python ./vpc_cleaner/vpc_cleaner.py --help
$ AWS_PROFILE=profile-to-use poetry run python ./vpc_cleaner/vpc_cleaner.py --help
Usage: vpc_cleaner.py [OPTIONS]

Options:
Expand Down

0 comments on commit c9466e2

Please sign in to comment.