Skip to content

Commit

Permalink
build: put python source in src/mt2 to avoid import confusion (#58)
Browse files Browse the repository at this point in the history
* build: put python source in src/mt2 to avoid import confusion

* optional: shared object only shows up within mt2 installation area

* Remove unnecessary files from source build

* Don't need source dir as an include dir

* Actually none of this is needed any more :)

* Bump version to 1.2.2

* Fix

* Add useful Makefile targets for testingwheel locally

* Also remove testdir

---------

Co-authored-by: Tom Gillam <[email protected]>
  • Loading branch information
lgray and tpgillam authored Aug 29, 2024
1 parent cf21dd9 commit 46dc153
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 17 deletions.
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
History
=======

1.2.2 (2024-08-29)
------------------
* Fix wheel builds

1.2.1 (2024-08-05)
------------------

Expand Down
6 changes: 2 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
include *.rst
include Makefile
recursive-include examples *.ipynb
recursive-include src *.h
exclude examples/*
include src/_mt2/*.h
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ clean: clean-build clean-pyc clean-venv
.PHONY: clean-build
clean-build:
rm -rf build/
rm -rf testdir/
rm -rf dist/
rm -rf .eggs/
rm -rf src/*.egg-info/
find . -name '*.egg-info' -delete
find . -name '*.egg' -delete
find . -name '*.so' -delete

.PHONY: clean-pyc
clean-pyc:
Expand All @@ -27,3 +30,21 @@ clean-venv:
.PHONY: test
test: install
uv run --locked python -m unittest discover tests

.PHONY: build
build: install
@# Slightly disgusting; just installing the `build` module into the working venv and
@# removing after we're done.
uv pip install build
uv run python -m build
uv pip uninstall build

.PHONY: test_wheel
test_wheel: clean build
@# Build the wheel, then install it and check that we can import it.
rm -rf testdir && mkdir testdir
cd testdir && uv venv
cd testdir && uv pip install `find ../dist/ -name *.whl`
testdir/.venv/bin/python -c "from mt2 import mt2"
rm -r testdir

7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "mt2"
version = "1.2.1"
version = "1.2.2"
description = "Stransverse mass computation as a numpy ufunc."
authors = [
{ name = "Tom Gillam", email = "[email protected]" },
Expand Down Expand Up @@ -29,8 +29,3 @@ urls = { Homepage = "https://github.com/tpgillam/mt2" }
requires = ["setuptools>=61.0", "numpy"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include = ["mt2*"]

[tool.setuptools.package-data]
mt2 = ["src/*.h", "src/*.cpp"]
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import numpy

__version__ = "1.2.1"
__version__ = "1.2.2"

setup(
ext_modules=[
Extension(
"_mt2",
["src/main.cpp"],
"mt2._mt2",
["src/_mt2/main.cpp"],
define_macros=[
# Pass in the version info so we can expose it in the extension.
("VERSION_INFO", __version__),
Expand All @@ -19,7 +19,7 @@
# citation information elsewhere.
("DISABLE_COPYRIGHT_PRINTING", "1"),
],
include_dirs=[numpy.get_include(), "src"],
include_dirs=[numpy.get_include()],
language="c++",
extra_compile_args=["-std=c++11"],
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions mt2/__init__.py → src/mt2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import numpy

from _mt2 import mt2_lester_ufunc, mt2_tombs_ufunc # pyright: ignore [reportMissingImports]
from mt2._mt2 import mt2_lester_ufunc, mt2_tombs_ufunc # pyright: ignore [reportMissingImports]

__version__ = "1.2.1"
__version__ = "1.2.2"

__all__ = ["mt2", "mt2_arxiv", "mt2_ufunc"]

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _mt2 import mt2_lally_ufunc, mt2_lester_ufunc, mt2_tombs_ufunc
from mt2._mt2 import mt2_lally_ufunc, mt2_lester_ufunc, mt2_tombs_ufunc


def mt2_lally(*args, desired_precision_on_mt2=0.0, out=None):
Expand Down

0 comments on commit 46dc153

Please sign in to comment.