Skip to content

Commit

Permalink
MAINT: Replace poetry with setuptools for package management.
Browse files Browse the repository at this point in the history
Poetry is overkill for this project since no deep dependency management
is required (The sole dependency is numpy). This PR removes the use of
poetry and replaces it with functionality introduced in
setuptools>=61.0.0.
  • Loading branch information
zoj613 committed Jun 20, 2022
1 parent fca4a8b commit b7f10e9
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 653 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,26 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Cache/restor poetry lockfile
uses: actions/cache@v2
with:
path: .
key: deps-${{ hashFiles('poetry.lock') }}
restore-keys: deps-

- name: Install Dependencies
- name: Ensure openblas is installed on macOS for numpy
if: matrix.os == 'macOS-10.15'
run: |
brew install openblas
python3 -m pip install --upgrade pip setuptools wheel
pip install -U poetry
poetry install --no-root
OPENBLAS="$(brew --prefix openblas)" pip install -r requirements-dev.txt
- name: Ensure openblas is installed on macOS for numpy-1.19
if: matrix.os == 'macOS-10.15' && matrix.python-version != '3.10'
- name: Install Dependencies for non-mac OS
if: matrix.os != 'macOS-10.15'
run: |
poetry cache clear --all numpy
brew install openblas
OPENBLAS="$(brew --prefix openblas)" poetry run pip install --force-reinstall numpy==1.19.0
python3 -m pip install --upgrade pip setuptools wheel
pip install -r requirements-dev.txt
- name: Run Pytest, report coverage
env:
BUILD_WITH_COVERAGE: true
run: |
poetry run cythonize polyagamma/*.pyx -X linetrace=True
poetry install
poetry run pytest -v --cov-branch --cov=polyagamma tests/ --cov-report=xml
cythonize polyagamma/*.pyx -X linetrace=True
pip install -e .
pytest -v --cov-branch --cov=polyagamma tests/ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
Expand Down
38 changes: 18 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,39 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Cache/restore poetry lockfile
uses: actions/cache@v2
with:
path: .
key: deps-${{ hashFiles('poetry.lock') }}
restore-keys: deps-

- name: Install Dependencies and Cythonize extension
run: |
python3 -m pip install --upgrade pip setuptools wheel poetry cibuildwheel==2.4.0
poetry install --no-root
poetry run cythonize polyagamma/*.pyx
- name: Ensure openblas is installed on macOS for numpy
if: matrix.os == 'macOS-10.15' && matrix.python-version != '3.10'
if: matrix.os == 'macOS-10.15'
run: |
poetry cache clear --all numpy
brew install openblas
OPENBLAS="$(brew --prefix openblas)" poetry run pip install --force-reinstall numpy==1.19.0
python3 -m pip install --upgrade pip setuptools wheel cibuildwheel==2.4.0
OPENBLAS="$(brew --prefix openblas)" pip install -r requirements-dev.txt
- name: Install Dependencies
if: matrix.os != 'macOS-10.15'
run: |
python3 -m pip install --upgrade pip setuptools wheel cibuildwheel==2.4.0
pip install -r requirements-dev.txt
- name: Build wheels
env:
# skip pypy builds
CIBW_SKIP: "pp* *-musllinux_x86_64 cp36-* cp38-win* cp39-win* cp310-win* cp310-manylinux* cp39-macosx* cp310-macosx*"
CIBW_SKIP: "cp36-* *-musllinux_x86_64"
CIBW_ARCHS_LINUX: "auto64"
CIBW_ARCHS_MACOS: "x86_64"
CIBW_ARCHS_WINDOWS: "auto64"
CIBW_TEST_COMMAND: 'python -c "import polyagamma; print(polyagamma.random_polyagamma());"'
# ensure openblas is used in macOS when building numpy
CIBW_BEFORE_ALL_MACOS: brew install openblas
CIBW_ENVIRONMENT_MACOS: OPENBLAS="$(brew --prefix openblas)"
CIBW_TEST_COMMAND: 'cd ~ && python -c "from polyagamma import random_polyagamma; print(random_polyagamma());"'
# skip the wheel build test command for windows OS
CIBW_TEST_SKIP: "*-win*"
BUILD_WHEEL: true
run: poetry run cibuildwheel --output-dir wheelhouse
run: cibuildwheel --output-dir wheelhouse --config-file pyproject.toml

- name: Build source distribution
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: |
poetry build -f sdist
python -m build --sdist
mv dist/*.gz wheelhouse
- name: Store the wheelhouse directory
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prune .github
prune examples
prune scripts
prune tests
34 changes: 12 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
.PHONY: clean cythonize install test sdist wheels

DOCKER_IMAGES=quay.io/pypa/manylinux2010_x86_64 \
quay.io/pypa/manylinux2014_x86_64

define make_wheels
docker pull $(1)
docker container run -t --rm -e PLAT=$(strip $(subst quay.io/pypa/,,$(1))) \
-e BUILD_WHEEL=1 -v $(shell pwd):/io $(1) /io/build_wheels.sh
endef


clean:
rm -Rf build/* dist/* polyagamma/*.c polyagamma/*.so polyagamma/*.html \
polyagamma.egg-info **/*__pycache__ __pycache__ .coverage* \
./**/polyagamma.egg-info **/*__pycache__ __pycache__ .coverage* \

cythonize:
cythonize polyagamma/*.pyx

install: clean cythonize
poetry install
dev:
pip install -r requirements-dev.txt

sdist:
python -m build --sdist

sdist: clean cythonize
poetry build -f sdist
wheel:
python -m build --wheel

test:
test: cythonize
pytest tests/ -vvv

test-cov: clean
poetry run cythonize polyagamma/*.pyx -X linetrace=True
BUILD_WITH_COVERAGE=1 poetry install
poetry run pytest -v --cov-branch --cov=polyagamma tests/ --cov-report=html

wheels: clean cythonize
$(foreach img, $(DOCKER_IMAGES), $(call make_wheels, $(img));)
cythonize polyagamma/*.pyx -X linetrace=True
BUILD_WITH_COVERAGE=1 pip install -e .
pytest -v --cov-branch --cov=polyagamma tests/ --cov-report=html
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,11 @@ or using `conda` with the following command:
```shell
$ conda install -c conda-forge polyagamma
```
Alternatively, once can install from source by cloning the repo. This requires an installation of [poetry][2]
and the following shell commands:
Alternatively, once can install from source with the following shell commands:
```shell
$ git clone https://github.com/zoj613/polyagamma.git
$ cd polya-gamma/
# install dependencies (make sure pip is up to date before hand)
$ poetry install --no-root
$ make install
# add package to python's path
$ export PYTHONPATH=$PWD:$PYTHONPATH
$ cd polyagamma/
$ pip install .
```


Expand Down Expand Up @@ -224,7 +219,7 @@ every call to the function. This overhead can somewhat be mitigated by passing i
generator instance at every call to the `polyagamma` function. To eliminate this overhead,
it is best to use the Cython functions directly. Below is a timing example to demonstrate
the benefit of passing a generator explicitly:
```ipynb
```shell
In [3]: rng = np.random.SFC64(1)

In [4]: %timeit random_polyagamma()
Expand Down Expand Up @@ -256,10 +251,9 @@ All contributions, bug reports, bug fixes, documentation improvements, enhanceme

To submit a PR, follow the steps below:
1) Fork the repo.
2) Install the [poetry][10] package and setup the dev environment with `poetry install --no-root`. All dependencies will be installed.
2) Install and setup the dev environment with `pip install -r requirements-dev.txt` or `make dev`.
3) Start writing your changes, including unittests.
3) Once finished, run `make install` to build the project with the new changes.
4) Once build is successful, run tests to make sure they all pass with `make test`.
4) Run tests to make sure they all pass with `make test`.
5) Once finished, you can submit a PR for review.


Expand All @@ -272,7 +266,6 @@ To submit a PR, follow the steps below:


[1]: ./examples/c_polyagamma.c
[2]: https://python-poetry.org/docs/pyproject/
[3]: https://github.com/zoj613/polyagamma/releases
[4]: https://img.shields.io/pypi/wheel/polyagamma?style=flat-square
[5]: https://img.shields.io/github/v/release/zoj613/polyagamma?include_prereleases&label=pypi&style=flat-square
Expand Down
46 changes: 0 additions & 46 deletions build_wheels.sh

This file was deleted.

0 comments on commit b7f10e9

Please sign in to comment.