Skip to content

Commit

Permalink
Merge pull request #201 from astanin/dev-pep621
Browse files Browse the repository at this point in the history
Merge dev-pep621 - migrate to pyproject.toml
  • Loading branch information
astanin committed Oct 6, 2022
2 parents 9172378 + 0a6554e commit fd0a34c
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 75 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Expand Up @@ -39,6 +39,16 @@ jobs:
- ./venv
key: v1-dependencies-{{ checksum ".circleci/requirements.txt" }}

- run:
name: build wheel
command: |
. venv/bin/activate
python -m build -nwx .
- store_artifacts:
path: dist
destination: dist

- run:
name: run tests
command: |
Expand Down
5 changes: 5 additions & 0 deletions .circleci/requirements.txt
Expand Up @@ -3,3 +3,8 @@ tox
numpy
pandas
wcwidth
setuptools
pip
build
wheel
setuptools_scm
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
/tabulate/version.py

build
dist
.tox
Expand Down
7 changes: 3 additions & 4 deletions HOWTOPUBLISH
@@ -1,8 +1,7 @@
# update contributors and CHANGELOG in README
# tag version release
python3 benchmark.py # then update README
tox -e py33,py34,py36-extra
python3 setup.py sdist bdist_wheel
tox -e py37-extra,py38-extra,py39-extra,py310-extra
python3 -m build -nswx .
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
twine upload dist/*
# tag version release
# bump version number in setup.py in tabulate.py
7 changes: 5 additions & 2 deletions appveyor.yml
Expand Up @@ -17,8 +17,11 @@ environment:
- PYTHON: "C:\\Python310-x64"

install:
# Newer setuptools is needed for proper support of pyproject.toml
- "%PYTHON%\\python.exe -m pip install setuptools --upgrade"
# We need wheel installed to build wheels
- "%PYTHON%\\python.exe -m pip install wheel"
- "%PYTHON%\\python.exe -m pip install wheel --upgrade"
- "%PYTHON%\\python.exe -m pip install build setuptools_scm"
- "%PYTHON%\\python.exe -m pip install pytest numpy pandas"

build: off
Expand All @@ -40,7 +43,7 @@ after_test:
# 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct
# interpreter
#- "build.cmd %PYTHON%\\python.exe setup.py bdist_wheel"
- "%PYTHON%\\python.exe setup.py sdist bdist_wheel"
- "%PYTHON%\\python.exe -m build -nswx ."

artifacts:
# bdist_wheel puts your built wheel in the dist directory
Expand Down
38 changes: 38 additions & 0 deletions pyproject.toml
@@ -0,0 +1,38 @@
[build-system]
requires = ["setuptools>=61.2.0", "wheel", "setuptools_scm[toml]>=3.4.3"]
build-backend = "setuptools.build_meta"

[project]
name = "tabulate"
authors = [{name = "Sergey Astanin", email = "s.astanin@gmail.com"}]
license = {text = "MIT"}
description = "Pretty-print tabular data"
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Software Development :: Libraries",
]
requires-python = ">=3.7"
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/astanin/python-tabulate"

[project.optional-dependencies]
widechars = ["wcwidth"]

[project.scripts]
tabulate = "tabulate:_main"

[tool.setuptools]
packages = ["tabulate"]

[tool.setuptools_scm]
write_to = "tabulate/version.py"
61 changes: 0 additions & 61 deletions setup.py

This file was deleted.

5 changes: 4 additions & 1 deletion tabulate.py → tabulate/__init__.py
Expand Up @@ -22,7 +22,10 @@ def _is_file(f):


__all__ = ["tabulate", "tabulate_formats", "simple_separated_format"]
__version__ = "0.8.11"
try:
from .version import version as __version__ # noqa: F401
except ImportError:
pass # running __init__.py as a script, AppVeyor pytests


# minimum extra space in headers
Expand Down
21 changes: 14 additions & 7 deletions test/test_cli.py
Expand Up @@ -113,7 +113,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):

def test_script_from_stdin_to_stdout():
"""Command line utility: read from stdin, print to stdout"""
cmd = [sys.executable, "tabulate.py"]
cmd = [sys.executable, "tabulate/__init__.py"]
out = run_and_capture_stdout(cmd, input=sample_input())
expected = SAMPLE_SIMPLE_FORMAT
print("got: ", repr(out))
Expand All @@ -126,7 +126,7 @@ def test_script_from_file_to_stdout():
with TemporaryTextFile() as tmpfile:
tmpfile.write(sample_input())
tmpfile.seek(0)
cmd = [sys.executable, "tabulate.py", tmpfile.name]
cmd = [sys.executable, "tabulate/__init__.py", tmpfile.name]
out = run_and_capture_stdout(cmd)
expected = SAMPLE_SIMPLE_FORMAT
print("got: ", repr(out))
Expand All @@ -142,7 +142,7 @@ def test_script_from_file_to_file():
input_file.seek(0)
cmd = [
sys.executable,
"tabulate.py",
"tabulate/__init__.py",
"-o",
output_file.name,
input_file.name,
Expand All @@ -165,7 +165,7 @@ def test_script_from_file_to_file():
def test_script_header_option():
"""Command line utility: -1, --header option"""
for option in ["-1", "--header"]:
cmd = [sys.executable, "tabulate.py", option]
cmd = [sys.executable, "tabulate/__init__.py", option]
raw_table = sample_input(with_headers=True)
out = run_and_capture_stdout(cmd, input=raw_table)
expected = SAMPLE_SIMPLE_FORMAT_WITH_HEADERS
Expand All @@ -178,7 +178,7 @@ def test_script_header_option():
def test_script_sep_option():
"""Command line utility: -s, --sep option"""
for option in ["-s", "--sep"]:
cmd = [sys.executable, "tabulate.py", option, ","]
cmd = [sys.executable, "tabulate/__init__.py", option, ","]
raw_table = sample_input(sep=",")
out = run_and_capture_stdout(cmd, input=raw_table)
expected = SAMPLE_SIMPLE_FORMAT
Expand All @@ -190,7 +190,14 @@ def test_script_sep_option():
def test_script_floatfmt_option():
"""Command line utility: -F, --float option"""
for option in ["-F", "--float"]:
cmd = [sys.executable, "tabulate.py", option, ".1e", "--format", "grid"]
cmd = [
sys.executable,
"tabulate/__init__.py",
option,
".1e",
"--format",
"grid",
]
raw_table = sample_input()
out = run_and_capture_stdout(cmd, input=raw_table)
expected = SAMPLE_GRID_FORMAT_WITH_DOT1E_FLOATS
Expand All @@ -202,7 +209,7 @@ def test_script_floatfmt_option():
def test_script_format_option():
"""Command line utility: -f, --format option"""
for option in ["-f", "--format"]:
cmd = [sys.executable, "tabulate.py", "-1", option, "grid"]
cmd = [sys.executable, "tabulate/__init__.py", "-1", option, "grid"]
raw_table = sample_input(with_headers=True)
out = run_and_capture_stdout(cmd, input=raw_table)
expected = SAMPLE_GRID_FORMAT_WITH_HEADERS
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -9,6 +9,7 @@

[tox]
envlist = lint, py{37, 38, 39, 310}
isolated_build = True

[testenv]
commands = pytest -v --doctest-modules --ignore benchmark.py {posargs}
Expand Down

0 comments on commit fd0a34c

Please sign in to comment.