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

Adding tox config #2

Merged
merged 8 commits into from
Dec 6, 2023
48 changes: 48 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: check
on:
pull_request:

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: test ${{ matrix.py }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os:
- Ubuntu
- MacOs
py:
- 3.11
- '3.10'
- 3.9
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v4
- name: Install tox and dev dependencies
run: python -m pip install -r dev-requirements.txt
- name: Setup Micromamba
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: "latest"
- name: Pick environment to run
run: |
import subprocess; import json; import os
major, minor, impl = json.loads(subprocess.check_output(["python", "-c", "import json; import sys; import platform; print(json.dumps([sys.version_info[0], sys.version_info[1], platform.python_implementation()]));"], universal_newlines=True))
with open(os.environ['GITHUB_ENV'], 'a') as file_handler:
file_handler.write('TOXENV=' + ("py" if impl == "CPython" else "pypy") + ("{}{}".format(major, minor) if impl == "CPython" else "3") + "\n")
shell: python
- name: Setup test suite
run: tox -vv --notest
- name: Run test suite
run: tox --skip-pkg-install
env:
CI_RUN: "yes"
DIFF_AGAINST: HEAD
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include README.md
graft ShortSeq
prune ShortSeq/tests/testdata/
prune *.egg-info/
prune **/__pycache__
global-exclude .DS_Store
global-exclude *.so
4 changes: 2 additions & 2 deletions ShortSeq/__init__.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .short_seq cimport *
from .fast_read cimport *
from .short_seq_util cimport *
from .short_seq_var cimport *
from .short_seq_128 cimport *
from .short_seq_64 cimport *
from .fast_read cimport *
from .util cimport *
4 changes: 3 additions & 1 deletion ShortSeq/short_seq.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ from cpython.unicode cimport PyUnicode_AsASCIIString

from libcpp.vector cimport vector

from .short_seq_util cimport *
from .short_seq_var cimport *
from .short_seq_128 cimport *
from .short_seq_64 cimport *
from .fast_read cimport *
from .util cimport *

from ShortSeq import MAX_64_NT, MAX_128_NT, MAX_VAR_NT

"""
Private dictionary fast-path methods not currently offered by the Cython wrapper
Expand Down
2 changes: 1 addition & 1 deletion ShortSeq/short_seq_128.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .short_seq_util cimport *
from .util cimport *

# Constants
cdef size_t MIN_128_NT
Expand Down
2 changes: 1 addition & 1 deletion ShortSeq/short_seq_64.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .short_seq_util cimport *
from .util cimport *

# Constants
cdef size_t MIN_64_NT
Expand Down
2 changes: 1 addition & 1 deletion ShortSeq/short_seq_var.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .short_seq_util cimport *
from .util cimport *
from cpython.mem cimport PyObject_Calloc, PyObject_Free
from libc.math cimport ceil
from libc.string cimport memcmp
Expand Down
13 changes: 0 additions & 13 deletions ShortSeq/tests/unit_tests_main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import unittest
import time

from pympler.asizeof import asizeof

from ShortSeq import ShortSeq, ShortSeq64, ShortSeq128, ShortSeqVar
from ShortSeq import MIN_VAR_NT, MAX_VAR_NT, MIN_64_NT, MAX_64_NT, MIN_128_NT, MAX_128_NT
Expand Down Expand Up @@ -158,16 +155,6 @@ def test_slice(self):
self.assertEqual(sq[i:], sample[i:])
self.assertEqual(sq[-i:], sample[-i:])

def test_gzip_size_comparison(self):
sample = rand_sequence(MAX_64_NT, no_range=True)
import gzip

gz_bytes = gzip.compress(sample.encode())
print(asizeof(gz_bytes))
print(asizeof(sample.encode()))
print(asizeof(ShortSeq.from_str(sample)))



class ShortSeqVarTests(unittest.TestCase):
"""These tests address the variable length ShortSeq variant (ShortSeqVar)"""
Expand Down
2 changes: 1 addition & 1 deletion ShortSeq/umi/umi.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ShortSeq.short_seq_util cimport *
from ShortSeq.util cimport *
from cpython.mem cimport PyObject_Calloc, PyObject_Free
from cpython.exc cimport PyErr_NoMemory
from libc.math cimport ceil, floor
Expand Down
1 change: 1 addition & 0 deletions ShortSeq/short_seq_util.pxd → ShortSeq/util.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ For SIMD operations.
cdef extern from "x86intrin.h" nogil:
uint64_t _pext_u64 (uint64_t __X, uint64_t __Y)
uint32_t _pext_u32 (uint32_t __X, uint32_t __Y)
uint64_t _popcnt64(uint64_t __X)

"""
A little bit of hackery to allow fast access to the packed hash field of both
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tox<4
tox-conda
cython
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
URL = 'https://github.com/AlexTate/ShortSeq'
AUTHOR = 'Alex Tate'
PLATFORM = 'Unix'
REQUIRES_PYTHON = '>=3.10.0'
REQUIRES_PYTHON = '>3.8, <3.12'
VERSION = '0.0.1'


Expand All @@ -33,8 +33,8 @@
sources=['ShortSeq/short_seq_64.pyx'],
extra_compile_args=short_seq_common_compile_args,
language='c++'),
Extension("ShortSeq.short_seq_util",
sources=['ShortSeq/short_seq_util.pyx'],
Extension("ShortSeq.util",
sources=['ShortSeq/util.pyx'],
extra_compile_args=short_seq_common_compile_args,
language='c++'),
Extension("ShortSeq.fast_read",
Expand All @@ -54,6 +54,7 @@
description=DESCRIPTION,
include_package_data=True,
packages=find_namespace_packages(),
python_requires=REQUIRES_PYTHON,
zip_safe=False,
ext_modules=cythonize(
extensions,
Expand Down
18 changes: 18 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tox]
envlist = ShortSeq-dev-py3{9,10,11}
minversion = 3.27.1
requires = tox-conda

[testenv]
deps = -rrequirements.txt
conda_channels = conda-forge
changedir = {envtmpdir} ; prevent unittest from importing module from the CWD
commands =
python --version
python -m unittest ShortSeq.tests.unit_tests_main

[gh]
python =
3.11: py311
3.10: py310
3.9: py39