question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Discussion] Convert Makefile into a Python script

See original GitHub issue

Proposal: 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
    • test
      • Runs pytest and set XRAY env to run that locally
      • Define parameter for specifying tests folder
  • clean
    • Deletes zip file and build folder

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
heitorlessacommented, Dec 31, 2018

This will no longer be needed due to SAM now supports build

1reaction
h1f1xcommented, Jun 12, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Convert a makefile to Python Script | Python | Coding Forums
Hello All I am working on a Problem to convert makefile in to a python script. Are there any Modules? Please try to...
Read more >
How to write makefile for Python(turn into a executable file)?
I need to write a makefile to turn my python codes into executable file. For example, I have main.py , utility.py. I need...
Read more >
Creating a Python Makefile - Earthly Blog
It is a tool which controls the generation of executable and other non-source files from a program's source file. It can automate the...
Read more >
Automation and Make
The script plotcounts.py reads in a data file and plots the 10 most ... This is a build file, which for Make is...
Read more >
1. Embedding Python in Another Application ... - Python Docs
Most topics discussed in the previous chapters are still valid. To show this, consider what the extension code from Python to C really...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found