Skip to content

Commit

Permalink
Modernize build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed Sep 14, 2024
1 parent 837bd0e commit 903ea70
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 38 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ macOS).
* Clone: ``git clone git@github.com:walles/px.git ; cd px``
* Build and test: ``./tox.sh``
* Run: ``./px.pex``
* To add dependencies, edit ``requirements.txt``

You can also run ``./devbin/tox-in-docker.sh``, which can be used to run Linux
tests on a Mac.
Expand Down
5 changes: 0 additions & 5 deletions devbin/make-executable-zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ python3 -m venv "$ENVDIR"

# shellcheck source=/dev/null
. "$ENVDIR/bin/activate"
pip install -r "$ROOTDIR/requirements.txt"

# Set up file structure in our temporary directory
echo 'import px.px; px.px.main()' >"$WORKDIR/__main__.py"

# The main attraction!
cp -a "$ROOTDIR/px" "$WORKDIR/"

# Dependencies, must match list in requirements.txt
#
# NOTE: This section intentionally left blank

# Tidy up a bit
find "$WORKDIR" -name '*.pyc' -delete

Expand Down
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

27 changes: 10 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,31 @@

import os
import re
import subprocess

from setuptools import setup

from devbin import update_version_py
from px import version

update_version_py.main()
try:
from devbin import update_version_py

git_version = (
subprocess.check_output(["git", "describe", "--dirty"]).decode("utf-8").strip()
)

requirements = None
with open("requirements.txt", encoding="utf-8") as reqsfile:
requirements = reqsfile.readlines()
update_version_py.main()
except ModuleNotFoundError:
print("Devbin not found, assuming source distribution, not updating version.py")

with open(
os.path.join(os.path.dirname(__file__), "README.rst"), encoding="utf-8"
) as fp:
LONG_DESCRIPTION = fp.read()

if not re.match(r"^[0-9]+\.[0-9]+\.[0-9]+$", git_version):
version_for_setuptools = version.VERSION
if not re.match(r"^[0-9]+\.[0-9]+\.[0-9]+$", version_for_setuptools):
# Setuptools wants nice version numbers
git_version = "0.0.0"
version_for_setuptools = "0.0.0"

setup(
name="pxpx",
version=git_version,
version=version_for_setuptools,
description="ps and top for Human Beings",
long_description=LONG_DESCRIPTION,
long_description_content_type="text/x-rst",
Expand All @@ -50,15 +47,11 @@
"Topic :: Utilities",
],
packages=["px"],
install_requires=requirements,
# See: http://setuptools.readthedocs.io/en/latest/setuptools.html#setting-the-zip-safe-flag
zip_safe=True,
setup_requires=[
"pytest-runner",
],
tests_require=[
"pytest",
],
entry_points={
"console_scripts": [
"px = px.px:main",
Expand Down
9 changes: 3 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ minversion = 3.8.0
mypy_version = 1.11.2
ruff_version = 0.6.5
pytest_version = 8.2.2
setuptools_version = 68.2.2
setuptools_version = 74.1.2

envlist=
version.py
Expand Down Expand Up @@ -62,7 +62,6 @@ depends = version.py, ruff-format
deps =
ruff=={[tox]ruff_version}
pytest=={[tox]pytest_version}
-r requirements.txt

# Auto-fix locally but not in CI
commands =
Expand All @@ -83,7 +82,6 @@ deps =
pytest == {[tox]pytest_version}
pytest-avoidance == 0.3.0
python-dateutil >= 2.6.1
-r requirements.txt
commands =
pytest --durations=10 --color=yes tests

Expand Down Expand Up @@ -118,13 +116,12 @@ allowlist_externals =
/bin/rm
deps =
setuptools == {[tox]setuptools_version}
wheel == 0.35.1
build == 1.2.2
commands =
# clean up build/ and dist/ folders
/bin/rm -rf build dist
# build wheel
/bin/rm -rf dist
python setup.py bdist_wheel --bdist-dir {toxinidir}/bdist --dist-dir {toxinidir}/dist
python -m build --outdir {toxinidir}/dist
# Start testing it
/bin/bash -c "pip uninstall --yes pxpx"
/bin/bash -c "pip install {toxinidir}/dist/pxpx-*.whl"
Expand Down

0 comments on commit 903ea70

Please sign in to comment.