Skip to main content

Python Create React App

Project description

pcra - Python Create React App

CLI for template-based project scaffolding based on the React to Python book

This highly opinionated but configurable script will create the initial structure for a React/Material-UI application that is programmed in Python (not JavaScript!) and uses Transcrypt to transpile the code into JavaScript.

The script performs the following actions:

  • Creates a source code folder structure in the specified project folder
  • Adds a set of core Python source code modules for creating the React application
  • Optionally stubs out a Flask back-end application with basic user session management
  • Creates virtual environments for front-end and back-end applications
  • PIP installs Transcrypt and Flask into the virtual environments
  • NPM installs Parcel and the Transcrypt plug-in for Parcel
  • Adds a middleware script for serving the Flask application in development
  • NPM installs react, material-ui, and other supporting JavaScript libraries
  • Creates a local git repository and does an initial commit
  • Initializes npm semver versioning for the front-end application

By default, the sample React application that is installed with py-create-react-app is just a placeholder for you to start building your application from. It is similar to the one you get when using the JavaScript create-react-app command. If you would like to use the framework outlined in the React to Python book, you can use the --full-stack command-line option, which will create the scaffolding for a full-stack application with a Flask back-end. If you only need the client side of that framework, you can use the --client-only option.

There are also options to bypass the setup for the virtual environment, installing JavaScript dependencies, and creating a Git repository, if you prefer to set any of those up manually.

If you have your own framework template that follows the same folder structure as PCRA, you can specify that on the command line as well and take advantage of the automated setup features.

After installing the pcra package with pip, you can verify that it works by running it with:

py-create-react-app my_project

This will set up the structure of a project in a new my_project folder in the current directory. After it finishes the setup process, you can build and run the application using the following commands:

cd my_project
source ./venv/bin/activate or venv\Scripts\activate for Windows
npm start -- --open

Default React Project React to Python Project
screenshot screenshot

Installation

Install using Python 3.7 with:

python3.7 -m pip install pcra

or to get the latest version from GitHub:

python3.7 -m pip install git+https://github.com/JennaSys/pcra

On Windows you can also use:

py -3.7 -m pip install pcra

Usage:

py-create-react-app [-h] [-co | -fs] [-nv] [-njs] [-ng] [-t TEMPLATE] FOLDER_NAME

Python Create React App: Template-based Python React project scaffolding creator

positional arguments:

  FOLDER_NAME           name of the project folder (must not already exist)

optional arguments:

  -h,          --help               show this help message and exit
  -co,         --client-only        only create client project (not full stack)
  -fs,         --full-stack         create full-stack project (with Flask back-end)
  -nv,         --no-virtualenv      DO NOT create virtual environments
  -njs,        --no-javascript      DO NOT install JavaScript libraries
  -ng,         --no-git             DO NOT create Git repository
  -t TEMPLATE, --template TEMPLATE  alternate template folder to use

NOTE: Transcrypt requires that this must be run with Python version 3.7

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcra-0.1.1.tar.gz (201.6 kB view details)

Uploaded Source

Built Distribution

pcra-0.1.1-py3-none-any.whl (210.5 kB view details)

Uploaded Python 3

File details

Details for the file pcra-0.1.1.tar.gz.

File metadata

  • Download URL: pcra-0.1.1.tar.gz
  • Upload date:
  • Size: 201.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.9

File hashes

Hashes for pcra-0.1.1.tar.gz
Algorithm Hash digest
SHA256 097173dec32b97a0bcfc7ff3e630bfa74e337985d532ef1dafca7748f497af43
MD5 a7d2decdc917db0372f98675083b7164
BLAKE2b-256 50c1de9a7fceac89d15297eb04bee05f99862511dcffdffe6db583df5417c20d

See more details on using hashes here.

File details

Details for the file pcra-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pcra-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 210.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.9

File hashes

Hashes for pcra-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42a406316c9a1b5948cead66d45e0ff598e625565665a0fde4bcf7315e1eecfb
MD5 752ac426fe6b86c8f397f67b948ef76d
BLAKE2b-256 e23e76ed72e9d0054be14f030dff7f113aa4c2b5478813e3accbcff2aea7723a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page