/create-python-project

This repository holds a wizard that provides commands to auto-generate a python project based on different template structures. The created project will be as per Ansys recommendations.

Primary LanguagePythonMIT LicenseMIT

Create Python Project

PRs Welcome

Deprecation Warning

Warning This repository has been deprecated in favor of ansys-templates. The new template takes advantage of a dynamic install, allows you to select the build system and is deeply tested.

Quick Overview

Easily create a new Python project with simple commands:

pipx run ansys-create-python-project -n my-project

or

acpp -n my-project

Create Python Project

The new python project will be created according to the Ansys-recommended structure.

For example, the commands above will create a directory called my-project inside the current directory.

View the full documentation here.

Prerequisites

  • Python 3.8+
  • pip
  • pipx (Optional but recommended)

This tool is compatible with Windows OS and Linux distributions.

Usage

Create new project

With pipx

pipx run ansys-create-python-project -n my-project 

pipx is a package runner tool that that helps to run applications written in Python. In fact, it uses pip, but is focused on installing and managing Python packages that can be run from the command line directly as applications. pipx requires Python 3.6+ and can be installed by following these instructions.

It will create a directory called my-project inside the current folder.
Inside that directory, it will generate the initial project structure and install the transitive dependencies:

my-project
├── README.md
├── CONTRIBUTING.md
├── LICENSE
├── flake8
├── pytest.ini
├── requirements.txt
├── package.json
├── CHANGELOG.md
├── .gitignore
├── .gitattributes
├── docker
│   ├── dockerfile
│   └── docker-compose.yml
├── doc
│   ├── images
│   |     └── img.jpeg
│   └── README.md
├── src
│   └── app.py
├── tests
│    └── test_app.py
└── examples
    └── README.md
   

No configuration or complicated folder structures required, only the files you need to build your app.

With pip

If you do not want to install pipx you can still use the package, but first you must install it with pip.

pip install ansys-create-python-project

Then, you can run the package on the command line.

acpp -n my-project

If you aren't sure what sort of arguments you need to supply you can always view the help through the following command.

acpp --help

Specify other templates

The default project template is 'classic'. However, there are several other templates available. You can view the available templates by running the following command.

pipx run ansys-create-python-project --template

You can easily specify other templates with the -t flag.

pipx run ansys-create-python-project -n my-project -t rest-api

Run tests locally

The project newly created is done with a docker and a docker-compose files in the /tests folder. That enables to run all tests very easily in any environment without any additional requirements (only docker and docker-compose are required).

To run the tests run the following command:

  1. Move to /tests folder
  2. Build the docker image
  3. Start a container
  4. Run the tests
  5. Optional: Run specific tests suites thanks to the powerful pytest search feature

Create Python Project

Push your new project to git repository

1- Go inside the created directory by running

cd ./my-project

2- Push this project in git remote repository"

git init

git remote add origin <git_repository_url>

git add . && git commit -m \"initial commit\"

git push origin main