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

packaging changes #41

Merged
merged 6 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.10" ]
python-version: [ "3.11" ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "pip: Python ${{ matrix.python-version }} coverage"
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
if: "!contains(github.event.head_commit.message, 'Bump version')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: current_version
Expand All @@ -22,11 +22,11 @@ jobs:
current_version: "${{ env.current_version }}"
files: DESCRIPTION
commit_name: Version autobump
commit_email: andrew@friarswood.net
login: virgesmith
commit_email: devops@friarswood.net
login: "${{ secrets.REPO_LOGIN }}"
token: "${{ secrets.REPO_PAT }}"
# part defaults to patch
part: minor
# part: minor
- name: Create dist
run: |
pip install pybind11
Expand Down
33 changes: 3 additions & 30 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: "pip: Python ${{ matrix.python-version }} / ${{ matrix.os }}"
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -44,30 +44,3 @@ jobs:
run: |
python -m pytest

# package:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: "pip: Python 3.11 / ubuntu-latest"
# uses: actions/setup-python@v4
# with:
# python-version: "3.11"
# - name: Bump version
# run: |
# python -m pip install bump2version pybind11
# bump2version patch
# - name: Create dist
# run: |
# python setup.py sdist
# - name: artifacts
# uses: actions/upload-artifact@v3
# with:
# name: dt_utils_${{ matrix.python-version }}
# path: |
# dist
# - name: Publish
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository-url: https://test.pypi.org/legacy/
6 changes: 4 additions & 2 deletions .github/workflows/r-cmd-check.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
on:
push:
branches:
- main
pull_request:
branches:
- main
Expand Down Expand Up @@ -29,7 +31,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
Expand All @@ -46,6 +48,6 @@ jobs:
check-dir: '"check"'
- name: artifacts
if: ${{ matrix.config.r == 'release' && matrix.config.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
path: check
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
.RData
.Ruserdata
build/
node_modules/
stubs/
*.o
*.d
src/*.so
src/*.dll
*.so
*.dll
*.log

dist/
Expand Down
2 changes: 1 addition & 1 deletion R/humanleague.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#'
#' @docType package
#' @name humanleague
NULL
"_PACKAGE"

#' @useDynLib humanleague
#' @importFrom Rcpp sourceCpp
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://opensource.org/licenses/MIT)

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/humanleague)](https://pypi.org/project/humanleague/)
[![PyPI version](https://badge.fury.io/py/humanleague.svg)](https://badge.fury.io/py/humanleague)
[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/humanleague)](https://CRAN.R-project.org/package=humanleague)
[![CRAN Downloads](https://cranlogs.r-pkg.org/badges/grand-total/humanleague?color=black)](https://cran.r-project.org/package=humanleague)

[![DOI](https://zenodo.org/badge/95961787.svg)](https://zenodo.org/badge/latestdoi/95961787)
[![status](https://joss.theoj.org/papers/d5aaf6e1c2efed431c506762622473b4/status.svg)](https://joss.theoj.org/papers/d5aaf6e1c2efed431c506762622473b4)

[![python (pip) build](https://github.com/virgesmith/humanleague/actions/workflows/pip-package.yml/badge.svg)](https://github.com/virgesmith/humanleague/actions/workflows/pip-package.yml/badge.svg)
[![python (pip) build](https://github.com/virgesmith/humanleague/actions/workflows/python-test.yml/badge.svg)](https://github.com/virgesmith/humanleague/actions/workflows/python-test.yml/badge.svg)
[![r-cmd-check](https://github.com/virgesmith/humanleague/actions/workflows/r-cmd-check.yml/badge.svg)](https://github.com/virgesmith/humanleague/actions/workflows/r-cmd-check/badge.svg)

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/430da36db15f46978bfccd1ad3243ae9)](https://www.codacy.com/gh/virgesmith/humanleague/dashboard?utm_source=github.com&utm_medium=referral&utm_content=virgesmith/humanleague&utm_campaign=Badge_Grade)
Expand Down Expand Up @@ -57,10 +57,12 @@ Requires Python 3.9 or newer. The package can be installed using `pip`, e.g.
python -m pip install humanleague --user
```

### Build, install and test (from cloned repo)
#### Development

Fork or clone the repo, then

```bash
pip install -e .
pip install -e .[dev]
pytest
```

Expand Down
6 changes: 5 additions & 1 deletion humanleague/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
from _humanleague import flatten, integerise, ipf, qis, qisi, SobolSequence, __version__
import importlib.metadata

__version__ = importlib.metadata.version("humanleague")

from _humanleague import flatten, integerise, ipf, qis, qisi, SobolSequence
40 changes: 39 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,52 @@
requires = [
"setuptools>=42",
"wheel",
"pybind11>=2.6.0",
"pybind11>=2.10.3",
"pytest"
]

build-backend = "setuptools.build_meta"

[project]
name = "humanleague"
version = "2.3.0"
authors = [
{ name="Andrew Smith", email="[email protected]" },
]
license = {file = "LICENSE.md"}
description = "Microsynthesis using quasirandom sampling and/or IPF"
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]
dependencies = [
"numpy>=1.19.1"
]

[project.optional-dependencies]
dev = [
"pybind11>=2.10.3",
"pytest>=7.1.3",
"mypy>=1.5.0",
"mypy-extensions>=1.0.0",
"ruff>=0.0.286",
"build>=0.10.0"
]

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = [
"tests"
]

[tool.ruff]
select = ["E", "F"]
ignore = ["E501"]

[tool.ruff.per-file-ignores]
"**/__init__.py" = ["F401", "F403"]
11 changes: 0 additions & 11 deletions scripts/create-conda-env.sh

This file was deleted.

8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[bumpversion]
current_version = 2.3.0

[bumpversion:file:pyproject.toml]
search = version = "{current_version}"
replace = version = "{new_version}"

[bumpversion:file:DESCRIPTION]
search = Version: "{current_version}"
replace = version: "{new_version}"

[aliases]
test = pytest

Expand Down
32 changes: 1 addition & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@
from pybind11.setup_helpers import Pybind11Extension, ParallelCompile


def readme():
with open('README.md') as f:
return f.read()


def version():
""" The R file DESCRIPTION in the project root is now the single source of version info """
with open("DESCRIPTION") as fd:
lines = fd.readlines()
for line in lines:
if line.startswith("Version:"):
return line.rstrip().split(":")[1].lstrip()


def source_files():
sources = glob.glob("src/*.cpp")
# can't use compile skips as some files are auto-generated
Expand All @@ -35,7 +21,6 @@ def header_files():

def defines():
return [
("HUMANLEAGUE_VERSION", version()),
("PYTHON_MODULE", None)
]

Expand All @@ -46,7 +31,7 @@ def defines():
sources=source_files(),
include_dirs=["src"],
define_macros=defines(),
depends=["setup.py", "DESCRIPTION", "src/docstr.inl"] + header_files(),
depends=["setup.py", "src/docstr.inl"] + header_files(),
cxx_std=20,
)
]
Expand All @@ -56,23 +41,8 @@ def defines():

setup(
name='humanleague',
version=version(),
description='Microsynthesis using quasirandom sampling and/or IPF',
author='Andrew P Smith',
author_email='[email protected]',
url='http://github.com/virgesmith/humanleague',
long_description=readme(),
long_description_content_type="text/markdown",
packages=["humanleague"],
package_data={"humanleague": ["py.typed", "*.pyi"]},
ext_modules=ext_modules,
install_requires=['numpy>=1.19.1'],
setup_requires=['pybind11>=2.5.0', 'pytest-runner'],
tests_require=['pytest'],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
zip_safe=False,
)
1 change: 1 addition & 0 deletions src/NDArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#if __cplusplus <= 201703l
#include <cstddef>
#endif
#include <cstdint>
#include <cassert>

// The array storage
Expand Down
5 changes: 0 additions & 5 deletions src/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

namespace py = pybind11;

#define STR2(x) #x
#define STR(x) STR2(x)

using namespace py::literals;


Expand Down Expand Up @@ -298,8 +295,6 @@ PYBIND11_MODULE(_humanleague, m) {

m.doc() = module_docstr;

m.attr("__version__") = STR(HUMANLEAGUE_VERSION);

m.def("flatten",
hl::flatten,
flatten_docstr,
Expand Down