[Discussion] Convert Makefile into a Python script
See original GitHub issueProposal: Convert Makefile into a Python script
Last updated: June 6th
Abstract
As of today, OSX and Linux users are able to have hot-reloading thanks to Makefile logic that creates hard-links on a given service/folder, however this is currently not possible for Windows due to Operating Systems differences.
Windows hard links seem to be supported when using Python and this proposal aims to convert this Makefile to make these features more accessible to everyone. Additionally, this could open the opportunity to add other mechanisms such as deployment asked here https://github.com/aws-samples/cookiecutter-aws-sam-python/pull/2 and make the packaging feature more explicit.
Background
When Windows customers try to use Makefile for hot-reloading or easier Python packaging they need to install Git Bash or Windows Sub-system in order to get access to UNIX tools to make this work.
Linux and OSX users also expressed they’d like to have requirements.txt
or Pipfile
per function and not at the project level as well as a deploy
target, of which would add complexity to Makefile and error prone not to mention that is difficult to test Makefile changes today.
Proposal
I propose porting Makefile essential features to a Python CLI script that would include:
Rationale
By implementing this Python CLI script we could also give more options to customers and be less opinionated as to where their dependencies should be declared and more importantly allow for testing this functionality as Makefile is only for advanced users.
Difficulty here is deciding on a name for this Python CLI script because setup.py
is widely used for Python Packaging with setuptools and manage.py
is used for Django Apps so perhaps bootstrap.py
could fit the bill here.
Also needs some thinking whether it makes sense to use only requirements.txt
to simplify initial design or to support both Pipfile
and requirements.txt
.
Compatibility
No breaking change to the application itself
Implementation
This could be implemented using Python Click or pure Python Argparse to avoid additional dependencies:
- Move
test
folder inside the function - Create a
test
folder to explicitly have tests for this Python CLI script - Add the following targets
- build
- Install deps and creates structure for hot-reloading without having to build a wrapper or anything
- Define parameter for Source Code directory and optional for requirements.txt/Pipfile
- package
- Install deps and builds a Lambda compliant ZIP package and optionally with LambCI Docker Lambda Runtime when needed
- Define parameter to allow straight up
zip
instead of installing deps in case they are already ready
- run
- Runs
sam local start-api
and supports for running Lambda containers within a Docker network
- Runs
- test
- Runs
pytest
and setXRAY
env to run that locally - Define parameter for specifying tests folder
- Runs
- build
- clean
- Deletes zip file and build folder
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top GitHub Comments
This will no longer be needed due to SAM now supports
build
Hi,
I liked the idea of having a makefile instead of a python script. Acceptance (of developers) seems a little higher these times. And it seems a little bit of reinventing the wheel? I am using pybuilder for some years. Maybe you take a look into it [1]. This seems to be doing stuff you like, but introduce another dependency.
[1] https://www.youtube.com/watch?v=jufUqH3bDG0