Skip to content

Commit

Permalink
tools/create_new: fixed generated tox.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
SamDanielThangarajan committed Sep 3, 2024
1 parent 24710f0 commit 11ab617
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/nasdaq_protocols/tools/new_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class AppInfo:
class Context:
project_name: str
project_src_name: str
project_module_dir: Path
target_dir: Path
pyproject_toml: Path
tox_ini: Path
Expand Down Expand Up @@ -61,9 +62,11 @@ def create(name, target_dir, application):
click.echo(f'Creating project {name} in {target_dir}')

target_dir = Path(target_dir) / Path(name)
project_src_name = name.replace('-', '_')
context = Context(
project_name=name,
project_src_name=name.replace('-', '_'),
project_src_name=project_src_name,
project_module_dir=Path(target_dir) / Path('src') / Path(project_src_name),
target_dir=Path(target_dir),
pyproject_toml=Path(target_dir) / Path('pyproject.toml'),
tox_ini=Path(target_dir) / Path('tox.ini'),
Expand All @@ -72,7 +75,7 @@ def create(name, target_dir, application):

for app_proto in application:
app_name, proto_name = app_proto.split(':')
app_dir = Path(target_dir) / Path('src') / Path(context.project_src_name) / Path(app_name)
app_dir = context.project_module_dir / Path(app_name)
app_info = AppInfo(
app_name=app_name,
app_dir=app_dir,
Expand All @@ -81,10 +84,10 @@ def create(name, target_dir, application):
)
app_info.app_dir.mkdir(parents=True, exist_ok=True)
_write_app_xml(app_info)
click.echo(f'Created application directory: {app_dir}')
context.apps.append(app_info)
click.echo(f'Created application directory: {app_dir}')

Path(target_dir / Path('__init__.py')).touch()
Path(context.project_module_dir / Path('__init__.py')).touch()
_write_pyproject(context)
_write_tox(context)

Expand Down
7 changes: 5 additions & 2 deletions src/nasdaq_protocols/tools/templates/tox.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ description = Build package
deps =
nasdaq-protocols
build
allowlist_externals =
{{#apps}}
nasdaq-{{proto_name}}-codegen
{{/apps}}
commands =
{{#apps}}
nasdaq-generate-{{proto_name}}-classes src/{{project_src_name}}/{{app_name}}/{{app_name}}.xml src/{{project_src_name}}/{{app_name}} {{app_name}} {{project_src_name}}.{{app_name}}
nasdaq-{{proto_name}}-codegen --spec-file=src/{{project_src_name}}/{{app_name}}/{{app_name}}.xml --app-name={{app_name}} --op-dir=src/{{project_src_name}}/{{app_name}} --init-file
{{/apps}}
python -m build

0 comments on commit 11ab617

Please sign in to comment.