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

Add PEP 517 support (closes #503) #511

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:

- name: Install dependencies
run: |
pip3 install --upgrade setuptools wheel twine
pip3 install --upgrade setuptools build twine

- name: Work around arm64 support on MacOS
# https://github.com/actions/virtual-environments/issues/2557
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test-smoketests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install numpy

- name: Build scalene
Expand Down
15 changes: 10 additions & 5 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,21 @@ endif

PYTHON_API_VER:=$(shell $(PYTHON) -c 'from pip._vendor.packaging.tags import interpreter_name, interpreter_version; print(interpreter_name()+interpreter_version())')

bdist: vendor-deps
$(PYTHON) setup.py bdist_wheel $(PYTHON_PLAT)
python-deps:
$(PYTHON) -m pip install \
build \
auditwheel

bdist: python-deps vendor-deps
$(PYTHON) -m build --wheel
ifeq ($(shell uname -s),Linux)
auditwheel repair dist/*.whl
$(PYTHON) -m auditwheel repair dist/*.whl
rm -f dist/*.whl
mv wheelhouse/*.whl dist/
endif

sdist: vendor-deps
$(PYTHON) setup.py sdist
sdist: vendor-deps python-deps
$(PYTHON) -m build --sdist

upload: sdist bdist # to pypi
$(PYTHON) -m twine upload dist/*
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ clear-vendor-dirs:
if exist vendor\ (rmdir /Q /S vendor)
mkdir vendor

pkg: vendor/Heap-Layers vendor/printf/printf.cpp
python-deps:
$(PYTHON) -m pip install \
build \
auditwheel

pkg: python-deps vendor/Heap-Layers vendor/printf/printf.cpp
-rm -rf dist build *egg-info
$(PYTHON) setup.py sdist bdist_wheel
$(PYTHON) -m build

upload: pkg # to pypi
$(PYTHON) -m twine upload dist/*
57 changes: 57 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[build-system]
requires = ["setuptools>=61.0.0", "setuptools_scm", "wheel>=0.36.1", "Cython>=0.29.28"]
build-backend = "setuptools.build_meta"
SnoopJ marked this conversation as resolved.
Show resolved Hide resolved

[project]
name = "scalene"
description = "Scalene: A high-resolution, low-overhead CPU, GPU, and memory profiler for Python"
license = {text = "Apache License 2.0"}
keywords = ["performance memory profiler"]
# version is computed by setup.py
dynamic = ["version"]
requires-python = ">= 3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Framework :: IPython",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Software Development",
"Topic :: Software Development :: Debuggers",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
]
readme = "README.md"
authors = [
{name = "Emery Berger", email = "emery@cs.umass.edu"},
{name = "Sam Stern"},
{name = "Juan Altmayer Pizzorno"},
emeryberger marked this conversation as resolved.
Show resolved Hide resolved
]
dependencies = [
"cloudpickle>=1.5.0",
"ipython==7.31.1",
"Jinja2>=3.0.3",
"rich>=10.7.0",
"pynvml>=11.0.0",
"pyperf==2.0.0",
"lxml==4.9.1",
"packaging==20.9",
jaltmayerpizzorno marked this conversation as resolved.
Show resolved Hide resolved
]

[project.urls]
"Source code" = "https://github.com/plasma-umass/scalene"

[project.scripts]
scalene = "scalene.__main__:main"

[tool.setuptools]
packages = ["scalene"]
13 changes: 0 additions & 13 deletions requirements.txt

This file was deleted.

51 changes: 10 additions & 41 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
from setuptools import setup, find_packages
from setuptools.extension import Extension
from scalene.scalene_version import scalene_version
from os import path, environ
from pathlib import Path
import sys
import sysconfig


HERE = Path(__file__).parent.resolve()

# NOTE: sys.path must be modified to make the following import work if the
# package is being built in an isolated environment
sys.path.insert(0, str(HERE))
from scalene.scalene_version import scalene_version


if sys.platform == 'darwin':
import sysconfig
mdt = 'MACOSX_DEPLOYMENT_TARGET'
Expand Down Expand Up @@ -160,52 +169,12 @@ def copy_extensions_to_source(self):
dev_build = ('.dev' + environ['DEV_BUILD']) if 'DEV_BUILD' in environ else ''

setup(
name="scalene",
version=scalene_version + dev_build,
description="Scalene: A high-resolution, low-overhead CPU, GPU, and memory profiler for Python",
keywords="performance memory profiler",
long_description=read_file("README.md"),
long_description_content_type="text/markdown",
url="https://github.com/plasma-umass/scalene",
author="Emery Berger",
author_email="emery@cs.umass.edu",
license="Apache License 2.0",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Framework :: IPython",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Software Development",
"Topic :: Software Development :: Debuggers",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: Apache Software License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows"
],
packages=find_packages(),
cmdclass={
'bdist_wheel': BdistWheelCommand,
'egg_info': EggInfoCommand,
'build_ext': BuildExtCommand,
},
install_requires=[
"wheel>=0.36.1",
"rich>=10.7.0",
"cloudpickle>=1.5.0",
"pynvml>=11.0.0",
"Jinja2>=3.0.3",
],
ext_modules=([get_line_atomic, pywhere, crdp] if sys.platform != 'win32' else []),
setup_requires=['wheel', 'Cython', 'setuptools_scm'],
include_package_data=True,
entry_points={"console_scripts": ["scalene = scalene.__main__:main"]},
python_requires=">=3.8",
)