Pythonのパッケージ周りについて調べた時のメモ
用語
パッケージングツール
- destribute : python標準のパッケージ管理用モジュール、destributeよりも多機能なsetuptoolsが基本的には使われる
- setuptools : 2017年8月2日現在、すくなくともpython2系のパッケージング時のデファクトスタンダード。
- distutils : setuptoolsよりも機能が少ないので、setuptoolsを使っていればよい
インストールツール
- easy_install : setuptoolsに付属している、PyPIからパッケージをダウンロードしてインストールできるコマンド
- ez_setup.py : setuptoolsをインストールする際に利用されるスクリプト
- pip : easy_installよりも高機能なインストーラー、easy_installではパッケージのアンインストール等ができない
配布形式
- egg : setuptoolsで定義されたpython Packageの配布形式、中身はpythonのコードやメタ情報を所定のフォーマットでzip圧縮したもの
- wheels : eggの後続のフォーマット
配布物の作成
- bdist : setup.pyを使ってビルド済み配布物を作成するコマンド、bdist_rpmやbdist_wininst等を作成できる
- sdist : setup.pyを使ってソースコード配布物を作成するコマンド
その他
- setup.py : パッケージに必要な情報を記述する
- init.py : pythonがあるディレクトリの目印
- PyPI : the Python Package Index、Pythonのパッケージが登録されている場所
テンプレート
from setuptools import setup, find_packages setup( name = "HelloWorld", version = "0.0.1", packages = find_packages(), #find_packages()はsetup.pyがあるディレクトリから__init__.pyがあるディレクトリを探す author = "repli", author_email = "repli@example.com", description = "This is an Example Package", license = "MIT", keywords = "package example examples", # 検索用のワード url = "", # もしあれば、プロジェクトのホームページ install_requires = ['docutils>=0.3'], #python以外に含めるデータ package_data = { '': ['*.txt', '*.rst'], } )
ref
builderscon 2017に参加して来ました
概要
8月3,4,5で開催されたbuildersconに参加してきました。
buildersconとは
公式サイト(https://builderscon.io)より引用
buildersconは「知らなかった、を聞く」をテーマとした技術を愛する全てのギーク達のお祭りです。
セッション感想
1日目は完全オフレコなので、内容については何もかかないですが、ああいう話を聞ける機会はめったにないので、次同じようなものがあったらぜひまた聞きたいと思うぐらいには最高だった。
オンプレ、クラウドを組み合わせて作るビックデータ基盤 -データ基盤の選び方-
- 普段はオンプレの環境しか触っていないのでクラウド側の知識は新鮮で面白かった
- MetaデータのDBはすごく便利そう、テーブルの説明のコメントを追加できるのはよさげ
横山三国志に「うむ」は何コマある?〜マンガ全文検索システムの構築
OSS開発を仕事にする技術
- 無理ゲーな目標を立てる
- コントローラブルとアンコントローラブルをわける
- コントローラブルに集中する
- もっとも生産性が高いのは「作らない」こと
Chrome拡張を使って様々なWebサービスをハックする
Googleが開発したニューラルネット専用LSI「Tensor Processing Unit」
- DCの温度管理も機械学習でやって、電力効率が15%よくなった
- スマホのDeepLerningをtensorflowをDSPで動かすと速くて省電力でいける
- TPU第一世代の話
- ASIC : アプリケーションスペシックIC (application specific )
- 15ヶ月でASICを作り終わった
- 2015年から使ってる
- 第一世代TPUは学習と推論の推論にしか使ってない
- 2006年ぐらいから計画してた
OSSで始めるセキュリティログ収集
- auditログを取ろう、見よう
- ただauditログは見づらいのでパースしたい
- osqueryかElastic Beatsが良さそう
- osqueryはrocksDBのというKVSを内部で持っている
- osqueryの今のバージョンだとアプリケーションに影響はでてない
- auditログが見づらいのは思っていたので、osqueryは是非試してみたい
- 個人的には今回一番ためになったセッション
Factory Class
- キーボードを作って販売した話
- ぜひ発送の問題とかも入れて本して欲しいぐらい面白かった
カンファレンス感想
- 刺激的な3日間だった
- 普段は聞かない分野の話もきけて最高
- 試してみたい技術がいっぱい知れた
- 施設的にしょうがないけど、コーヒーが一つ部屋でしか飲めないは残念
- 名札にベストスピーカーの投票ページのQRコードがあるソリューションすごい
- ランチ美味しい
- 同時通訳の人すごい、ありがとう
- ペパボラップが頭に残り続ける
denite.nvim の設定 備忘録
denite.nvimはvimでいうところのUnite
インストール
dein.tomlに以下を追加
[[plugins]] repo = 'Shougo/denite.nvim' #インストール後にNeoVimで以下を実行して再起動することで有効になる :UpdateRemotePlugins
設定
まだまだ設定しきれてないが設定したのは下記
$ brew install the_silver_searcher
neovim側の設定
"grepでagを使用するように設定 call denite#custom#var('grep', 'command', ['ag']) "カレントディレクトリ内の検索もagを使用する call denite#custom#var('file_rec', 'command', ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']) "その他のgrepの設定 call denite#custom#var('grep', 'default_opts',['-i', '--vimgrep']) call denite#custom#var('grep', 'recursive_opts', []) call denite#custom#var('grep', 'pattern_opt', []) call denite#custom#var('grep', 'separator', ['--']) call denite#custom#var('grep', 'final_opts', [])
"denite時に使用するキーマップ "ESCキーでdeniteを終了 call denite#custom#map('insert', '<esc>', '<denite:enter_mode:normal>', 'noremap') call denite#custom#map('normal', '<esc>', '<denite:quit>', 'noremap') "C-N,C-Pで上下移動 call denite#custom#map('insert', '<C-n>', '<denite:move_to_next_line>', 'noremap') call denite#custom#map('insert', '<C-p>', '<denite:move_to_previous_line>', 'noremap') "C-J,C-Kでsplitで開く call denite#custom#map('insert', '<C-j>', '<denite:do_action:split>', 'noremap') call denite#custom#map('insert', '<C-k>', '<denite:do_action:vsplit>', 'noremap') " 以下はdenite起動時に使用するキーマップ " バッファ一覧 noremap <C-P> :Denite buffer<CR> " ファイル一覧 noremap <C-N> :Denite -buffer-name=file file<CR> " 最近使ったファイルの一覧 noremap <C-Z> :Denite file_old<CR> " カレントディレクトリ noremap <C-C> :Denite file_rec<CR> "バッファ一覧 nnoremap sB :<C-u>Denite buffer -buffer-name=file<CR> "Denite でバッファ内検索 nnoremap <silent> <Leader><C-f> :<C-u>Denite line<CR> nnoremap <silent> <expr><Space>l ":<C-u>DeniteWithCursorWord line<CR>"
- 表示をカスタマイズ
" プロンプトの左端に表示される文字を指定 call denite#custom#option('default', 'prompt', '>') " deniteの起動位置をtopに変更 call denite#custom#option('default', 'direction', 'top')
MacのSpotlightからneovimを起動する方法
そもそもSpotlightから起動するのが、しっくり来てない人もいると思いますが、
下のGIFを見て貰えればどういうことかわかると思います。
私は普段、Spotlightから様々なアプリを起動しており、 ちょっとメモが取りたいなーって時とかはターミナルでvimを開かず、ここから起動してました。
なので、neovimもここから起動できるように設定します。
neovimはMacVimのようにアプリケーションとしてMacにインストールされず、GUI版もないのでインストールをしただけだと、Spotlightからは起動できないです。
ではどうするかと言うと、neovimを起動するスクリプトを書いて、それをSpotlightから実行することでSpotlightからneovimを起動するのを実現します。
スクリプトをSpotlightから実行できるようにするには.command拡張子でファイルを書けばいいので、下記のファイルを適当な場所に作成しておきます。
今回はファイル名はneovim_run.commandにしてます。
!#/bin/sh nvim
ファイルをおいたらもうSpotlightから起動できるはずです。
Neovim 補完設定
すでに前回までの設定が終わっている状態で設定を続けていきます。
neovimで補完を有効にするために設定をする。
neovimではvimで使っていた、neocomplete.vimではなくdeoplete.nvimを使用する。
また、スニペットの補完はvimと同じでneosnippet.vimを使用する
deoplete.nvimとneosnippet.vimのインストール
pluginはTOMLで管理しているのでTOMLに以下を追加
[[plugins]] repo = 'Shougo/deoplete.nvim' on_i = 1 [[plugins]] repo = 'Shougo/neosnippet.vim.git' on_i = 1 on_ft = 'snipppet'
追加したら、あとは起動時にダウンロードされる
補完用のポップアップが表示された時の設定
補完用のポップアップが表示されている時に
追加した設定は下記
"補完候補選択時は<TAB>で候補移動snipppet時は<TAB>で次の入力先へ imap <expr><TAB> pumvisible() ? "\<C-N>" : neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" smap <expr><TAB> neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
まとめ
これでneovimでも補完が表示されるようになったのでほぼvimと同じように使えるようになってきた。
deoplete.nvimは言語ごとに保管用のpluginを入れていくようなので、必要になった言語を都度追加していく予定
alacrittyインストール 備忘録
vimとneovimをiTerm2で使用中にスクロールが遅くなることがあり、調べてたらalacrittyというのが良さげだったのでインストールした
基本的にはこの記事を参考にやれば問題はない : http://qiita.com/zebult/items/0047b72916383a5c0acf
ただ、今回はbrewからインストールするとmakeで失敗してインストールできなかった
エラーメッセージ
$brew install --HEAD mscharley/homebrew/alacritty ==> Installing alacritty from mscharley/homebrew ==> Cloning git@github.com:jwilm/alacritty.git Updating ~/Library/Caches/Homebrew/alacritty--git ==> Checking out branch master ==> make app Last 15 lines from ~/Library/Logs/Homebrew/alacritty/01.make: Compiling cgmath v0.7.0 Compiling walkdir v0.1.8 Compiling notify v2.6.3 error: custom derive attribute panicked --> src/ansi.rs:373:62 | 373 | #[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] | ^^^^^^^^^ | = help: message: proc_macro::__internal::with_parse_sess() called before set_parse_sess()! error: Could not compile `alacritty`. To learn more, run the command again with --verbose. make: *** [alacritty] Error 101 If reporting this issue please do so at (not Homebrew/brew or Homebrew/core): https://github.com/mscharley/homebrew-homebrew/issues
おそらくこのissuesと同じような問題だと思われる
https://github.com/jwilm/alacritty/issues/413
alacrittyの問題というかrust周りの問題?
brewで入れるのはとりあえず諦めて自分でbuildすることにする
#rustのインストール #rustはrustupで管理するのがよさげ : http://qiita.com/chikoski/items/b6461367e8c3875bb235 $curl https://sh.rustup.rs -sSf | sh #zshrcにsource ~/.cargo/env を追加 $echo 'source ~/.cargo/env' >> .zshrc #alacrittyのインストール #これは公式の手順を参考に実施 : https://github.com/jwilm/alacritty $git clone https://github.com/jwilm/alacritty.git $cd alacritty $rustup override set stable $rustup update stable $cargo build --release $sudo cp target/release/alacritty /usr/local/bin #alacrittyコマンドでalacrittyが起動する
とりあえず無事インストールできたので使用しながら設定は直していく
2017/04/24 追記
rustupさえ入れておけばbrewでのmakeに失敗しないようでした
https://github.com/cema-sp/homebrew-tap
$curl https://sh.rustup.rs -sSf | sh $echo 'source ~/.cargo/env' >> .zshrc $brew install --HEAD cema-sp/tap/alacritty
Neovim 入門3 plugin
neovimでもvimと同じようにpluginが使える。
vimで使用していたdein.vimはNeovimもサポートしているので、これをそのまま使う。
https://github.com/Shougo/dein.vim
deinのインストール
dein.vimのインストールは公式サイトを参考にinit.vimに追加
なお、pluginはTOMLファイルに記述していく。
let s:dein_cache_path = expand('~/.cache/nvim/dein') let g:home = expand('~') let g:nvim_home = g:home .'/.config/nvim' let s:dein_dir = expand(g:home . '/.cache/dein') let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim' if &runtimepath !~# '/dein.vim' if !isdirectory(s:dein_repo_dir) execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir endif execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p') endif let g:rc_dir = g:nvim_home . '/rc' let g:dein#install_max_processes = 16 let g:dein#install_progress_type = 'title' let g:dein#enable_notification = 1 let s:toml = g:rc_dir . '/dein.toml' let s:lazy_toml = g:rc_dir . '/dein_lazy.toml' if dein#load_state(s:dein_dir) call dein#begin(s:dein_dir, [s:toml, s:lazy_toml]) call dein#load_toml(s:toml, {'lazy' : 0}) call dein#load_toml(s:lazy_toml, {'lazy' : 1}) call dein#end() call dein#save_state() endif if dein#check_install() call dein#install() endif #plugin毎の設定ロード for plugin in glob(g:rc_dir . '/plugins/*', 1, 1) execute "source " . plugin endfor filetype plugin indent on #plugin毎に設定ファイルを分け、それを読み込む for plugin in glob(g:rc_dir . '/plugins/*', 1, 1) execute "source " . plugin endfor
neoterm
せっかくなのでNeovimぽいpluginを入れてみる。
Neovimではvimの中のshellを実行できるので(TERMINALモード)、それを便利にするpluginを入れる。
今回入れるのはneotermというplugin。
https://github.com/kassio/neoterm
dein.tomlに下記を追加
[[plugins]] repo = 'kassio/neoterm'
これでnvimを起動したタイミングでdein.vimがpluginをダウンロードして来てくれる。
neotermの設定を記述(公式サイトのexampleから必要そうなのだけをもってきただけ)
let g:neoterm_position = 'horizontal' " Useful maps " hide/close terminal nnoremap <silent> ,th :call neoterm#close()<cr> " clear terminal nnoremap <silent> ,tl :call neoterm#clear()<cr> " kills the current job (send a <c-c>) nnoremap <silent> ,tc :call neoterm#kill()<cr> " Git commands command! -nargs=+ Tg :T git <args>
まとめ
とりあえずこれで、初期設定とpluginのインストールはできたので、あとは必要なpluginや設定を適宜追加していくだけまではできた。
フォルダ構成としては現状は以下になっている。
nvim ├── init.vim └── rc ├── color.vim ├── dein.toml ├── dein_lazy.toml ├── filetypes.vim ├── mapping.vim ├── plugins │ └── neoterm.vim └── settings.vim