-
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.
- Loading branch information
Victor H. Chavez
committed
Feb 12, 2020
0 parents
commit e7ab944
Showing
28 changed files
with
3,220 additions
and
0 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,77 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, | ||
body size, disability, ethnicity, gender identity and expression, level of | ||
experience, nationality, personal appearance, race, religion, or sexual | ||
identity and orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
Moreover, project maintainers will strive to offer feedback and advice to | ||
ensure quality and consistency of contributions to the code. Contributions | ||
from outside the group of project maintainers are strongly welcomed but the | ||
final decision as to whether commits are merged into the codebase rests with | ||
the team of project maintainers. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an | ||
appointed representative at an online or offline event. Representation of a | ||
project may be further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at '[email protected]'. The project team will | ||
review and investigate all complaints, and will respond in a way that it deems | ||
appropriate to the circumstances. The project team is obligated to maintain | ||
confidentiality with regard to the reporter of an incident. Further details of | ||
specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], | ||
version 1.4, available at | ||
[http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
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 @@ | ||
|
||
Copyright 2020 VH Chavez | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the | ||
following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote | ||
products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,6 @@ | ||
include LICENSE | ||
include MANIFEST.in | ||
include versioneer.py | ||
|
||
graft molely | ||
global-exclude *.py[cod] __pycache__ *.so |
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,18 @@ | ||
molely | ||
============================== | ||
[//]: # (Badges) | ||
[![Travis Build Status](https://travis-ci.com/REPLACE_WITH_OWNER_ACCOUNT/molely.svg?branch=master)](https://travis-ci.com/REPLACE_WITH_OWNER_ACCOUNT/molely) | ||
[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/REPLACE_WITH_APPVEYOR_LINK/branch/master?svg=true)](https://ci.appveyor.com/project/REPLACE_WITH_OWNER_ACCOUNT/molely/branch/master) | ||
[![codecov](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/molely/branch/master/graph/badge.svg)](https://codecov.io/gh/REPLACE_WITH_OWNER_ACCOUNT/molely/branch/master) | ||
|
||
A short description of the project. | ||
|
||
### Copyright | ||
|
||
Copyright (c) 2020, VH Chavez | ||
|
||
|
||
#### Acknowledgements | ||
|
||
Project based on the | ||
[Computational Molecular Science Python Cookiecutter](https://github.com/molssi/cookiecutter-cms) version 1.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,44 @@ | ||
environment: | ||
|
||
matrix: | ||
- PYTHON: "C:\\Miniconda36-x64" | ||
PYTHON_VERSION: "3.6" | ||
PYTHON_ARCH: "64" | ||
|
||
- PYTHON: "C:\\Miniconda37-x64" | ||
PYTHON_VERSION: "3.7" | ||
PYTHON_ARCH: "64" | ||
|
||
|
||
install: | ||
# Make sure pip is around | ||
- python -m ensurepip | ||
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" | ||
|
||
# Add conda-forge channel | ||
- conda config --add channels conda-forge | ||
|
||
|
||
# Always run commands without asking | ||
- conda config --set always_yes yes | ||
|
||
# Try to update conda first to avoid odd dependency clashes | ||
- conda update --all | ||
|
||
# Create test environment for package | ||
- python devtools\\scripts\\create_conda_env.py -n=test -p=%PYTHON_VERSION% devtools\\conda-envs\\test_env.yaml | ||
|
||
# Activate the test environment | ||
- activate test | ||
|
||
# Build and install package | ||
- python setup.py develop --no-deps | ||
|
||
|
||
build: false | ||
|
||
test_script: | ||
- pytest -v --cov=molely molely\\tests | ||
|
||
on_success: | ||
- codecov |
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,60 @@ | ||
# Development, testing, and deployment tools | ||
|
||
This directory contains a collection of tools for running Continuous Integration (CI) tests, | ||
conda installation, and other development tools not directly related to the coding process. | ||
|
||
|
||
## Manifest | ||
|
||
### Continuous Integration | ||
|
||
You should test your code, but do not feel compelled to use these specific programs. You also may not need Unix and | ||
Windows testing if you only plan to deploy on specific platforms. These are just to help you get started | ||
|
||
* `travis-ci`: Linux and OSX based testing through [Travis-CI](https://about.travis-ci.com/) | ||
* `before_install.sh`: Pip/Miniconda pre-package installation script for Travis | ||
* `appveyor`: Windows based testing through [AppVeyor](https://www.appveyor.com/) (there are no files directly related to this) | ||
|
||
### Conda Environment: | ||
|
||
This directory contains the files to setup the Conda environment for testing purposes | ||
|
||
* `conda-envs`: directory containing the YAML file(s) which fully describe Conda Environments, their dependencies, and those dependency provenance's | ||
* `test_env.yaml`: Simple test environment file with base dependencies. Channels are not specified here and therefore respect global Conda configuration | ||
|
||
### Additional Scripts: | ||
|
||
This directory contains OS agnostic helper scripts which don't fall in any of the previous categories | ||
* `scripts` | ||
* `create_conda_env.py`: Helper program for spinning up new conda environments based on a starter file with Python Version and Env. Name command-line options | ||
|
||
|
||
## How to contribute changes | ||
- Clone the repository if you have write access to the main repo, fork the repository if you are a collaborator. | ||
- Make a new branch with `git checkout -b {your branch name}` | ||
- Make changes and test your code | ||
- Ensure that the test environment dependencies (`conda-envs`) line up with the build and deploy dependencies (`conda-recipe/meta.yaml`) | ||
- Push the branch to the repo (either the main or your fork) with `git push -u origin {your branch name}` | ||
* Note that `origin` is the default name assigned to the remote, yours may be different | ||
- Make a PR on GitHub with your changes | ||
- We'll review the changes and get your code into the repo after lively discussion! | ||
|
||
|
||
## Checklist for updates | ||
- [ ] Make sure there is an/are issue(s) opened for your specific update | ||
- [ ] Create the PR, referencing the issue | ||
- [ ] Debug the PR as needed until tests pass | ||
- [ ] Tag the final, debugged version | ||
* `git tag -a X.Y.Z [latest pushed commit] && git push --follow-tags` | ||
- [ ] Get the PR merged in | ||
|
||
## Versioneer Auto-version | ||
[Versioneer](https://github.com/warner/python-versioneer) will automatically infer what version | ||
is installed by looking at the `git` tags and how many commits ahead this version is. The format follows | ||
[PEP 440](https://www.python.org/dev/peps/pep-0440/) and has the regular expression of: | ||
```regexp | ||
\d+.\d+.\d+(?\+\d+-[a-z0-9]+) | ||
``` | ||
If the version of this commit is the same as a `git` tag, the installed version is the same as the tag, | ||
e.g. `molely-0.1.2`, otherwise it will be appended with `+X` where `X` is the number of commits | ||
ahead from the last tag, and then `-YYYYYY` where the `Y`'s are replaced with the `git` commit hash. |
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,16 @@ | ||
name: test | ||
channels: | ||
dependencies: | ||
# Base depends | ||
- python | ||
- pip | ||
|
||
# Testing | ||
- pytest | ||
- pytest-cov | ||
- codecov | ||
|
||
# Pip-only installs | ||
#- pip: | ||
# - codecov | ||
|
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,95 @@ | ||
import argparse | ||
import os | ||
import re | ||
import glob | ||
import shutil | ||
import subprocess as sp | ||
from tempfile import TemporaryDirectory | ||
from contextlib import contextmanager | ||
# YAML imports | ||
try: | ||
import yaml # PyYAML | ||
loader = yaml.load | ||
except ImportError: | ||
try: | ||
import ruamel_yaml as yaml # Ruamel YAML | ||
except ImportError: | ||
try: | ||
# Load Ruamel YAML from the base conda environment | ||
from importlib import util as import_util | ||
CONDA_BIN = os.path.dirname(os.environ['CONDA_EXE']) | ||
ruamel_yaml_path = glob.glob(os.path.join(CONDA_BIN, '..', | ||
'lib', 'python*.*', 'site-packages', | ||
'ruamel_yaml', '__init__.py'))[0] | ||
# Based on importlib example, but only needs to load_module since its the whole package, not just | ||
# a module | ||
spec = import_util.spec_from_file_location('ruamel_yaml', ruamel_yaml_path) | ||
yaml = spec.loader.load_module() | ||
except (KeyError, ImportError, IndexError): | ||
raise ImportError("No YAML parser could be found in this or the conda environment. " | ||
"Could not find PyYAML or Ruamel YAML in the current environment, " | ||
"AND could not find Ruamel YAML in the base conda environment through CONDA_EXE path. " | ||
"Environment not created!") | ||
loader = yaml.YAML(typ="safe").load # typ="safe" avoids odd typing on output | ||
|
||
|
||
@contextmanager | ||
def temp_cd(): | ||
"""Temporary CD Helper""" | ||
cwd = os.getcwd() | ||
with TemporaryDirectory() as td: | ||
try: | ||
os.chdir(td) | ||
yield | ||
finally: | ||
os.chdir(cwd) | ||
|
||
|
||
# Args | ||
parser = argparse.ArgumentParser(description='Creates a conda environment from file for a given Python version.') | ||
parser.add_argument('-n', '--name', type=str, | ||
help='The name of the created Python environment') | ||
parser.add_argument('-p', '--python', type=str, | ||
help='The version of the created Python environment') | ||
parser.add_argument('conda_file', | ||
help='The file for the created Python environment') | ||
|
||
args = parser.parse_args() | ||
|
||
# Open the base file | ||
with open(args.conda_file, "r") as handle: | ||
yaml_script = loader(handle.read()) | ||
|
||
python_replacement_string = "python {}*".format(args.python) | ||
|
||
try: | ||
for dep_index, dep_value in enumerate(yaml_script['dependencies']): | ||
if re.match('python([ ><=*]+[0-9.*]*)?$', dep_value): # Match explicitly 'python' and its formats | ||
yaml_script['dependencies'].pop(dep_index) | ||
break # Making the assumption there is only one Python entry, also avoids need to enumerate in reverse | ||
except (KeyError, TypeError): | ||
# Case of no dependencies key, or dependencies: None | ||
yaml_script['dependencies'] = [] | ||
finally: | ||
# Ensure the python version is added in. Even if the code does not need it, we assume the env does | ||
yaml_script['dependencies'].insert(0, python_replacement_string) | ||
|
||
# Figure out conda path | ||
if "CONDA_EXE" in os.environ: | ||
conda_path = os.environ["CONDA_EXE"] | ||
else: | ||
conda_path = shutil.which("conda") | ||
if conda_path is None: | ||
raise RuntimeError("Could not find a conda binary in CONDA_EXE variable or in executable search path") | ||
|
||
print("CONDA ENV NAME {}".format(args.name)) | ||
print("PYTHON VERSION {}".format(args.python)) | ||
print("CONDA FILE NAME {}".format(args.conda_file)) | ||
print("CONDA PATH {}".format(conda_path)) | ||
|
||
# Write to a temp directory which will always be cleaned up | ||
with temp_cd(): | ||
temp_file_name = "temp_script.yaml" | ||
with open(temp_file_name, 'w') as f: | ||
f.write(yaml.dump(yaml_script)) | ||
sp.call("{} env create -n {} -f {}".format(conda_path, args.name, temp_file_name), shell=True) |
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,41 @@ | ||
# Temporarily change directory to $HOME to install software | ||
pushd . | ||
cd $HOME | ||
# Make sure some level of pip is installed | ||
python -m ensurepip | ||
|
||
# Install Miniconda | ||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then | ||
# Make OSX md5 mimic md5sum from linux, alias does not work | ||
md5sum () { | ||
command md5 -r "$@" | ||
} | ||
MINICONDA=Miniconda3-latest-MacOSX-x86_64.sh | ||
else | ||
MINICONDA=Miniconda3-latest-Linux-x86_64.sh | ||
fi | ||
MINICONDA_HOME=$HOME/miniconda | ||
MINICONDA_MD5=$(curl -s https://repo.continuum.io/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *<td>\(.*\)<\/td> */\1/p') | ||
wget -q https://repo.continuum.io/miniconda/$MINICONDA | ||
if [[ $MINICONDA_MD5 != $(md5sum $MINICONDA | cut -d ' ' -f 1) ]]; then | ||
echo "Miniconda MD5 mismatch" | ||
exit 1 | ||
fi | ||
bash $MINICONDA -b -p $MINICONDA_HOME | ||
|
||
# Configure miniconda | ||
export PIP_ARGS="-U" | ||
# New to conda >=4.4 | ||
echo ". $MINICONDA_HOME/etc/profile.d/conda.sh" >> ~/.bashrc # Source the profile.d file | ||
echo "conda activate" >> ~/.bashrc # Activate conda | ||
source ~/.bashrc # source file to get new commands | ||
#export PATH=$MINICONDA_HOME/bin:$PATH # Old way, should not be needed anymore | ||
|
||
conda config --add channels conda-forge | ||
|
||
conda config --set always_yes yes | ||
conda install conda conda-build jinja2 anaconda-client | ||
conda update --quiet --all | ||
|
||
# Restore original directory | ||
popd |
Oops, something went wrong.