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

Add tox envs for building dists via PEP 517 #647

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
78 changes: 77 additions & 1 deletion .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,82 @@ jobs:
- name: Integration testing
if: matrix.os != 'windows'
run: |
python setup.py install
pip install .
proxy --hostname 127.0.0.1 --enable-web-server --pid-file proxy.pid --log-file proxy.log &
./tests/integration/main.sh

tox:
name: ${{ matrix.toxenv }}

runs-on: Ubuntu-latest
strategy:
matrix:
toxenv:
- cleanup-dists,build-dists,metadata-validation
fail-fast: false

env:
PY_COLORS: 1
TOX_PARALLEL_NO_SPINNER: 1
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Switch to using Python v3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc-cache-key-py
run: |
from hashlib import sha512
from sys import version

hash = sha512(version.encode()).hexdigest()
print(f'::set-output name=py-hash-key::{hash}')
shell: python
- name: Get pip cache dir
id: pip-cache
run: >-
echo "::set-output name=dir::$(pip cache dir)"
- name: Set up pip cache
uses: actions/[email protected]
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: >-
${{ runner.os }}-pip-${{
steps.calc-cache-key-py.outputs.py-hash-key }}-${{
hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{
steps.calc-cache-key-py.outputs.py-hash-key
}}-
${{ runner.os }}-pip-
- name: Install tox
run: >-
python -m
pip install
--user
tox

- name: Grab the source from Git
uses: actions/checkout@v2

- name: >-
Pre-populate tox envs: `${{ env.TOXENV }}`
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
--notest
- name: >-
Run tox envs: `${{ env.TOXENV }}`
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
__author__ = 'Abhinav Singh'
__author_email__ = '[email protected]'
__homepage__ = 'https://github.com/abhinavsingh/proxy.py'
__download_url__ = '%s/archive/master.zip' % __homepage__
__download_url__ = '%s/archive/develop.zip' % __homepage__
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How I manage releases currently:

  1. Release happen from master branch
  2. Develop is used for cutting edge version

At some point, I'll create a PR from develop -> master, which contain all changes between pip releases.

I ideally don't recommend folks to install from develop, if they are looking for stability. Even though develop is tested and I use to everyday locally, it may contain untested code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize. I thought maybe you forgot to update this.

__license__ = 'BSD'

if __name__ == '__main__':
Expand All @@ -33,7 +33,7 @@
long_description_content_type='text/markdown',
download_url=__download_url__,
license=__license__,
python_requires='!=2.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*',
python_requires='>= 3.6',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

zip_safe=False,
packages=find_packages(exclude=['tests', 'tests.*']),
package_data={'proxy': ['py.typed']},
Expand Down
61 changes: 61 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,69 @@
[tox]
envlist = py35,py36,py37,py38
webknjaz marked this conversation as resolved.
Show resolved Hide resolved
isolated_build = true
minversion = 3.21.0

[testenv]
deps =
-rrequirements.txt
-rrequirements-testing.txt
command = pytest


[dists]
setenv =
PEP517_OUT_DIR = {env:PEP517_OUT_DIR:{toxinidir}{/}dist}


[testenv:cleanup-dists]
description =
Wipe the the `{env:PEP517_OUT_DIR}{/}` folder
usedevelop = false
skip_install = true
deps =
setenv =
{[dists]setenv}
commands =
{envpython} -c \
'import os, shutil, sys; dists_dir = os.getenv("PEP517_OUT_DIR"); shutil.rmtree(dists_dir, ignore_errors=True); sys.exit(os.path.exists(dists_dir))'


[testenv:build-dists]
description =
Build non-universal dists and put them into
the `{env:PEP517_OUT_DIR}{/}` folder
depends =
cleanup-dists
isolated_build = true
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
usedevelop = false
skip_install = true
deps =
build >= 0.7.0, < 0.8.0
passenv =
PEP517_BUILD_ARGS
setenv =
{[dists]setenv}
commands =
{envpython} -m build \
--outdir '{env:PEP517_OUT_DIR}{/}' \
{posargs:{env:PEP517_BUILD_ARGS:}} \
'{toxinidir}'


[testenv:metadata-validation]
description =
Verify that dists under the `{env:PEP517_OUT_DIR}{/}` dir
have valid metadata
depends =
build-dists
deps =
twine
usedevelop = false
skip_install = true
setenv =
{[dists]setenv}
commands =
{envpython} -m twine check \
--strict \
{env:PEP517_OUT_DIR}{/}*