Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethWilke committed Mar 2, 2016
0 parents commit 2bc5dde
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
venv/
dist/
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.0.1, March 2nd 2016 -- Initial prototype
14 changes: 14 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2016, Rackspace, Inc. <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

8 changes: 8 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# file GENERATED by distutils, do NOT edit
CHANGES.txt
LICENSE.txt
README.txt
requirements.txt
setup.py
bin/packilog
libpackilog/__init__.py
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include *.txt
recursive-include docs *.txt
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Packilog

A package manager for SystemVerilog.
5 changes: 5 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
========
Packilog
========

A package manager for SystemVerilog.
17 changes: 17 additions & 0 deletions bin/packilog
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/python
import argparse
import os
import json
import libpackilog

argparser = argparse.ArgumentParser(description="Pull in SystemVerilog code.")
argparser.add_argument('-f', '--force', action='store_true')

args = argparser.parse_args()

manifest = None
if os.path.exists('packilog.json'):
manifest = json.load(open('packilog.json'))

if manifest:
libpackilog.pull_in_dependencies(manifest, force=args.force)
52 changes: 52 additions & 0 deletions libpackilog/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import requests
import os


def file_dependency(dependency, force=False):
''' Pull down a file-type dependency '''
if 'source' not in dependency:
print 'source for a file-based dependency was not defined'
return
if 'filename' not in dependency:
print 'filename for a file-based dependency was not defined'
return

source = dependency['source']
filename = dependency['filename']

# Request file
req = requests.get(source)
if req.status_code != 200:
error = "Failed to download dependency source from {0}: {1} {2}"
print error.format(source, req.status_code, req.reason)
return

# Write file
if os.path.exists(filename) and not force:
if req.text == open(filename).read():
print '{0} is up to date'.format(filename)
else:
error = "File {0} already exists, use -f flag to force overwrite"
print error.format(filename)
else:
with open(filename, 'w') as fp:
fp.write(req.text)
print '{0} downloaded from {1}'.format(filename, source)


dependency_handlers = {'file': file_dependency}


def pull_in_dependencies(manifest, force=False):
''' Handles pulling in dependencies '''
# Return immediately if there are no dependencies to handle
if 'dependencies' not in manifest:
return

for dependency in manifest['dependencies']:
if dependency['type'] not in dependency_handlers:
error = "ERROR: There is no handler for dependency type '{0}'."
print error.format(dependency['type'])
return
else:
dependency_handlers[dependency['type']](dependency, force)
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
argparse==1.2.1
requests==2.9.1
wsgiref==0.1.2
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from distutils.core import setup

setup(
name="Packilog",
version="0.0.1",
author="Kenneth Wilke",
author_email="[email protected]",
packages=['libpackilog'],
scripts=['bin/packilog'],
url='https://github.com/KennethWilke/Packilog',
license='LICENSE.txt',
description="A package manager for SystemVerilog.",
long_description=open('README.txt').read(),
install_requires=[
"requests >= 2.9.1"
],
)

0 comments on commit 2bc5dde

Please sign in to comment.