Created
January 14, 2019 12:22
-
-
Save podhmo/bc6611c4b323299c67ea95aecca9d7a9 to your computer and use it in GitHub Desktop.
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
import sys | |
import jedi | |
import textwrap | |
def run(module, venv_path=None): | |
source = textwrap.dedent(f""" | |
import {module} | |
{module}.no | |
""").strip() | |
env = None | |
if venv_path is not None: | |
env = jedi.create_environment(venv_path) | |
script = jedi.Script(source, 2, len(module + ".no") - 1, environment=env) | |
print(script.completions()) | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print("python program.py <module name> [<venv-path>]", file=sys.stderr) | |
sys.exit(1) | |
run(*sys.argv[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
PYTHON ?= python | |
run: | |
@echo "** which python >>" ${PYTHON} "**" | |
@echo "** arrow installed" "**" | |
@(${PYTHON} -c 'import arrow' &> /dev/null; if [ $$? -eq 0 ]; then echo ok; else echo ng; fi) | |
@echo "** pendulum installed" "**" | |
@(${PYTHON} -c 'import pendulum' &> /dev/null; if [ $$? -eq 0 ]; then echo ok; else echo ng; fi) | |
runA: | |
$(MAKE) run PYTHON=a/bin/python | |
runB: | |
$(MAKE) run PYTHON=b/bin/python | |
PYTHON ?= python | |
VENVPATH ?= | |
comp: | |
@echo "** which python >>" ${PYTHON} "**" | |
@echo "** venv path is >>" ${VENVPATH} "**" | |
@echo "** arrow.no -> arrow.now?" "**" | |
${PYTHON} 02usejedi.py arrow ${VENVPATH} | |
@echo "** pendulum.no -> pendulum.now?" "**" | |
${PYTHON} 02usejedi.py pendulum ${VENVPATH} | |
compAforA: | |
$(MAKE) comp PYTHON=a/bin/python VENVPATH=a | |
compAforB: | |
$(MAKE) comp PYTHON=a/bin/python VENVPATH=b | |
setup: | |
rm -rf a b | |
# 環境の作成 | |
python -m venv a | |
python -m venv b | |
# パッケージのインストール | |
a/bin/pip install arrow jedi | |
b/bin/pip install pendulum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment