update setup.py to be compatible with building "pure" and "binary" wheels

This commit is contained in:
Axel Kohlmeyer 2022-02-24 17:04:16 -05:00
parent d848e50d0d
commit 891d3c8296
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
3 changed files with 40 additions and 1 deletions

3
python/pyproject.toml Normal file
View File

@ -0,0 +1,3 @@
[build-system]
requires = [ "setuptools>=42", "wheel" ]
build-backend = "setuptools.build_meta"

View File

@ -1,6 +1,7 @@
# this only installs the LAMMPS python package
# it assumes the LAMMPS shared library is already installed
from setuptools import setup
from setuptools.dist import Distribution
from sys import version_info
import os,time
LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__))
@ -21,18 +22,49 @@ def get_lammps_version():
t = time.strptime("".join(line[start_pos:end_pos].split()), "%d%b%Y")
return "{}.{}.{}".format(t.tm_year,t.tm_mon,t.tm_mday)
class BinaryDistribution(Distribution):
"""Wrapper to enforce creating a binary package"""
def has_ext_modules(foo):
return True
libpath = os.environ.get("LAMMPS_SHARED_LIB")
if version_info.major >= 3:
pkgs = ['lammps', 'lammps.mliap']
else:
pkgs = ['lammps']
with open("README", "r", encoding="utf-8") as fh:
long_description = fh.read()
if libpath:
pkgdata = {'lammps': [ libpath ]}
bdist = BinaryDistribution
else:
pkgdata = {}
bdist = Distribution
setup(
name = "lammps",
version = get_lammps_version(),
author = "Steve Plimpton",
author_email = "sjplimp@sandia.gov",
url = "https://www.lammps.org",
project_urls = {
"Bug Tracker": "https://github.com/lammps/lammps/issues",
},
description = "LAMMPS Molecular Dynamics Python package",
long_description = long_description,
long_description_content_type = "text/plain",
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)",
"Operating System :: OS Independent",
],
license = "GPL",
packages=pkgs,
packages = pkgs,
package_data = pkgdata,
distclass = bdist,
)

View File

@ -0,0 +1,4 @@
pip
build
wheel
setuptools