Wing Tips: Creating a Project for an Existing Code Base

Sep 10, 2021


Wing 8 introduced some improvements and new capabilities for the project creation process. In this Wing Tip, we'll take a look at the options available during project creation in Wing Pro.

Note that Wing Personal also has the concept of projects, but omits support for remote development, cloning from revision control repositories, creating Python environments with the project, and support for specific third party packages and tools like Django, Flask, Jupyter, Docker, Poetry, pipenv, and others. As a result, many of the options described below are not available in Wing Personal.

Selecting Directory and Project Type

New projects are created with New Project in the Project menu. This displays a dialog that allows you to select the source code to use with the new project and to select or configure the Python environment you plan to use:

/images/blog/create-project/new-project.png

From here it's possible to create an entirely blank project, which you can configure later, or you can set up your project with an existing source directory or create a new source directory along with the project.

Note that you can create a project for remote development here, but for now ignore this option and leave Host set to Local Host. We'll talk about remote development in future Wing Tips.

Using an Existing Directory

If you already have a Python code base you want to use with Wing, select Use Existing Directory and choose the directory to use:

/images/blog/create-project/existing-dir.png

Creating a New Directory

If you are starting a new project from scratch, select Create New Directory and enter the directory name, parent directory, optionally select a revision control repository to clone into the new directory (for example, by entering a Github repository url), and select the unit testing framework that you plan to use, if any:

/images/blog/create-project/new-dir.png

Project Type

Whether you're using an existing directory or creating a new one, you will be able to specify a Project Type from this page of the New Project dialog. If you are using a Python package listed in the Project Type drop down, select that also. This tells Wing how to configure your project to work properly with your code:

/images/blog/create-project/project-type.png

If your project type is not listed, leave this value set to Custom. In this case, you can opt to ask Wing to configure your project to allow debug processes to be launched from outside of the IDE, for example by a web server or another app. If this will be the case, check on the Use wingdbstub for Debugging option. If you don't yet know how you will launch debug, leave this unchecked. You can always configure this later.

Selecting a Python Environment

At this point, if you used an existing source directory, Wing looks in the directory for a Python environment managed by Poetry, pipenv, or virtualenv and pip. If it finds one, it will use that with the new project and you can simply press the Create Project button.

Otherwise, press Next to select or configure a Python environment for the project.

You can then either use an existing Python environment with your project or create a new one. If you already have a Python environment to use, select Use Existing Python:

/images/blog/create-project/existing-env.png

You can specify the Python to use by selecting the default Python, entering a custom command line that invokes Python, selecting an activated environment, or setting up a container or cluster environment. The latter two options will be described in future Wing Tips.

The Use default option causes Wing to use the Python that is run from the command line or the latest found version if Python is not on the PATH.

Command Line is used to specify the full path command line that invokes Python. For virtualenv, Poetry, and pipenv this can be the python or python.exe executable that is found in the environment.

Activated Env is used to specify the activation command for an existing Python environment. Wing runs this command and then starts Python within the env.

Both the Command Line and Activated Env options provide a drop down that lists all the found Python installations and environments Wing was able to find on your system.

Creating a Python Environment

Another option is to create a new Python environment along with your project. This is done by selecting Create New Environment on the second New Project screen and then choosing the type of environment to create:

/images/blog/create-project/new-env.png

Wing can create environments managed by Anaconda, Docker, Poetry, pipenv, and virtualenv with pip. The options entered for each of these differ. We'll describe this in more detail in the next Wing Tip or take a look at these links for more information: Poetry | Anaconda | Docker | pipenv | virtualenv

Finishing Up

Once your Python environment has been selected or configured, press Create Project and Wing will show a progress dialog as it creates and configures everything.

As part of this process, Wing saves the project automatically if you created a new source directory. Otherwise, you will need to save the project, which is typically best done to the top level of your project source tree.



That's it for now! We'll be back next week to continue this Wing Tips mini-series on navigating Python code with Wing.

As always, please don't hesitate to email support@wingware.com if you run into problems or have any questions.



Share this article: