-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from dangle/framework
Added initial project framework.
- Loading branch information
Showing
15 changed files
with
370 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# IPython Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
|
||
# virtualenv | ||
venv/ | ||
ENV/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# Sublime project settings | ||
.sublimelinterrc | ||
*.sublime-project | ||
*.sublime-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,10 @@ | ||
language: python | ||
sudo: false | ||
python: | ||
- '2.7' | ||
- '3.3' | ||
- '3.4' | ||
- '3.5' | ||
- '3.6' | ||
install: | ||
- pip install tox-travis | ||
script: | ||
- tox | ||
deploy: | ||
provider: pypi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Za Wilgustus | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,59 @@ | ||
A replacement for Python virtualenv that uses a container-based environment manager that conforms to virtualenv's interface. | ||
contain | ||
======= | ||
|
||
The Contain Project Contract: | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|PyPI| |Python Versions| |Build Status| |Coverage Status| |Code Quality| | ||
|
||
I think contain has a contract with the User that says: | ||
*Automate the creation and management of development containers.* | ||
|
||
You give me a directory structure with source code, and meta-source code | ||
``contain`` makes it easy to create and share reusable container images that | ||
provide a consistent, yet familiar, development environment. | ||
|
||
I'll give you: | ||
``contain`` was inspired by Python's virtualenv_ package. Like | ||
``virtualenv``, ``contain`` separates project dependencies from packages | ||
installed on the development machine but additionally separates your project's | ||
operating system dependencies to guarantee that all developers are using a | ||
consistent set of dependencies. | ||
|
||
an image config (including entrypoint and runner) | ||
an image | ||
I'll run that image and give you: | ||
Unlike with traditional container-based approaches, ``contain`` creates an | ||
additional layer to make the use of the development container more seamless. | ||
``contain`` tries to be as invisible to the user as possible, by using the | ||
same shell, development tools, and configuration already defined by the user. | ||
``contain`` should never feel like it hinders or slows the development process. | ||
|
||
a contained environment for that source code you gave me. | ||
If the User gives contain an empty directory contain breaks saying: You violated our contract. If the User gives contain a directory with 0 files that contain recognizes... contain breaks saying, you violated our contract. | ||
|
||
Installation | ||
------------ | ||
|
||
Currently, the easiest method is to install it using pip: | ||
|
||
.. code-block:: bash | ||
$ pip3 install contain | ||
In the future, there will be operating system packages to simplify the | ||
installation of ``contain``. | ||
|
||
|
||
Basic Usage | ||
----------- | ||
|
||
.. code-block:: bash | ||
$ cd path/to/project | ||
$ contain | ||
.. _virtualenv: https://github.com/pypa/virtualenv | ||
|
||
|
||
.. |Build Status| image:: https://travis-ci.org/contains-io/contain.svg?branch=development | ||
:target: https://travis-ci.org/contains-io/contain | ||
.. |Coverage Status| image:: https://coveralls.io/repos/github/contains-io/contain/badge.svg?branch=development | ||
:target: https://coveralls.io/github/contains-io/contain?branch=development | ||
.. |PyPI| image:: https://img.shields.io/pypi/v/contain.svg | ||
:target: https://pypi.python.org/pypi/contain/ | ||
.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/contain.svg | ||
:target: https://pypi.python.org/pypi/contain/ | ||
.. |Code Quality| image:: https://api.codacy.com/project/badge/Grade/f6306cdc0276428fbbbed44386aeb1b6 | ||
:target: https://www.codacy.com/app/contains-io/contain?utm_source=github.com&utm_medium=referral&utm_content=contains-io/contain&utm_campaign=Badge_Grade |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Contains the top-level contain command and helper methods. | ||
Functions: | ||
contain: Run the given subcommand. If no subcommand is given, activate the | ||
current directory. | ||
""" | ||
|
||
from . import ( | ||
activate, | ||
init | ||
) | ||
|
||
|
||
def contain(): | ||
"""usage: contain [PROJECT] | ||
""" | ||
Usage: | ||
contain [--log-level <level> | --debug | --verbose] [<project>] | ||
contain [--log-level <level> | --debug | --verbose] | ||
[<command> [<args>...]] | ||
contain (-h | --help) | ||
contain (-V | --version) | ||
Options: | ||
-h, --help Display this help message and exit. | ||
-V, --version Display the version and exit. | ||
-d, --debug Set the log level to DEBUG. | ||
-v, --verbose Set the log level to INFO. | ||
--log-level <level> Set the log level to one of DEBUG, INFO, WARN, or | ||
ERROR. | ||
'{command} help -a' lists all available subcommands. | ||
See '{command} help <command>' for more information on a specific command. | ||
""" | ||
init.init() | ||
activate.activate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,36 @@ | ||
def activate(): | ||
"""usage: contain activate [PROJECT] | ||
# -*- coding: utf-8 -*- | ||
"""Contains the activate command and helper methods. | ||
Functions: | ||
activate: Activate the given project. If no project name is given, activate | ||
the current directory. | ||
""" | ||
|
||
import os | ||
import pathlib | ||
|
||
from .types import ProjectId | ||
|
||
|
||
def activate(project: ProjectId = None): | ||
""" | ||
Usage: | ||
contain activate [<project>] | ||
Arguments: | ||
<project> The name of the project to activate. | ||
""" | ||
_get_project_path(project) | ||
|
||
|
||
def _get_project_path(project: ProjectId): | ||
"""Find the path of the project based on the project name.""" | ||
if not project: | ||
return pathlib.Path(os.getcwd()) | ||
default_path = os.environ.get('CONTAINED_PROJECTS_PATH', '.') | ||
projects_path = pathlib.Path(default_path) | ||
matches = (p for p in projects_path.iterdir() if p == project) | ||
project_path = next(matches, None) | ||
if not project_path: | ||
raise ValueError('Unknown project "{}"'.format(project)) | ||
return pathlib.Path(project_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
def initialize(): | ||
"""usage: contain init [PROJECT] | ||
# -*- coding: utf-8 -*- | ||
"""Contains the init command and helper methods. | ||
Functions: | ||
init: Initialize the current directory as a project and create the | ||
contain metasource. | ||
""" | ||
|
||
|
||
def init(): | ||
""" | ||
Usage: | ||
contain init | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Contains types used by the contain application. | ||
Types: | ||
ProjectId: A validation type for project identifiers. | ||
""" | ||
|
||
from typingplus.types import Length | ||
|
||
|
||
ProjectId = Length[str, 1:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
A replacement for Python virtualenv that uses a container-based environment manager that conforms to virtualenv's interface. | ||
|
||
The Contain Project Contract: | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
I think contain has a contract with the User that says: | ||
|
||
You give me a directory structure with source code, and meta-source code | ||
|
||
I'll give you: | ||
|
||
an image config (including entrypoint and runner) | ||
an image | ||
I'll run that image and give you: | ||
|
||
a contained environment for that source code you gave me. | ||
If the User gives contain an empty directory contain breaks saying: You violated our contract. If the User gives contain a directory with 0 files that contain recognizes... contain breaks saying, you violated our contract. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,32 @@ | ||
[aliases] | ||
test=pytest | ||
|
||
[flake8] | ||
ignore = D203 | ||
exclude = | ||
.git, | ||
__pycache__, | ||
*.egg-info, | ||
.eggs, | ||
.tox, | ||
build, | ||
dist, | ||
examples, | ||
docs | ||
max-complexity = 10 | ||
|
||
[pep257] | ||
match-dir = contain|tests|. | ||
match = .*\.py | ||
ignore = D205,D400 | ||
|
||
[tool:pytest] | ||
addopts = -vvra | ||
|
||
[mypy] | ||
ignore_missing_imports=True | ||
|
||
[pylint] | ||
disable=ungrouped-imports,no-name-in-module,too-few-public-methods,invalid-sequence-index,bad-continuation,import-error,invalid-name,no-member,locally-disabled,locally-enabled,redefined-outer-name,redefined-variable-type | ||
reports=no | ||
known-standard-library=typing |
Oops, something went wrong.