From c9116dbb5f39be700adeac9423df1c2dcd58b0d9 Mon Sep 17 00:00:00 2001 From: Mike Gevaert Date: Mon, 28 Feb 2022 13:45:51 +0100 Subject: [PATCH] OSS updates --- .github/workflows/publish-sdist.yml | 27 ++++ .github/workflows/run-tox.yml | 77 +++++++++++ .gitlab-ci.yml | 4 - AUTHORS.txt | 23 ++++ CONTRIBUTING.rst | 23 ++++ LICENSE.txt | 202 ++++++++++++++++++++++++++++ README.rst | 32 +++++ default.nix | 12 -- doc/source/conf.py | 11 +- doc/source/index.rst | 2 +- setup.py | 53 ++++---- tox.ini | 15 +-- voxcell/__init__.py | 1 - voxcell/version.py | 3 - 14 files changed, 417 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/publish-sdist.yml create mode 100644 .github/workflows/run-tox.yml delete mode 100644 .gitlab-ci.yml create mode 100644 AUTHORS.txt create mode 100644 CONTRIBUTING.rst create mode 100644 LICENSE.txt create mode 100644 README.rst delete mode 100644 default.nix delete mode 100644 voxcell/version.py diff --git a/.github/workflows/publish-sdist.yml b/.github/workflows/publish-sdist.yml new file mode 100644 index 0000000..664dc61 --- /dev/null +++ b/.github/workflows/publish-sdist.yml @@ -0,0 +1,27 @@ +name: Publish sdist tarball to PyPI + +on: + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + +jobs: + build-n-publish: + name: Build and publish on PyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Build a source tarball + run: + python setup.py sdist + + - name: Publish distribution package to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/run-tox.yml b/.github/workflows/run-tox.yml new file mode 100644 index 0000000..0217b3d --- /dev/null +++ b/.github/workflows/run-tox.yml @@ -0,0 +1,77 @@ +name: Run all tox python3 + +on: + pull_request: + push: + branches: + - master + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9, 3.10] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip install tox-gh-actions + + - name: Run tox + run: | + tox -etests + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip install tox + + - name: Run tox + run: | + tox -elint + + coverage: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip setuptools + pip install tox + + - name: Run tox + run: | + tox -ecoverage + + - name: Upload to codecov + uses: codecov/codecov-action@v2 + with: + env_vars: OS,PYTHON + fail_ci_if_error: false + files: ./coverage.xml + flags: pytest + verbose: true diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 7a7869e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,4 +0,0 @@ -include: - - project: nse/ci - file: /ci/pipelines/nse.voxcell.yml - diff --git a/AUTHORS.txt b/AUTHORS.txt new file mode 100644 index 0000000..159c7cb --- /dev/null +++ b/AUTHORS.txt @@ -0,0 +1,23 @@ +Maintainer +---------- +* BBP/NSE + +Authors +------- +Aleksei Sanin +Antonel Stefano +Arseny V. Povolotsky +Benoît Coste +Christian O'Reilly +Eilif Muller +Genrich Ivaska +Gianluca Ficarelli +Hugo Dictus +James Dynes +Jean-Denis Courcol +Liesbeth Vanherpe +Luc Guyot +Luis Riquelme +Michael Gevaert +Mike Gevaert +Tom Delemontex diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..18a7950 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,23 @@ +Contributing +============ + +This page includes some guidelines to enable you to contribute to the project. + +Found a bug? +------------ + +If you find a bug in the source code or in using the theme, you can `open an issue `__ on GitHub. +Even better, you can `submit a pull request `__ with a fix. + +Submitting an issue +~~~~~~~~~~~~~~~~~~~ + +Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available. + +We want to fix all the issues as soon as possible, but before fixing a bug we need to reproduce and confirm it. +In order to reproduce bugs we will need as much information as possible, and preferably a sample demonstrating the issue. + +Submitting a pull request (PR) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you wish to contribute to the code base, please open a pull request by following GitHub's guidelines. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..e751f02 --- /dev/null +++ b/README.rst @@ -0,0 +1,32 @@ +Overview +======== + +Libraries for: + +* handling "traits fields" and collections and the logic to assign them. +* volumetric data within NRRD files +* Cell collection access / writer. +* to build, transform and handle fields of vectors and orientations. +* querying `Region hierarchy tree`, such as the one available from the `Allen Institute for Brain Science (AIBS)`_: `Mouse Brain Atlas Ontology's StructureGraph`_ (aka 1.json). + +Installation +============ + +.. code-block:: bash + + git clone https://github.com/BlueBrain/voxcell + cd voxcell + pip install -e . + + +Acknowledgements +================ + +The development of this software was supported by funding to the Blue Brain Project, a research center of the École polytechnique fédérale de Lausanne (EPFL), from the Swiss government’s ETH Board of the Swiss Federal Institutes of Technology. + +For license and authors, see LICENSE.txt and AUTHORS.txt respectively. + +Copyright © 2022 Blue Brain Project/EPFL + +.. _`Allen Institute for Brain Science (AIBS)`: https://alleninstitute.org/what-we-do/brain-science/ +.. _`Mouse Brain Atlas Ontology's StructureGraph`: http://api.brain-map.org/api/v2/structure_graph_download/1.json diff --git a/default.nix b/default.nix deleted file mode 100644 index 7ff32e6..0000000 --- a/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -# Nix development environment -# -# nix-build -I "nixpkgs=https://goo.gl/wTvE5t" -# nix-shell -I "nixpkgs=https://goo.gl/wTvE5t" -# -with import {}; -{ - voxcell = voxcell.overrideDerivation (oldAtr: rec { - version = "DEV_ENV"; - src = ./.; - }); -} diff --git a/doc/source/conf.py b/doc/source/conf.py index b7e6a3d..24e0794 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -15,7 +15,7 @@ import os import sys -import voxcell +from pkg_resources import get_distribution # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -64,16 +64,16 @@ master_doc = 'index' # General information about the project. -project = u'Voxcell' +project = 'voxcell' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = voxcell.__version__ +version = get_distribution(project).version # The full version, including alpha/beta/rc tags. -release = voxcell.__version__ +release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -119,9 +119,6 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'sphinx-bluebrain-theme' -html_theme_options = { - 'metadata_distribution': 'voxcell', -} # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/doc/source/index.rst b/doc/source/index.rst index e0d53ce..32de141 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -3,7 +3,7 @@ Welcome to |name|'s documentation! =================================== -|name| is a library aimed to provide an access to brain atlases stored in `VoxelBrain `_. +|name| is a library aimed to provide an access to brain atlases. In addition, it could be used for: diff --git a/setup.py b/setup.py index 4569fe5..9e54d5f 100644 --- a/setup.py +++ b/setup.py @@ -1,38 +1,22 @@ #!/usr/bin/env python - """Distribution configuration.""" -import importlib.util - from setuptools import setup, find_packages -spec = importlib.util.spec_from_file_location( - "voxcell.version", - "voxcell/version.py", -) -module = importlib.util.module_from_spec(spec) -spec.loader.exec_module(module) -VERSION = module.__version__ - -# keep this to avoid breaking the pip API should be removed in 2.9.0 -SONATA_REQUIRES = [ -] - +with open("README.rst", encoding='utf-8') as f: + README = f.read() setup( name='voxcell', - author='NSE Team', - author_email='bbp-ou-nse@groupes.epfl.ch', - version=VERSION, + author="Blue Brain Project, EPFL", description='Voxcell is a small library to handle probability' ' distributions that have a spatial component and to use them' ' to build collection of cells in space.', - url='https://bbpteam.epfl.ch/documentation/projects/voxcell', - project_urls={ - "Tracker": "https://bbpteam.epfl.ch/project/issues/projects/NSETM/issues", - "Source": "https://bbpgitlab.epfl.ch/nse/voxcell.git", - }, - license='BBP-internal-confidential', + long_description=README, + long_description_content_type="text/x-rst", + url="https://github.com/BlueBrain/voxcell", + download_url="https://github.com/BlueBrain/voxcell", + license='Apache-2', install_requires=[ 'h5py>=3.1.0', 'numpy>=1.9', @@ -41,10 +25,23 @@ 'requests>=2.18', 'scipy>=1.2.0', ], - extras_require={ - 'all': SONATA_REQUIRES, - 'sonata': SONATA_REQUIRES, - }, packages=find_packages(), python_requires='>=3.7', + + setup_requires=[ + 'setuptools_scm', + ], + use_scm_version={ + "local_scheme": "no-local-version", + }, + + classifiers=[ + "Development Status :: 2 - Pre-Alpha", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + ], ) diff --git a/tox.ini b/tox.ini index e4ea3d2..016d15c 100644 --- a/tox.ini +++ b/tox.ini @@ -10,23 +10,14 @@ envlist = lint py{37,38,39} -minversion = 3.18.0 - -# ignore basepython for envs that already specify a version -ignore_basepython_conflict = true +indexserver = + default = https://bbpteam.epfl.ch/repository/devpi/simple [testenv] -basepython=python3.9 -setenv = - PIP_INDEX_URL = https://bbpteam.epfl.ch/repository/devpi/simple extras = all deps = {[base]testdeps} commands = pytest tests {posargs} -[testenv:check-version] -skip_install = true -deps = bbp-nse-ci -commands = do_release.py -p . check-version [testenv:check-packaging] deps = @@ -70,7 +61,7 @@ deps = sphinx-bluebrain-theme commands = make clean - make html SPHINXOPTS=-W + make html SPHINXOPTS=-WT allowlist_externals = make [pycodestyle] diff --git a/voxcell/__init__.py b/voxcell/__init__.py index 038421d..4eb3b7b 100644 --- a/voxcell/__init__.py +++ b/voxcell/__init__.py @@ -3,7 +3,6 @@ from voxcell.cell_collection import CellCollection from voxcell.exceptions import VoxcellError from voxcell.region_map import RegionMap -from voxcell.version import __version__ from voxcell.voxel_data import ( OrientationField, ROIMask, diff --git a/voxcell/version.py b/voxcell/version.py deleted file mode 100644 index 33ceefa..0000000 --- a/voxcell/version.py +++ /dev/null @@ -1,3 +0,0 @@ -"""Voxcell version.""" -VERSION = '3.1.1.dev0' -__version__ = VERSION