Skip to content

Commit

Permalink
Merge pull request #58 from mkoeppe/pyproject_metadata
Browse files Browse the repository at this point in the history
Modernize Python metadata
  • Loading branch information
rocky authored Feb 20, 2024
2 parents 903ea1c + 5a4a922 commit 864fe5d
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 57 deletions.
6 changes: 5 additions & 1 deletion mathics_scanner/generate/build_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import os.path as osp
from pathlib import Path

from mathics_scanner.version import __version__
try:
from mathics_scanner.version import __version__
except ImportError:
# When using build isolation
__version__ = "unknown"


def get_srcdir():
Expand Down
58 changes: 58 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[build-system]
requires = [
"setuptools>=61.2",
# needed for building tables for the sdist:
"PyYAML",
"click",
]
build-backend = "setuptools.build_meta"

[project]
name = "Mathics_Scanner"
description = "Character Tables and Tokenizer for Mathics and the Wolfram Language."
dependencies = [
"PyYAML",
"chardet",
"click",
]
requires-python = ">=3.8"
readme = "README.rst"
license = {text = "GPL-3.0-only"}
keywords = ["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"]
maintainers = [
{name = "Mathics Group"},
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Interpreters",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://mathics.org/"

[project.optional-dependencies]
dev = [
"pytest",
]
full = [
"ujson",
]

[project.scripts]
mathics-generate-json-table = "mathics_scanner.generate.build_tables:main"

[tool.setuptools.dynamic]
version = {attr = "mathics_scanner.version.__version__"}
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[metadata]
description_file = README.rst

# Recommended flake8 settings while editing zoom, we use Black for the final
# linting/say in how code is formatted
#
Expand Down
71 changes: 20 additions & 51 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
import subprocess
import sys

import pkg_resources
from setuptools import setup
from setuptools.command.egg_info import egg_info


# Ensure user has the correct Python version
if sys.version_info < (3, 7):
Expand All @@ -50,11 +51,6 @@ def read(*rnames):
return open(osp.join(get_srcdir(), *rnames)).read()


from mathics_scanner.version import __version__

# Get/set __version__ and long_description from files
long_description = read("README.rst") + "\n"

is_PyPy = platform.python_implementation() == "PyPy" or hasattr(
sys, "pypy_version_info"
)
Expand Down Expand Up @@ -85,17 +81,28 @@ def subdirs(root, file="*.*", depth=10):
yield root + "*/" * k + file


class table_building_egg_info(egg_info):
# This runs as part of building an sdist

def finalize_options(self):
"""Run program to create JSON tables"""
build_tables_program = osp.join(
get_srcdir(), "mathics_scanner", "generate", "build_tables.py"
)
print(f"Building JSON tables via {build_tables_program}")
result = subprocess.run([sys.executable, build_tables_program])
if result.returncode:
raise RuntimeError(
f"Running {build_tables_program} exited with code {result.returncode}"
)
super().finalize_options()


setup(
name="Mathics_Scanner",
version=__version__,
cmdclass={"egg_info": table_building_egg_info},
packages=["mathics_scanner", "mathics_scanner.generate"],
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
entry_points={
"console_scripts": [
"mathics-generate-json-table=mathics_scanner.generate.build_tables:main"
]
},
package_data={
"mathics_scanner": [
"data/named-characters.yml",
Expand All @@ -105,44 +112,6 @@ def subdirs(root, file="*.*", depth=10):
"data/ExampleData/*",
]
},
long_description=long_description,
long_description_content_type="text/x-rst",
# don't pack Mathics in egg because of media files, etc.
zip_safe=False,
# metadata for upload to PyPI
maintainer="Mathics Group",
description="Character Tables and Tokenizer for Mathics and the Wolfram Language.",
license="GPL-3.0-only",
url="https://mathics.org/",
keywords=["Mathematica", "Wolfram", "Interpreter", "Shell", "Math", "CAS"],
classifiers=[
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Interpreters",
],
# TODO: could also include long_description, download_url,
)


def build_json_table() -> int:
"""Run program to create JSON tables"""
ROOT_DIR = pkg_resources.resource_filename("mathics_scanner", "")
build_tables_program = osp.join(ROOT_DIR, "generate", "build_tables.py")
print(f"Building JSON tables via f{build_tables_program}")
result = subprocess.run([sys.executable, build_tables_program])
return result.returncode


atexit.register(build_json_table)
2 changes: 0 additions & 2 deletions test/test_general_yaml_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def check_has_attr(attr: str):

def test_yaml_field_names():
for k, v in yaml_data.items():

diff = set(v.keys()) - {
"amslatex",
"ascii",
Expand Down Expand Up @@ -125,7 +124,6 @@ def test_precedence():

def test_unicode_name():
for k, v in yaml_data.items():

# Hack to skip characters that are correct but that doesn't show up in
# unicodedata.name
if "unicode-equivalent-name" not in v:
Expand Down

0 comments on commit 864fe5d

Please sign in to comment.