mintel / build-harness

🤖Collection of Makefiles to facilitate building Python/Golang projects, Dockerfiles, and more
Apache License 2.0
2 stars 6 forks source link

Disable installing build-harness venv via python 2 #51

Closed charlieparkes closed 4 years ago

charlieparkes commented 4 years ago
charlieparkes commented 4 years ago

Note: If you must develop in Python 2, install the libs via your project's dev-dependencies, you can write a target that offloads some complexity to the build-harness.

lint: pipenv reports/
    @$(MAKE) python/lint/announce/isort
    @$(PIPENV_RUN) isort $(ISORT_FLAGS) --check-only $(PYTHON_LINT_TARGETS) --diff
    @$(MAKE) python/lint/announce/flake8
    @$(PIPENV_RUN) flake8 $(FLAKE8_FLAGS) $(PYTHON_LINT_TARGETS)
.PHONY: lint

In this example, build-harness provides:

You could simplify this even more, but this is an example replicating the exact functionality build-harness provides for isort and flake8. Check the source for other examples you may draw inspiration from if you decide to write a custom target.

charlieparkes commented 4 years ago

@chavlin I'd prefer not to add it to the readme, as it's not "officially supported" by the project. In the unlikely event someone brings this up, refer them to this PR. (it is the github way) this is the way

charlieparkes commented 4 years ago

We just discovered that this breaks our jenkins builds. It's almost like running all builds on the same python 2 binary is a bad idea. 🙄 Will need to find a workaround for CI systems that don't run builds on the project's desired version of python.

charlieparkes commented 4 years ago

Ok, updated to work in python 2 build environments.

  1. If project is using pipenv, set python_requires in .build-harness.Pipfile
  2. bh/venv will now run with warning when local python is python 2, but the project is python 3, as python 2 pipenv will let us run python 3 packages and redirect to the correct system version of python, if it's installed