Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several issues with generating standalone projects #295

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 13 additions & 2 deletions py_maker/pymaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ def post_process(self) -> None:
proj_loc = (
self.location if self.location != "." else self.choices.project_dir
)
run_cmd = (
f"{self.location}"
if not self.choices.standalone
else "python main.py"
)

output = f"""
--> [green]Project created successfully.[/green]

Expand All @@ -233,7 +239,7 @@ def post_process(self) -> None:
3) Activate the virtual environment:
'poetry shell'
4) Run the application:
'{self.location}'
'{run_cmd}'
5) Code!

See the [bold][green]README.md[/green][/bold] file for more information.
Expand Down Expand Up @@ -313,11 +319,16 @@ def get_input(self) -> None:
if self.settings.github_username
else "<your GitHub username>"
)
repo_name = (
sanitize(self.choices.project_dir.name)
if self.choices.package_name == "-"
else self.choices.package_name
)
self.choices.repository = Prompt.ask(
"Repository URL?",
default=(
f"https://github.com/{github_username}/"
f"{re.sub(r'[_.]+', '-', self.choices.package_name)}"
f"{re.sub(r'[_.]+', '-', repo_name.lower())}"
),
)

Expand Down
4 changes: 4 additions & 0 deletions py_maker/template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ repository = "{{ repository }}"
# rename "{{ slug }}" below to change the executable name. You can also
# add more scripts if your package offers multiple commands.
{{ slug }} = "{{ package_name }}.main:app"

{% else%}
package-mode = false

{% endif %}

[tool.poetry.dependencies]
Expand Down