pymc4 commit log - Create skeleton, set up CI (#3) [fe7a3f5]
TL;DR
pythonの環境構築は Miniconda — Conda を使った方がいい
日付の順番でコミットログを追っていくと、順番が逆だったりするので単にコミットタイトルをブログの件名にすることにした。(順番が逆転するのはおそらくrebaseとかcherry-pickが原因)
そもそもgit的に日付の順番は保証されているわけではないので注意。
また、後で自分が件名でコミットを検索しやすいようにハッシュ値も入れておくことにした。
コミット
2018/06/02のコミットです。
Create skeleton, set up CI (#3) · pymc-devs/pymc4@fe7a3f5 · GitHub
以下のPRの会話にあるように新規プロジェクトを作成する際のボイラープレートコードを追加しただけのようです。
This adds a bunch of boilerplate for a new project:
- A folder for the main project, with version in the init.py
- A folder for tests. Run tests with pytest -xv tests/ --cov=pymc4/
- Adds linting. Run linter with pylint pymc4
- Adds CI (activated on travis)
- Adds coverage (activated on coveralls)
- Adds setup.py (and travis uses it to install the project, so it should have to work)
PR: Create skeleton, set up CI by ColCarroll · Pull Request #3 · pymc-devs/pymc4 · GitHub
具体的には以下のファイルが新規追加・変更されています。
- .gitignore
.vscode/
が除外されているので、vscodeを使っていることがわかる。
- .pylintrc
- PRコメントおよび
.travis.yml
によると、デフォルトのpylint pymc4
した結果のファイルみたいです。
- PRコメントおよび
- .travis.yml
- 後述
- README.md
- PyMC4の簡単な説明文
- pymc4/init.py
- バージョン情報: "0.0.1"
- requirements-dev.txt
- pylint
- pytest
- pytest-cov
- requirements.txt(空ファイル)
- setup.py
- 後述
- test/test_nothing.py
- 簡単なテストコード
.travis.yml
- pythonのバージョンは、3.5-3.6に対応
- python環境のセットアップは、Miniconda — Conda を使っている。
language: python python: - "3.5" - "3.6" install: - sudo apt-get update - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - hash -r - conda config --set always_yes yes --set changeps1 no - conda update -q conda - conda info -a - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION - source activate test-environment - pip install . - pip install -r requirements-dev.txt - pip install coveralls script: - pylint pymc4/ - pytest -xv --cov=pymc4/ test/ after_success: - coveralls
setup.py
- setupする際のライブラリの概要やrequirements、バージョン情報を動的に取得している
#!/usr/bin/env python from codecs import open # pylint: disable=redefined-builtin from os.path import realpath, dirname, join import re from setuptools import setup, find_packages DISTNAME = 'pymc4' # pylint: disable=line-too-long DESCRIPTION = "Pre-release development of high-level probabilistic programming interface for TensorFlow" AUTHOR = 'PyMC Developers' AUTHOR_EMAIL = 'pymc.devs@gmail.com' URL = "http://github.com/pymc-devs/pymc4" LICENSE = "Apache License, Version 2.0" CLASSIFIERS = ['Development Status :: 2 - Pre-Alpha', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'License :: OSI Approved :: Apache Software License', 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering', 'Topic :: Scientific/Engineering :: Mathematics', 'Operating System :: OS Independent'] PROJECT_ROOT = dirname(realpath(__file__)) # Get the long description from the README file with open(join(PROJECT_ROOT, 'README.md'), encoding='utf-8') as buff: LONG_DESCRIPTION = buff.read() REQUIREMENTS_FILE = join(PROJECT_ROOT, 'requirements.txt') with open(REQUIREMENTS_FILE) as f: INSTALL_REQS = f.read().splitlines() TEST_REQS = ['pytest', 'pytest-cov'] def get_version(): versionfile = join('pymc4', '__init__.py') lines = open(versionfile, 'rt').readlines() version_regex = r"^__version__ = ['\"]([^'\"]*)['\"]" for line in lines: match = re.search(version_regex, line, re.M) if match: return match.group(1) raise RuntimeError('Unable to find version in %s.' % (versionfile,)) if __name__ == "__main__": setup(name=DISTNAME, version=get_version(), maintainer=AUTHOR, maintainer_email=AUTHOR_EMAIL, description=DESCRIPTION, license=LICENSE, url=URL, long_description=LONG_DESCRIPTION, packages=find_packages(), package_data={}, include_package_data=True, classifiers=CLASSIFIERS, install_requires=INSTALL_REQS, tests_require=TEST_REQS,)