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

Provide an wizard for existing apps #1202

Closed
freakboy3742 opened this issue Apr 22, 2023 · 3 comments · Fixed by #1231
Closed

Provide an wizard for existing apps #1202

freakboy3742 opened this issue Apr 22, 2023 · 3 comments · Fixed by #1231
Labels
enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start!

Comments

@freakboy3742
Copy link
Member

What is the problem or limitation you are having?

briefcase new works well for bootstrapping a new project from scratch. However, if you have an existing project, the wizard can't really be used - your only option is to write (or update) your pyproject.toml config from scratch

Describe the solution you'd like

Briefcase should have an option (briefcase new --sources src/myapp) that can be used to set up an existing project with Briefcase. This mode would ask the usual wizard questions, use the location specified by --sources, and write a first draft of a pyproject.toml - updating the existing pyproject.toml if it already exists.

Describe alternatives you've considered

Treat this problem as a documentation issue.

Additional context

The easiest approach will likely be to use the cookiecutter new project template to generate a full dummy project config into a temporary directory, then merge the pyproject.toml in the dummy with the one that the project already has, and then clean up the temporary directory.

When the user specifies a sources of src/myapp, there should be some error detection to ensure that:

  1. The specified path exists
  2. It contains a __main__.py

Once that has been verified, there's no need to ask the user for the appname - it should be the tail of the path given to --sources (i.e., --sources src/myapp would be an app name of myapp). The user should still be asked for formal name, bundle etc.

It may also be necessary to provide a --test-sources option so that the user can optionally specify the location of their test code.

  1. Specifying --test-sources but not --sources should be an error;
  2. if --sources is specified, but --test-sources isn't, the template should be written as if there are no test sources;
  3. If --sources and --test-sources is specified, the testing entry script generated by the dummy template should be copied into the test sources folder.

When in --sources mode, the wizard should also audit the project to highlight any extra files that may be needed. For example, the default template generates a LICENSE and CHANGELOG file - if these aren't present in the existing project, the user should be warned that they should add them (or copy over the versions from the dummy project with a warning that dummy content has been added).

@freakboy3742 freakboy3742 added enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start! labels Apr 22, 2023
@yngvem
Copy link
Contributor

yngvem commented Apr 24, 2023

@MarieRoald and I would be happy to work on this during the sprint

@freakboy3742
Copy link
Member Author

@yngvem @MarieRoald Awesome - I'm in 250C if you need any assistance or pointers (or to collect your challenge coin when you're done :-)

@yngvem
Copy link
Contributor

yngvem commented Apr 24, 2023

After talking with @mhsmith, we found that specifying sources as a command line argument might become unnecessarily complicated. Instead, we think that specifying --target, which is the project root directory that contains the pyproject.toml file might be a better solution.

By doing it this way, we make it clearer that the target directory is the project root. Moreover, by specifying --target, we also make it possible to run briefcase new and explicitly state what the target directory should be for new projects.

We believe that the cleanest way to accomplish this is to modify the pyproject.toml file in the cookiecutter template, and adding a new field source_dir, which is automatically set for new projects but explicitly asked for when the directory specified in --target exists. Specifically, we propose changing this line:

    "{{ cookiecutter.source_dir }}",

After the cookiecutter is changed, we would modify NewCommand.__call__ so that if --target is specified, then cookiecutter is run in a temporary directory. Then, if --target exists, the original pyproject.toml file is merged with the file generated by cookiecutter. Otherwise, --target is created and all contents from the temporary cookiecutter directory is copied.

When prompted for --sources, we could check if the directory (relative to --target) exists and if it contains a __main__.py file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features. good first issue Is this your first time contributing? This could be a good place to start!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants