ํ๊ฒฝ
์ค๋ช
๋ค์๊ณผ ๊ฐ์ด ๋ก์ปฌ ๋๋ ํ ๋ฆฌ์ git repo์์ ํจํค์ง๋ฅผ ์ค์นํ ์ ์์ต๋๋ค.
pip install git+file:///"k/my/path with/lots of/spaces/repo/.git/"
๊ทธ๋ฌ๋ git+file:///"k/my/path with/lots of/spaces/repo/.git/"
์ requirements.txt
์ ๋ฃ์ ๋ค์ pip install -r requirements.txt
๋ก ์ค์นํ๋ ค๊ณ ํ๋ฉด ValueError: No closing quotation
์คํจํฉ๋๋ค.
์์๋๋ ํ๋
๋ช
๋ น์ ์ง์ ์คํํ ๋์ ๋ง์ฐฌ๊ฐ์ง๋ก ํจํค์ง๊ฐ ๋ก์ปฌ ๋๋ ํฐ๋ฆฌ์์ ์ค์น๋ ๊ฒ์ผ๋ก ์์ํ์ต๋๋ค.
๋ฒ์ ๋ฐฉ๋ฒ
requirements.txt
์ ์ข
์์ฑ์ผ๋ก ๊ณต๋ฐฑ์ด ํฌํจ๋ ๊ฒฝ๋ก์ ๋ก์ปฌ git repo๋ฅผ ์ง์ ํฉ๋๋ค.pip install -r requirements.txt
์ฐ์ถ
pip install -r .\requirements.txt
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 178, in main
status = self.run(options, args)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 326, in run
self.name, wheel_cache
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 288, in populate_requirement_set
use_pep517=options.use_pep517):
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 112, in parse_requirements
for req in req_iter:
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\site-packages\pip\_internal\req\req_file.py", line 173, in process_line
shlex.split(options_str), defaults) # type: ignore
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\shlex.py", line 305, in split
return list(lex)
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\shlex.py", line 295, in __next__
token = self.get_token()
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\shlex.py", line 105, in get_token
raw = self.read_token()
File "C:\Users\username\AppData\Local\Continuum\anaconda3\lib\shlex.py", line 187, in read_token
raise ValueError("No closing quotation")
ValueError: No closing quotation
requirements.txt
:
git+file:///"k/my/path with/lots of/spaces/repo/.git/"
pandas
requests
retrying
xlsxwriter
๊ด๋ จ SO ์ง๋ฌธ ๋ ์ฐธ์กฐํ์ญ์์ค.
pip๊ฐ ์ง์ ์คํ๋ ๋ ๋ฐ์ดํ ์ฒ๋ฆฌ๋ ์ ธ์์ ์ ์ดํฉ๋๋ค. ์๋ฅผ ๋ค์ด Bash์์๋ ์ค์ฒฉ๋์ง ์์ ๋ฐ์ดํ ์์ด ์ ๊ฑฐ๋๊ณ ํด๋น ๋ด์ฉ์ด ์/๋ค์ ์ค๋ ๋ด์ฉ๊ณผ ์ฐ๊ฒฐ๋์ด ๊ฐ ์ธ์๊ฐ ์์ฑ๋ฉ๋๋ค.
๋ฐ๋ฉด์ ์๊ตฌ ์ฌํญ ํ์ผ์ optparse์ ์ํด ์๋ ๊ทธ๋๋ก ์ฝํ์ง๋ฉฐ ํน๋ณํ ๊ฒฌ์ ์ฒ๋ฆฌ ๋๋ ์ ๊ฑฐ๊ฐ ๋ฐ์ํ์ง ์์ต๋๋ค.
์ฆ, ์ด ๊ฒฝ์ฐ URL์ ์ ๊ณตํ๋ ค๊ณ ํ ๋ ์ ํจํ์ง ์์ URL ๋ฌธ์(๊ณต๋ฐฑ๊ณผ ๊ฐ์)๋ ํผ์ผํธ๋ก ์ธ์ฝ๋ฉ๋์ด์ผ ํฉ๋๋ค(๊ณต๋ฐฑ์ %20). ๊ฒฝ๋ก์ ๊ณต๋ฐฑ์ด ์๋ git repo๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ์ค์นํ๋ ์์ ๋ ์ด ์คํฌ๋ฆฝํธ๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
repro.sh
#!/bin/sh
cd "$(mktemp -d)"
dir="$PWD/a b c/d e f"
mkdir -p "$dir"
cd "$dir"
cat <<EOF > setup.py
from setuptools import setup
setup(name='example')
EOF
git init
git add .
git commit -m init
cd -
python -V
python -m venv venv
venv/bin/python -m pip install --upgrade pip
cat <<EOF | tee requirements.txt
git+file://$PWD/a%20b%20c/d%20e%20f
EOF
python -m pip install -r requirements.txt
์ฐ์ถ
Initialized empty Git repository in /tmp/user/1000/tmp.kITsbsZCPO/a b c/d e f/.git/
[master (root-commit) d347157] init
1 file changed, 3 insertions(+)
create mode 100644 setup.py
/tmp/user/1000/tmp.kITsbsZCPO
Python 3.7.2
Collecting pip
Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 18.1
Uninstalling pip-18.1:
Successfully uninstalled pip-18.1
Successfully installed pip-19.3.1
git+file:///tmp/user/1000/tmp.kITsbsZCPO/a%20b%20c/d%20e%20f
Collecting git+file:///tmp/user/1000/tmp.kITsbsZCPO/a%20b%20c/d%20e%20f (from -r requirements.txt (line 1))
Cloning file:///tmp/user/1000/tmp.kITsbsZCPO/a b c/d e f to /tmp/user/1000/pip-req-build-ts2s099_
Requirement already satisfied (use --upgrade to upgrade): example==0.0.0 from git+file:///tmp/user/1000/tmp.kITsbsZCPO/a%20b%20c/d%20e%20f in /home/chris/.pyenv/versions/3.7.2/lib/python3.7/site-packages (from -r requirements.txt (line 1))
์ด๊ฒ์ ํจ๊ณผ๊ฐ ์์์ต๋๋ค. ์ ๋ง ๊ฐ์ฌํฉ๋๋ค!!
SO ์ง๋ฌธ์ ๋ตํ์๊ฒ ์ต๋๊น? ๊ทธ๋ ์ง ์์ผ๋ฉด ๊ด์ฐฎ์ผ์๋ค๋ฉด ๋ต๋ณ์ผ๋ก ๊ทํ์ ์ค๋ช ์ ์ธ์ฉํ๊ฒ ์ต๋๋ค.
ํธ๊ธฐ์ฌ์ ์ด ๋ฌธ์ ๋ฅผ ์ข ๋ฃํ๊ฒ ์ต๋๋ค. ์ด๊ฒ์ด Windows๋ง์ ๋ฌธ์ ์ ๋๊น? SO์ ์ฌ์ฉ์ 00์ ๋ฐ๋ฅด๋ฉด Mac์์ %20 ์์ด๋ ์๋ํ๊ธฐ ๋๋ฌธ์ ๋๋ค.
๋์์ด ๋์๋ค๋ ๋คํ์ ๋๋ค. :)
์งํํ์๊ธฐ ๋ฐ๋๋๋ค!
๋์์ด ํ๋ซํผ์ ๋ฐ๋ผ ๋ค๋ฅด๋ค๋ฉด ์กฐ๊ธ ๋๋ ๊ฒ์ ๋๋ค. ์ฌ๊ธฐ์ ์๋ ์ฝ๋๋ URL์ ๋ถํ ํ๋ ์ฝ๋์ฌ์ผ ํ๋ฉฐ ํ๋ซํผ ๊ฐ์ ๋ณ๊ฒฝ๋ ์ฌํญ์ด ํ์๋์ง ์์ต๋๋ค. ์ด์จ๋ ํผ์ผํธ ์ธ์ฝ๋ฉ์ ์ฆ์ ์ฌ์ฉํ ์ ์๋ ๋ชจ๋ ๊ณณ์์ ์๋ํด์ผ ํ๋ฏ๋ก ๋ค๋ฅธ ํ๋ซํผ์์ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ์๋ํ๊ฒ ํ ์ ์๋ ์ฌ๋๋ค์๊ฒ๋ ๋ถ๋ช ํ ์ ํฉํ ๋ฐฉ๋ฒ์ ๋๋ค.