Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full switch to poetry #599

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ current_version = 1.0.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(?P<release>(a|b|rc)?)(?P<releasenumber>\d*)
serialize =
serialize =
{major}.{minor}.{patch}{release}{releasenumber}
{major}.{minor}.{patch}

[bumpversion:part:release]
values =
values =
a
b
rc
Expand All @@ -18,6 +18,8 @@ values =
[bumpversion:file:src/reuse/__init__.py]

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:setup.py]

Expand Down
49 changes: 19 additions & 30 deletions .github/workflows/pythonpackage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ jobs:
strategy:
max-parallel: 10
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
exclude:
- os: macos-latest
python-version: "3.6"

steps:
- uses: actions/checkout@v2
Expand All @@ -30,14 +27,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install reuse
run: |
python setup.py install
pip install poetry
poetry install
- name: Run tests with pytest
run: |
make test
poetry run pytest

pylint:
runs-on: ubuntu-latest
Expand All @@ -46,14 +40,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install poetry
poetry install
- name: Lint with PyLint
run: |
make lint
poetry run pylint src/reuse tests/*.py

black:
runs-on: ubuntu-latest
Expand All @@ -62,14 +56,15 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install poetry
poetry install
- name: Test formatting with black
run: |
make blackcheck
poetry run isort --check src/ tests/
poetry run black .

reuse:
runs-on: ubuntu-latest
Expand All @@ -78,14 +73,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install reuse
run: |
python setup.py install
pip install poetry
poetry install
- name: Test REUSE compliance
run: |
make reuse
Expand All @@ -97,14 +89,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install reuse
run: |
python setup.py install
pip install poetry
poetry install
- name: Create docs with Sphinx
run: |
make docs
23 changes: 0 additions & 23 deletions MANIFEST.in

This file was deleted.

69 changes: 10 additions & 59 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,52 +43,21 @@ clean-docs: ## remove docs build artifacts
rm -fr docs/api/
rm -f docs/*.md

.PHONY: lint
lint: ## check with pylint
pylint src/reuse tests/*.py *.py

.PHONY: blackcheck
blackcheck: ## check with black
black --check .
isort --check src/ tests/ *.py

.PHONY: black
black: ## format with black
isort src/ tests/ *.py
black .

.PHONY: prettier
prettier: ## format with prettier
prettier --write .

.PHONY: reuse
reuse: dist ## check with self
reuse lint
poetry run reuse lint
tar -xf dist/reuse*.tar.gz -C dist/
# This prevents the linter from using the project root as root.
git init dist/reuse*/
cd dist/reuse*/; reuse lint

.PHONY: test
test: ## run tests quickly
py.test

.PHONY: coverage
coverage: ## check code coverage quickly
py.test --cov-report term-missing --cov=src/reuse
poetry run reuse --root dist/reuse*/ lint

.PHONY: docs
docs: ## generate Sphinx HTML documentation, including API docs
$(MAKE) -C docs html

.PHONY: tox
tox: ## run all tests against multiple versions of Python
tox

.PHONY: dist
dist: clean-build clean-pyc clean-docs ## builds source and wheel package
python setup.py sdist
python setup.py bdist_wheel
poetry build
ls -l dist

.PHONY: create-pot
Expand All @@ -102,34 +71,16 @@ update-po-files: create-pot ## update .po files
find ./po -name "*.po" -exec msgmerge --width=79 --output={} {} po/reuse.pot \;

.PHONY: test-release
test-release: dist ## package and upload to testpypi
twine upload --sign -r testpypi dist/*
test-release: ## package and upload to testpypi
poetry config repositories.test-pypi https://test.pypi.org/legacy/
# You may need to use `poetry config pypi-token.test-pypi pypi-YYYYYYYY`
poetry publish --build -r test-pypi

.PHONY: release
release: dist ## package and upload a release
twine upload --sign -r pypi dist/*

.PHONY: install-requirements
install-requirements: ## install requirements
pip install -r requirements.txt

.PHONY: install-dev-requirements
install-dev-requirements: install-requirements ## install dev requirements
pip install -r requirements-dev.txt

.PHONY: uninstall
uninstall: ## uninstall reuse
-pip uninstall -y reuse

.PHONY: install
install: uninstall install-requirements ## install reuse
python setup.py install
release: ## package and upload a release
# You may need to use `poetry config pypi-token.pypi pypi-YYYYYYYY`
poetry publish --build

.PHONY: update-resources
update-resources: ## update spdx data files
python .github/workflows/license_list_up_to_date.py --download

.PHONY: develop
develop: uninstall install-dev-requirements ## install source directory
pre-commit install
python setup.py develop
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
- Source code: <https://github.com/fsfe/reuse-tool>
- PyPI: <https://pypi.python.org/pypi/reuse>
- REUSE: 3.0
- Python: 3.6+
- Python: 3.7+

## Background

Expand Down Expand Up @@ -110,7 +110,7 @@ reuse will then be available in `~/.local/bin`, which must be added to your
To install reuse, you need to have the following pieces of software on your
computer:

- Python 3.6+
- Python 3.7+
- pip

You then only need to run the following command:
Expand Down
14 changes: 8 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# SPDX-FileCopyrightText: 2019 Free Software Foundation Europe e.V. <https://fsfe.org>
# SPDX-FileCopyrightText: 2022 Carmen Bianca Bakker <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Create a base image that has dependencies installed.
FROM alpine:3.13 AS base
FROM alpine:3.16 AS base

RUN apk --no-cache add git mercurial python3

# Build reuse into a virtualenv
FROM base AS build

RUN apk --no-cache add poetry

WORKDIR /reuse-tool
COPY . /reuse-tool/

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY . /reuse-tool/

RUN pip3 install -r requirements.txt
RUN pip3 install .

RUN poetry install --no-dev --no-root
RUN poetry build
RUN pip install dist/*.whl

# Copy over the virtualenv and use it
FROM base
Expand Down
13 changes: 8 additions & 5 deletions docker/Dockerfile-debian
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ RUN apt-get update \
# Build reuse into a virtualenv
FROM base AS build

RUN apt-get update \
&& apt-get install -y python3-poetry \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /reuse-tool
COPY . /reuse-tool/

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY . /reuse-tool/

RUN pip3 install -r requirements.txt
RUN pip3 install .

RUN poetry install --no-dev --no-root
RUN poetry build
RUN pip install dist/*.whl

# Copy over the virtualenv and use it
FROM base
Expand Down
13 changes: 7 additions & 6 deletions docker/Dockerfile-extra
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
# Like normal Dockerfile, but install additional packages on top

# Create a base image that has dependencies installed.
FROM alpine:3.13 AS base
FROM alpine:3.16 AS base

RUN apk --no-cache add git mercurial python3 openssh-client

# Build reuse into a virtualenv
FROM base AS build

RUN apk --no-cache add poetry

WORKDIR /reuse-tool
COPY . /reuse-tool/

ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY . /reuse-tool/

RUN pip3 install -r requirements.txt
RUN pip3 install .

RUN poetry install --no-dev --no-root
RUN poetry build
RUN pip install dist/*.whl

# Copy over the virtualenv and use it
FROM base
Expand Down
4 changes: 2 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@poetry run $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@poetry run $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Loading