How to used `make` based python project in pycharm
Completed
I have a make based python project , whose basic structure can be seen from here : https://github.com/drivendata/cookiecutter-data-science.
Is it possible for me to be able to run this project from pycharm itself? If not, is there any other automatic build system I can use?
Please sign in to leave a comment.
I don't think you can do it directly by "importing" the content of makefile automatically into PyCharm (sorry if I'm wrong, since I don't have any experience with makefiles & PyCharm) but PyCharm provides a number of functions that will enable you to run it. Secondly maybe there is no need to import content of makefile into PyCharm after all. Here are a few tips:
requirements: PyCharm will detect your requirements.txt and ask you to install packages automatically. You may want to create a virtualenv with PyCharm and manage all requirements through PyCharm interface.
Package requirements filename can be defined in Tools>Python Integrated Tools
data: this is just running a script. You can click on in in Project windows and select run
clean: again from Project window you can click on directory structure and select Clean Python compiled files options
lint: if you don't want use PyCharm inspections here is a link that will show you how to run flake8 as external tool:
https://foxmask.trigger-happy.eu/post/2016/02/17/pycharm-running-flake8/
The question is do you really need to run it as external tool instead of using PyCharm capabilities?
sync_data_to_s3 & sync_data_from_s3: Remote Deployment options is what you are looking for.
Basically using flake8 tip you should be able to automate your makefile script.
Another option is to open correct virtualenv in PyCharm switch to project directory from Terminal window and type make assuming
you have all the tools including make installed. The flake8 tip can be used to achieve the same goal.
I use something like the following. It is a bit of a cludge and depends on people putting their venv in the correct spot.
There is a case where someone has created a venv in the root directory and then wants to use one elsewhere on their system and doesn't clean up the one in the root of the project but this works for me.
---------------------------------------------------
.PHONY: test init_db migrate generate_migration default
.DEFAULT_GOAL := default
export PYTHONPATH=.
# This is for running inside PyCharm
export PATH:=${PWD}/venv/bin:${PATH}
default: migrate init_db
generate_migration:
@ alembic revision --autogenerate
migrate:
@ alembic upgrade head
test:
@ pytest -v tests
init_db:
@ python fastapp/scripts/initialise.py
# vim:ft=make
---------------------------------------------------