From 2cebc0cbae7639b7bfa090c5b3e76025d3b04453 Mon Sep 17 00:00:00 2001 From: jlaura <jlaura@asu.edu> Date: Thu, 16 Jun 2016 10:43:41 -0700 Subject: [PATCH] Working on getting the build cooking. --- .coveragerc | 4 +- MANIFEST.in | 2 + build.py | 38 ------------------ conda/build.sh | 0 plio/__init__.py | 15 +------ plio/data/__init__.py | 7 ++++ {data => plio/data}/data.db | Bin plio/io_db.py | 3 +- plio/isis_serial_number.py | 3 +- plio/tests/test_io_db.py | 3 +- setup.cfg | 0 setup.py | 78 ++++++++++++++++++++++-------------- 12 files changed, 66 insertions(+), 87 deletions(-) create mode 100644 MANIFEST.in delete mode 100644 build.py mode change 100644 => 100755 conda/build.sh create mode 100644 plio/data/__init__.py rename {data => plio/data}/data.db (100%) delete mode 100644 setup.cfg diff --git a/.coveragerc b/.coveragerc index b3aa334..38d9271 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,8 +1,8 @@ [run] -source = autocnet +source = plio [report] omit = - plio/ControlNetFileV0002_pb2.py + */ControlNetFileV0002_pb2.py */sqlalchemy_json/* */tests/* exclude_lines = diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f34be04 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include plio/examples * +recursive-include plio/data * diff --git a/build.py b/build.py deleted file mode 100644 index 7d180b4..0000000 --- a/build.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python - -import sys -import os -import sh - -from argparse import ArgumentParser - - -# Initialize -try: - token = os.environ['BINSTAR_KEY'] -except KeyError: - sys.exit("Must set $BINSTAR_KEY") -binstar = sh.Command('binstar').bake(t=token) -conda = sh.Command('conda') - - -def build_and_publish(path, channel): - binfile = conda.build("--output", path).strip() - conda.build(path) - binstar.upload(binfile, force=True, channel=channel) - - -def main(): - parser = ArgumentParser() - parser.add_argument('-p', '--project', required=True) - parser.add_argument('-c', '--channel', required=False, default='main') - parser.add_argument('-s', '--site', required=False, default=None) - parser.add_argument('-b', '--build_dir', required=False, default='conda') - args = parser.parse_args() - - build_and_publish(args.build_dir, channel=args.channel) - return 0 - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/conda/build.sh b/conda/build.sh old mode 100644 new mode 100755 diff --git a/plio/__init__.py b/plio/__init__.py index adf02da..3431520 100755 --- a/plio/__init__.py +++ b/plio/__init__.py @@ -1,18 +1,6 @@ -import os -import plio - __version__ = "0.1.0" - - -def get_data(filename): - packagdir = plio.__path__[0] - dirname = os.path.join(os.path.dirname(packagdir), 'data') - fullname = os.path.join(dirname, filename) - return fullname - # Submodule imports -from . import sqlalchemy_json from . import isis_serial_number from . import io_controlnetwork from . import io_gdal @@ -21,4 +9,5 @@ from . import io_yaml from . import io_db from . import io_hdf from . import utils - +from . import examples +from . import data \ No newline at end of file diff --git a/plio/data/__init__.py b/plio/data/__init__.py new file mode 100644 index 0000000..c8454b8 --- /dev/null +++ b/plio/data/__init__.py @@ -0,0 +1,7 @@ +import os + + +def get_data(filename): + packagedir, _ = os.path.split(__file__) + fullname = os.path.join(packagedir, filename) + return fullname \ No newline at end of file diff --git a/data/data.db b/plio/data/data.db similarity index 100% rename from data/data.db rename to plio/data/data.db diff --git a/plio/io_db.py b/plio/io_db.py index 91bc6ab..6724c06 100644 --- a/plio/io_db.py +++ b/plio/io_db.py @@ -1,8 +1,7 @@ -import plio from sqlalchemy import Column, Integer, String, create_engine, orm from sqlalchemy.ext import declarative -from plio.sqlalchemy_json.alchemy import NestedJsonObject +from .sqlalchemy_json.alchemy import NestedJsonObject Base = declarative.declarative_base() diff --git a/plio/isis_serial_number.py b/plio/isis_serial_number.py index 2a74a59..55a1854 100644 --- a/plio/isis_serial_number.py +++ b/plio/isis_serial_number.py @@ -1,6 +1,6 @@ import warnings import plio -from plio import get_data +from plio.data import get_data from plio.io_db import Translations, StringToMission, setup_db_session from plio.utils import find_in_dict, find_nested_in_dict @@ -27,6 +27,7 @@ def get_isis_translation(label): """ # Instantiate a DB session if not already instantiated if not hasattr(plio, 'data_session'): + print(get_data('data.db')) plio.data_session = setup_db_session(get_data('data.db')) # Grab the label is not already read diff --git a/plio/tests/test_io_db.py b/plio/tests/test_io_db.py index 3204921..82b3933 100644 --- a/plio/tests/test_io_db.py +++ b/plio/tests/test_io_db.py @@ -3,7 +3,7 @@ import unittest from sqlalchemy.orm import session -from plio import get_data +from plio.data import get_data import sys sys.path.insert(0, os.path.abspath('..')) @@ -14,5 +14,6 @@ from .. import io_db class TestDataDB(unittest.TestCase): def test_setup_session(self): + print(get_data('data.db')) data_session = io_db.setup_db_session(get_data('data.db')) self.assertIsInstance(data_session, session.Session) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e69de29..0000000 diff --git a/setup.py b/setup.py index 98241ec..5ff21ec 100644 --- a/setup.py +++ b/setup.py @@ -1,31 +1,49 @@ -from setuptools import setup +from setuptools import setup, find_packages +import plio +#Grab the README.md for the long description +with open('README.rst', 'r') as f: + long_description = f.read() -setup( - name = "plio", - version = "0.1.0", - author = "Jay Laura", - author_email = "jlaura@usgs.gov", - description = ("I/O API to support planetary data formats."), - license = "Public Domain", - keywords = "planetary io", - url = "http://packages.python.org/plio", - packages=['plio'], - install_requires=[ - 'gdal>=2', - 'pvl', - 'protobuf==3.0.0b2', - 'h5py', - 'pandas', - 'sqlalchemy', - 'pyyaml'], - classifiers=[ - "Development Status :: 3 - Alpha", - "Topic :: Utilities", - "License :: Public Domain", - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - ], -) + +VERSION = plio.__version__ + +def setup_package(): + + #import plio + #print(plio.examples.available()) + + setup( + name = "plio", + version = VERSION, + author = "Jay Laura", + author_email = "jlaura@usgs.gov", + description = ("I/O API to support planetary data formats."), + long_description = long_description, + license = "Public Domain", + keywords = "planetary io", + url = "http://packages.python.org/plio", + packages=find_packages(), + include_package_data=True, + zip_safe=False, + install_requires=[ + 'gdal>=2', + 'pvl', + 'protobuf==3.0.0b2', + 'h5py', + 'pandas', + 'sqlalchemy', + 'pyyaml'], + classifiers=[ + "Development Status :: 3 - Alpha", + "Topic :: Utilities", + "License :: Public Domain", + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], + ) + +if __name__ == '__main__': + setup_package() \ No newline at end of file -- GitLab