From 6763886004c7bc51dcdbde3340f260723a364f5a Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Sun, 4 Aug 2024 13:06:17 -0400 Subject: [PATCH 1/2] CI: remove unused Travis CI configuration --- .travis.yml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ee97400..0000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -language: python - "3.7" - -# Maybe everything shoulb be packed in a `job` that states `include:` `if:` with some condition -before_install: - # Install Minconda - - wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - - chmod +x miniconda.sh - - "./miniconda.sh -b" - - export PATH=/home/travis/miniconda3/bin:$PATH - - conda update --yes conda - # Not sure what this does, I copy pasted it from a tutorial - - sudo rm -rf /dev/shm - - sudo ln -s /run/shm /dev/shm - -install: - - conda install --yes python="3.7" numpy scipy cython h5py typing numba - - pip install Sphinx sphinxcontrib-websupport sphinx_bootstrap_theme numpy-groupies - -script: - # Build documentation - - cd doc - - make html - - cd .. - -deploy: - # Automatically upload docs to github pages for master commits - - provider: pages - skip_cleanup: true - local_dir: built/html - github_token: $GH_TOKEN - on: - branch: master - - provider: pypi - user: slinnarsson - password: - secure: YfGbHN++dIAe9PIVb+2Y2pqLke69/59AgLzGBghwchE6/bz77iYHeYr471ZF1uB2hEE207HwYdA2355HHIMLKALG6RIN3Y4YdWSc6OzwggqCAeufDgvwTchSQmReWj/aOuzpwcw6mDw07yl7IX8Snzo51n8jrj+xW551WM4/fczDE2ZnleyN3HMHT7+KwDuQeSRJFAzhmU+Rw3S7qg0Z8nzA7A4BSRnOYoXqagOmPLUXty1ZItEkd2rFBVCkZOM0u+k6PLIBVUDv8Zor0OLNzcQh87DnT5gUFWL1WV8HpZQBqcK8XfujZYBRpUX+Kt7X5j8dUfh1I0+RC6qr1WpGV017by8XW2Ok+Gcyoet4HjNvY5rMGxQ6S3Et1VD2rgoJocGGcjOGgIRMv2SaOjHUmV2vK6VDMCHJgXG5K9Y5YjuDIWBO9uMBoUFG9Gmap4rqmC5DWLq4vNpM8JY7zPheFBmjw3QvQeWKKD0NL8I0RNpQPSJqkaaDyas+xuC0g2nKLVwdz7aIYb5CQNmvOfvSO61i0CFZ6SDZTEkXvHIJk+bD9E4hbbMRPZUHhnOkJ0ZIspD5KazvdQiKTYwpfFSyZeV/yCqcJcwPr39gRgpIoCPp8pqenoB/R08okyBlszq+QTPqSvhoWpaPpifSv90e9W5BKKxDjtpJJ66eIZxvZ/8= - on: - tags: true From fca0d7738eb7eb2877097388c81048a1c2d0cf4b Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Sun, 4 Aug 2024 14:28:34 -0400 Subject: [PATCH 2/2] CI: initial testing with GitHub Actions - Set maximum allowed version for NumPy in order to ensure existing code works. - There are problems with older NumPy and Python 3.12 - Fix file argument opening for h5py 3 - Fix installation and packaging for latest versions of setuptools, build, and twine --- .github/workflows/ci.yml | 22 ++++++ .github/workflows/test_and_package.yml | 97 ++++++++++++++++++++++++++ setup.py | 7 +- tests/test_file_attribute_manager.py | 2 +- 4 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/test_and_package.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f175782 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +--- +name: ci + +# yamllint disable-line rule:truthy +on: + push: + pull_request: + +concurrency: + group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} + cancel-in-progress: true + +jobs: + test-and-package: + uses: ./.github/workflows/test_and_package.yml + secrets: inherit + all: + needs: [test-and-package] + runs-on: ubuntu-latest + steps: + - name: Success + run: "true" diff --git a/.github/workflows/test_and_package.yml b/.github/workflows/test_and_package.yml new file mode 100644 index 0000000..8918931 --- /dev/null +++ b/.github/workflows/test_and_package.yml @@ -0,0 +1,97 @@ +--- +# yamllint disable rule:line-length +name: run tests and create installable packages + +# yamllint disable-line rule:truthy +on: + workflow_dispatch: + workflow_call: + +concurrency: + group: test-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} + cancel-in-progress: true + +jobs: + + run-tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: + - 3.8 + - 3.9 + - "3.10" + - 3.11 + # 3.12 has problems with older NumPy + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install test dependencies + run: | + python -m pip install -U setuptools pip + python -m pip install pytest pytest-cov + - name: Install package + run: | + python -m pip install . + - name: Test + run: | + python -m pytest --cov=loompy + - name: Install pypa/build + run: | + python -m pip install build + - name: Build distribution packages (binary wheel and source tarball) + run: | + python -m build + - name: Check packages with twine + run: | + python -m pip install twine + python -m twine check dist/* + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + if: matrix.python-version == '3.11' + + # We check the installation using all Python versions using the packages + # created from a single version, since the packages are platform and version + # independent. + check-installation: + needs: + - run-tests + runs-on: ubuntu-latest + strategy: + matrix: + install-method: [wheel, source] + python-version: + - 3.8 + - 3.9 + - "3.10" + - 3.11 + # 3.12 has problems with older NumPy + steps: + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Download the distribution packages + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Update environment + run: | + python -m pip install -U setuptools pip + - name: Install from wheel + run: | + python -m pip install dist/*.whl + if: matrix.install-method == 'wheel' + - name: Install from source + run: | + python -m pip install dist/*.tar.gz + if: matrix.install-method == 'source' + - name: Check installation + run: | + cd ~ + python -c 'import loompy; print(loompy.__version__)' diff --git a/setup.py b/setup.py index 292ff71..5016ff4 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +from pathlib import Path from setuptools import find_packages, setup # First update the version in loompy/_version.py, then: @@ -17,8 +18,8 @@ name="loompy", version=__version__, packages=find_packages(), - python_requires='>=3.6', - install_requires=['h5py', 'numpy', 'scipy', 'setuptools', 'numba', 'click', "numpy-groupies"], + python_requires='>=3.6,<3.12', + install_requires=['h5py', 'numpy<1.24', 'scipy', 'setuptools', 'numba', 'click', "numpy-groupies"], entry_points=''' [console_scripts] loompy=loompy.commands:cli @@ -27,6 +28,8 @@ author="Linnarsson Lab", author_email="sten.linnarsson@ki.se", description="Work with Loom files for single-cell RNA-seq data", + long_description=Path("README.md").read_text(encoding="utf-8"), + long_description_content_type="text/markdown", license="BSD", keywords="loom omics transcriptomics bioinformatics", url="https://github.com/linnarsson-lab/loompy", diff --git a/tests/test_file_attribute_manager.py b/tests/test_file_attribute_manager.py index b5e5fd8..e6948a2 100644 --- a/tests/test_file_attribute_manager.py +++ b/tests/test_file_attribute_manager.py @@ -15,7 +15,7 @@ def setUp(self): f = NamedTemporaryFile(suffix="loom") f.close() self.filename = f.name - self.file = h5py.File(f.name) + self.file = h5py.File(f.name, mode="w") self.file.attrs["arr"] = self.VALUE_IN_FILE def tearDown(self):