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

Pip install #77

Closed
wants to merge 4 commits into from
Closed
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
20 changes: 20 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: PyPI
on: push

jobs:
build-n-publish:
name: Build and publish Python distribution to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Build a binary wheel and a source tarball
run: |
python -mpip install wheel
python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_PASSWORD }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*/.DS_Store
**/__pycache__/*
.DS_Store
**/__pycache__/*
dist/
*.egg-info/
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
recursive-exclude examples *
global-include image.schema
Empty file added ome_ngff/__init__.py
Empty file.
38 changes: 38 additions & 0 deletions ome_ngff/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import json
import os
from typing import Dict

from jsonschema import RefResolver

SCHEMAS_PATH = "schemas"


class LocalRefResolver(RefResolver):
def resolve_remote(self, url: str) -> Dict:
# Use remote URL to generate local path
# e.g. https://ngff.openmicroscopy.org/0.3/schemas/image.schema
rel_path = url.replace("https://ngff.openmicroscopy.org/", "")
curr_dir = os.path.dirname(__file__)
path = os.path.join(curr_dir, "..", rel_path)
path = os.path.normpath(path)
# Load local document and cache it
document = load_json(path)
self.store[url] = document
return document


def load_json(path: str) -> Dict:
with open(path) as f:
document = json.loads(f.read())
return document


def get_schema(version: str, strict: bool = False) -> Dict:
schema_name = "strict_image.schema" if strict else "image.schema"
curr_dir = os.path.dirname(__file__)
# The paths here match the paths in the ngff repo (and public schemas)
path = os.path.join(
curr_dir, "..", version, "schemas", schema_name
)
path = os.path.normpath(path)
return load_json(path)
43 changes: 43 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python

import codecs
import os
from typing import List

from setuptools import setup


def read(fname):
file_path = os.path.join(os.path.dirname(__file__), fname)
return codecs.open(file_path, encoding="utf-8").read()


install_requires: List[List[str]] = []
install_requires += (["jsonschema"],)


setup(
name="ome-ngff",
version="0.0.4dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This version probably expresses best my concerns about the multi-type repository. Turning it into a question, what is our positions on the different versions in this repository? I see at least 3 sources of truth:"

  • the version of the Python library shipping the schemas (0.0.4.dev)
  • the version of the latest schema (currently 0.3.0)
  • the latest repository tag (currently 0.1.3)
    Are these versions expected to be in sync or evolve independently. For all the versions that are in sync, can we use a single-source of truth.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "version of the latest schema" is defined by the most recent top-level directory, currently /0.3/ but I think that doesn't have to match the current version in setup.py, since the directory will never be named *dev. But at each release they should match and correspond to the repo tag (with bumpversion being the single source of truth).

author="The Open Microscopy Team",
url="https://github.com/ome/ngff",
description="OME Next-Generation File Format: spec and schemas",
long_description=read("README.md"),
long_description_content_type="text/markdown",
packages=["ome_ngff"],
py_modules=["ome_ngff"],
# include_package_data = True,
python_requires=">=3.6",
install_requires=install_requires,
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Software Development :: Libraries :: Python Modules",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
"License :: OSI Approved :: BSD License",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another issue to clarify is that the repository is currently marked under the W3C Sofware and Document License - see https://github.com/ome/ngff/blob/main/LICENSE.md

],
tests_require=["pytest"],
)