Skip to content

Commit 45cc8f7

Browse files
authored
fix: PAN-1832 include config on wheel (#10)
* fix: PAN-1832 include config on wheel
1 parent 8b31cec commit 45cc8f7

File tree

14 files changed

+126
-238
lines changed

14 files changed

+126
-238
lines changed

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**/__pycache__/
2+
*.egg-info/
3+
*.key*
4+
*.keystore*
5+
*.swp
6+
.coverage
7+
.DS_store
8+
.venv/
9+
.vscode/
10+
build/
11+
dist/
12+
find.sh
13+
local/
14+
.pytest_cache
15+
.mypy_cache
16+
Dockerfile
17+
*.

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
5151
- name: Test image
5252
run: |
53-
docker run --rm ghcr.io/pantos-io/client-cli:latest --help
53+
docker run --rm ghcr.io/pantos-io/client-cli:latest --help
5454
5555
build-and-run:
5656
runs-on: ubuntu-latest

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ build/
1111
dist/
1212
find.sh
1313
local/
14+
.pytest_cache
15+
.mypy_cache

Dockerfile

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
1-
FROM python:3.12-alpine
2-
3-
ARG environment=testnet
4-
ARG version=1.1.0
5-
6-
ENV PANTOS_CLIENT_VERSION=${version}
1+
FROM python:3.12-alpine AS build
72

83
RUN apk update && apk add gcc libc-dev libffi-dev \
94
&& apk cache clean
105

6+
RUN python3 -m pip install poetry
7+
118
WORKDIR /pantos-cli
129

13-
COPY pyproject.toml poetry.lock ./
10+
COPY . .
1411

15-
RUN python3 -m pip install poetry
12+
RUN poetry build
13+
14+
FROM python:3.12-alpine AS production
15+
16+
WORKDIR /pantos-cli
17+
18+
COPY --from=build /pantos-cli/dist/*.whl .
1619

17-
RUN poetry install --only main --no-interaction --no-cache --no-root
20+
RUN python3 -m pip install *.whl
1821

19-
RUN mkdir -p ./pantos/cli
22+
RUN pip cache purge && rm -rf ~/.cache/pip
2023

21-
COPY pantos/cli ./pantos/cli
22-
COPY client-cli.yml .
23-
COPY client-library.yml .
24-
COPY client-cli.env .
25-
COPY client-library.env .
24+
RUN rm *.whl
2625

27-
ENTRYPOINT ["poetry", "run", "python3", "-m", "pantos.cli"]
26+
ENTRYPOINT ["pantos-cli"]

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,8 @@ wheel:
7070
poetry build
7171

7272
.PHONY: docker
73-
docker: dist/pantos_client_cli-$(PANTOS_CLIENT_CLI_VERSION).docker
74-
75-
dist/pantos_client_cli-$(PANTOS_CLIENT_CLI_VERSION).docker: Dockerfile pantos/ client-cli.yml client-library.yml client-library.publish.env submodules/client-library/pantos/client/library/ pyproject.toml submodules/common/pantos/common/
73+
docker:
7674
docker build -t pantosio/pantos-client .
77-
mkdir -p dist
78-
docker save pantosio/pantos-client > dist/pantos_client_cli-$(PANTOS_CLIENT_CLI_VERSION).docker
7975

8076
.PHONY: install
8177
install: dist/pantos_client_cli-$(PANTOS_CLIENT_CLI_VERSION)-py3-none-any.whl

pantos-client-cli.conf

Lines changed: 0 additions & 41 deletions
This file was deleted.

pantos-client-library.conf

Lines changed: 0 additions & 175 deletions
This file was deleted.

pantos/cli/__main__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import argparse
55
import decimal
66
import getpass
7+
import importlib.resources
78
import pathlib
9+
import shutil
810
import sys
911
import typing
1012
import uuid
@@ -31,6 +33,8 @@ def main() -> None:
3133
_execute_command_transfer(arguments)
3234
elif arguments.command == 'status':
3335
_execute_command_status(arguments)
36+
elif arguments.command == 'create-config':
37+
_execute_command_create_config(arguments)
3438
else:
3539
raise NotImplementedError
3640
except Exception as error:
@@ -125,6 +129,12 @@ def _create_argument_parser() -> argparse.ArgumentParser:
125129
help='The number of blocks to query for the transfer on the '
126130
'destination blockchain. If not specified, the query will '
127131
'include all blocks from the latest to the genesis block.')
132+
parser_config = subparsers.add_parser('create-config',
133+
help='Create a new empty env file')
134+
parser_config.add_argument(
135+
'-p', '--path', type=pathlib.Path, default=None,
136+
help='Path where to create the env file, defaults to the '
137+
'current working directory')
128138
return parser
129139

130140

@@ -199,6 +209,22 @@ def _execute_command_status(arguments: argparse.Namespace) -> None:
199209
transfer_status)
200210

201211

212+
def _execute_command_create_config(arguments: argparse.Namespace) -> None:
213+
path = arguments.path
214+
if path is None:
215+
path = pathlib.Path.cwd()
216+
217+
path.mkdir(parents=True, exist_ok=True)
218+
219+
# List and copy all .env files from the pantos resource directory
220+
resource_path = importlib.resources.files('pantos')
221+
for env_file in resource_path.iterdir():
222+
env_file_path = pathlib.Path(env_file.name)
223+
if env_file_path.suffix == '.env':
224+
shutil.copy(env_file_path, path / env_file_path.name)
225+
print(f'Created .env files in {path}')
226+
227+
202228
def _load_private_key(
203229
blockchain: api.Blockchain,
204230
keystore_path: typing.Optional[pathlib.Path] = None) -> api.PrivateKey:
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)