Skip to content

Commit

Permalink
switch from pipenv to poetry
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Miller <admiller@redhat.com>
  • Loading branch information
maxamillion committed May 13, 2020
1 parent 68e09e4 commit 7cd038b
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 385 deletions.
25 changes: 14 additions & 11 deletions CONTRIBUTING.md
Expand Up @@ -6,30 +6,33 @@ If you have questions about this document or anything not covered here? Come cha

## Things to know prior to submitting code

- All code and doc submissions are done through pull requests against the `master` branch.
- All code and doc submissions are done through pull requests against the `devel` branch.
- Take care to make sure no merge commits are in the submission, and use `git rebase` vs `git merge` for this reason.
- We ask all of our community members and contributors to adhere to the [Ansible code of conduct](http://docs.ansible.com/ansible/latest/community/code_of_conduct.html). If you have questions, or need assistance, please reach out to our community team at [codeofconduct@ansible.com](mailto:codeofconduct@ansible.com)

## Setting up your development environment

It's entirely possible to develop on **Ansible Runner** simply with
Ansible Runner development is powered by [Poetry](https://python-poetry.org/), make sure you have it [installed](https://python-poetry.org/docs/#installation) and then:

```bash
(host)$ python setup.py develop
```

Another (recommended) way is to use [Pipenv](https://docs.pipenv.org/), make sure you have it installed and then:

```bash
(host)$ pipenv install --dev
(host)$ poetry install
```

This will automatically setup the development environment under a virtualenv, which you can then switch to with:

```bash
(host)$ pipenv shell
(host)$ poetry shell
```

## Linting and Unit Tests

`tox` is used to run linters (`flake8` and `yamllint`) and unit tests on both Python 2 and 3. It uses pipenv to bootstrap these two environments.
`tox` is used to run linters (`flake8` and `yamllint`) and unit tests on both Python 2 and 3. It uses poetry to bootstrap these two environments.

## A note about setup.py

In this repository you will find a [`setup.py` file](https://docs.python.org/3/installing/index.html#installing-index),
for the time being this needs to be kept in-sync by hand until [Poetry](https://python-poetry.org/).
has the ability to generate a `setup.py` in a compatible way *or* the built-in
Poetry tooling allows for the `packaging/poetry-gen-setup.py` to be sufficient
for auto-generation. This is necessary as it allows the Ansible Runner codebase
to be compatible with build and release systems that do not yet support Poetry.
2 changes: 1 addition & 1 deletion Dockerfile.dev
Expand Up @@ -8,7 +8,7 @@ RUN yum -y install epel-release && \
which gcc python-devel libxml2 libxml2-devel krb5 krb5-devel curl curl-devel \
openssh openssh-clients && \
pip install --no-cache-dir -U setuptools && \
pip install --no-cache-dir wheel pexpect psutil python-daemon pipenv PyYAML && \
pip install --no-cache-dir wheel pexpect psutil python-daemon poetry PyYAML && \
localedef -c -i en_US -f UTF-8 en_US.UTF-8 && \
chmod +x /tini && \
rm -rf /var/cache/yum
Expand Down
19 changes: 12 additions & 7 deletions Makefile
@@ -1,14 +1,15 @@
PYTHON ?= python
ifeq ($(origin VIRTUAL_ENV), undefined)
DIST_PYTHON ?= pipenv run $(PYTHON)
DIST_PYTHON ?= poetry run $(PYTHON)
else
DIST_PYTHON ?= $(PYTHON)
endif

NAME = ansible-runner
IMAGE_NAME ?= $(NAME)
PIP_NAME = ansible_runner
VERSION := $(shell $(DIST_PYTHON) setup.py --version)
LONG_VERSION := $(shell poetry version)
VERSION := $(filter-out $(NAME), $(LONG_VERSION))
ifeq ($(OFFICIAL),yes)
RELEASE ?= 1
else
Expand Down Expand Up @@ -72,18 +73,20 @@ clean:
find . -type f -regex ".*\py[co]$$" -delete

dist:
$(DIST_PYTHON) setup.py bdist_wheel --universal
poetry build

sdist: dist/$(NAME)-$(VERSION).tar.gz

# Generate setup.py transiently for the sdist so we don't have to deal with
# packaging poetry as a RPM for rpm build time dependencies.
dist/$(NAME)-$(VERSION).tar.gz:
$(DIST_PYTHON) setup.py sdist

dev:
pipenv install
poetry install

shell:
pipenv shell
poetry shell

test:
tox
Expand All @@ -100,11 +103,13 @@ devimage:
docker build --rm=true -t $(IMAGE_NAME)-dev -f Dockerfile.dev .

rpm:
docker-compose -f packaging/rpm/docker-compose.yml \
MOCK_CONFIG=$(MOCK_CONFIG) docker-compose -f packaging/rpm/docker-compose.yml build
MOCK_CONFIG=$(MOCK_CONFIG) docker-compose -f packaging/rpm/docker-compose.yml \
run --rm -e RELEASE=$(RELEASE) rpm-builder "make mock-rpm"

srpm:
docker-compose -f packaging/rpm/docker-compose.yml \
MOCK_CONFIG=$(MOCK_CONFIG) docker-compose -f packaging/rpm/docker-compose.yml build
MOCK_CONFIG=$(MOCK_CONFIG) docker-compose -f packaging/rpm/docker-compose.yml \
run --rm -e RELEASE=$(RELEASE) rpm-builder "make mock-srpm"

mock-rpm: rpm-build/$(RPM_NVR).$(RPM_ARCH).rpm
Expand Down
21 changes: 0 additions & 21 deletions Pipfile

This file was deleted.

0 comments on commit 7cd038b

Please sign in to comment.