Python package for project creation
pip install setup.py
{
"project-name": "Example project",
"project-description": "Example project description",
"project-version-major":1,
"project-version-minor":3,
"git-repo":"https://github.com/user/example.git",
"author": "AuthorName AuthorLastName",
"author-email": "author@mail.com",
"docker-tag": "",
"configuration":
{
"parent-folder": "/where/to/build/your/project",
"packages": {
"pack1": {}
},
"resource-folders": ["resource1", "resource2"]
}
}
`pymake /path/to/your/configure.py
- 📂 [project-name]
- 📃
README.md - 📃
pymakeconfigure.json - 📂 [project-name]
- 📃
__init__.py - 📃
main.py - 📃
project_vars.py - 📃
pymakefile.json - 📂 [resource1]
- 📂 [resource2]
- 📂 [pack1]
- 📃
__init__.py
- 📃
- 📂 [pymake]
- 📂 [docker]
- 📃
create_docker_image.py - 📃
aws_push.template - 📃
create_image.template - 📃
Dockerfile.template - 📃
dockerignore.template - 📃
run_container_local.template
- 📃
- 📂 [setup]
- 📃
create_setup.py - 📃
setup.py.template
- 📃
- 📂 [docker]
- 📃
- 📃
This means that you have to program something!
Some important notes:
To use resource files on your project, you can access your file path using the library
pkg_resourcesas:
pkg_resources.resource_filename(__name__, 'resource.txt')Note that this will access files from a python module to a file in the same folder. If the resource is in a deeper folder you can use:
pkg_resources.resource_filename(__name__, 'path/from/module/resource.txt')If you want to access files in upper folders, you have to define the name of your project such as:
pkg_resources.resource_filename(example_project, 'resource1/resource.txt')This option can be used anywhere in your code - MAKE SURE THE ROOT PROJECT FOLDER IS IN
sys.path
In the file main.py, develop your entry point for your program. Just complete the main() function.
This file will create the setup.py of your project in the root directory.
This script will create the configuration for a docker image creation. Note create your setup.py before the docker image creation.
If you will upload your docker image to an aws repository, make sure your pymakefile.json has the variable
docker-tagset to the repository tag.
To create your local docker image, run the script
create_image.shas root
Run the script
run_container_local.shas root
Run the script
aws_push.shas root
The Dockerfile
This file is a default that you can modify. It will copy your project folder, install using the
setup.pyand launch yourmainscript function
#"""Project example_project
#Author Name Surname
#email me@you.com
#"""
# Set python base image
FROM python:3-stretch
# Set the working directory
WORKDIR /usr/src/app
# Copy files
COPY . example_project/
# Install internal requirements
RUN pip install --no-cache-dir example_project/
`
# Define command to execute
CMD [ "example_project" ]