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

modernized build #2070

Merged
merged 3 commits into from
Apr 16, 2022
Merged
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
20 changes: 8 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ jobs:
python-version: ${{ matrix.python }}
- name: Update pip
run: |
pip install -U wheel
pip install -U setuptools
python -m pip install -U pip
- name: Get pip cache dir
id: pip-cache
run: echo "::set-output name=dir::$(pip cache dir)"
run: echo "::set-output name=dir::$(python -m pip cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.py') }}
key: pip|${{ runner.os }}|${{ matrix.python }}|${{ hashFiles('setup.cfg') }}
- name: set full Python version in PY env var
# See https://pre-commit.com/#github-actions-example
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
- run: pip install tox codecov
- run: tox -e ${{ matrix.tox }}
- run: python -m pip install tox
- run: python -m tox -e ${{ matrix.tox }}

verify_docker_build:
name: Always - Docker verify, push to tag 'master' if on master
Expand Down Expand Up @@ -121,11 +119,10 @@ jobs:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
python -m pip install --upgrade pip build
- name: Build + set TAG env var for later use
run: |
python setup.py sdist bdist_wheel
python -m build
echo "TAG=${GITHUB_REF#refs/*/}" | tee -a $GITHUB_ENV
- name: Publish tagged version to PyPI
uses: pypa/gh-action-pypi-publish@master
Expand Down Expand Up @@ -159,12 +156,11 @@ jobs:
- name: Install dependencies
if: ${{ env.NOT_MERGE_COMMIT == '' }}
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
python -m pip install --upgrade pip build
- name: Build
if: ${{ env.NOT_MERGE_COMMIT == '' }}
run: |
python setup.py sdist bdist_wheel
python -m build
- name: Publish prerelease version to PyPI
if: ${{ env.NOT_MERGE_COMMIT == '' }}
uses: pypa/gh-action-pypi-publish@master
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.9-slim as base

FROM base as builder
RUN apt update && apt install -y git
RUN apt-get update && apt-get install -y git
cyberw marked this conversation as resolved.
Show resolved Hide resolved
# there are no wheels for some packages (geventhttpclient?) for arm64/aarch64, so we need some build dependencies there
RUN if [ -n "$(arch | grep 'arm64\|aarch64')" ]; then apt install -y --no-install-recommends gcc python3-dev; fi
RUN python -m venv /opt/venv
Expand Down
2 changes: 1 addition & 1 deletion locust/test/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ def tick(self):
0, test_shape.get_current_user_count(), "Shape is not seeing stopped runner user count correctly"
)
self.assertDictEqual(master.reported_user_classes_count, {"FixedUser1": 0, "FixedUser2": 0, "TestUser": 0})
sleep(0.5)
sleep(1.0)
cyberw marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(STATE_STOPPED, master.state)

def test_distributed_shape_with_stop_timeout(self):
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 120

[tool.setuptools_scm]
write_to = "locust/_version.py"
local_scheme = "no-local-version"
18 changes: 17 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = Developer friendly load testing framework
long_description = file: README.md
long_description_content_type = text/markdown
license = MIT
obsoletes-dist = locustio
obsoletes_dist = locustio
cyberw marked this conversation as resolved.
Show resolved Hide resolved
classifiers =
Topic :: Software Development :: Testing :: Traffic Generation
Development Status :: 5 - Production/Stable
Expand All @@ -35,6 +35,22 @@ packages = find:
include_package_data = true
zip_safe = false
python_requires = >= 3.6
install_requires =
gevent >=20.12.1
flask >=2.0.0
Werkzeug >=2.0.0
requests >=2.23.0
msgpack >=0.6.2
pyzmq >=22.2.1
geventhttpclient >=1.5.1
ConfigArgParse >=1.0
psutil >=5.6.7
Flask-BasicAuth >=0.2.0
Flask-Cors >=3.0.10
roundrobin >=0.0.2
typing-extensions >=3.7.4.3
Jinja2 <3.1.0
pywin32;platform_system=='Windows'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was unable to get it working with pywin32 being an extras_require as in the setup.py case, however this should be the same(?). pywin32 only needed when running on windows.
https://setuptools.pypa.io/en/latest/userguide/dependency_management.html#platform-specific-dependencies


[options.packages.find]
exclude =
Expand Down
44 changes: 3 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,4 @@
import ast
import os
import re
import sys
# kept for compability, https://setuptools.pypa.io/en/latest/setuptools.html?highlight=setuptools.setup()#setup-cfg-only-projects
import setuptools

from setuptools import find_packages, setup

ROOT_PATH = os.path.abspath(os.path.dirname(__file__))

setup(
name="locust",
install_requires=[
"gevent>=20.12.1",
"flask>=2.0.0",
"Werkzeug>=2.0.0",
"requests>=2.23.0",
"msgpack>=0.6.2",
"pyzmq>=22.2.1",
"geventhttpclient>=1.5.1",
"ConfigArgParse>=1.0",
"psutil>=5.6.7",
"Flask-BasicAuth>=0.2.0",
"Flask-Cors>=3.0.10",
"roundrobin>=0.0.2",
"typing-extensions>=3.7.4.3",
"Jinja2<3.1.0",
],
test_suite="locust.test",
tests_require=[
"cryptography",
"mock",
"pyquery",
],
extras_require={
":sys_platform == 'win32'": ["pywin32"],
},
use_scm_version={
"write_to": "locust/_version.py",
"local_scheme": "no-local-version",
},
setup_requires=["setuptools_scm<=6.0.1"],
)
setuptools.setup()
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[tox]
skipsdist = True
envlist =
flake8
black
Expand All @@ -24,7 +25,8 @@ allowlist_externals =
timeout
grep
commands =
coverage run -m unittest discover []
python3 -m pip install .
cyberw marked this conversation as resolved.
Show resolved Hide resolved
python3 -m coverage run -m unittest discover []
bash -ec 'PYTHONUNBUFFERED=1 timeout 2s python3 examples/debugging.py >out.txt 2>err.txt || true'
grep -qm 1 '/hello' out.txt
bash -ec '! grep . err.txt' # should be empty
Expand Down