我正在实验Platform.sh,并尝试按照其documentation在本地构建我的项目。 但是构建失败,显然无法找到项目文件:
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
我已经尝试过git commit
代码,但是还是没有运气。这是我得到的完整回溯:
$ platform local:build Mon 11 Feb 2019 12:28:09 -02
Building application app (runtime type: python:3.6)
Installing python3 dependencies with 'pip': pipenv
Looking in indexes: http://localhost:3141/root/pypi/+simple/
Collecting pipenv==2018.10.13 (from -r requirements.txt (line 1))
Downloading http://localhost:3141/root/pypi/+f/d5a/c9a7705c654ec/pipenv-2018.10.13-py3-none-any.whl (5.2MB)
100% |████████████████████████████████| 5.2MB 37.8MB/s
Requirement already satisfied: pip>=9.0.1 in /home/user/.local/share/virtualenvs/space-app-phFju0DF/lib/python3.6/site-packages (from pipenv==2018.10.13->-r requirements.txt (line 1)) (10.0.1)
Collecting certifi (from pipenv==2018.10.13->-r requirements.txt (line 1))
Downloading http://localhost:3141/root/pypi/+f/993/f830721089fef/certifi-2018.11.29-py2.py3-none-any.whl (154kB)
100% |████████████████████████████████| 163kB 36.9MB/s
Collecting virtualenv-clone>=0.2.5 (from pipenv==2018.10.13->-r requirements.txt (line 1))
Downloading http://localhost:3141/root/pypi/+f/f2a/07ed255f3abac/virtualenv_clone-0.5.1-py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /home/user/.local/share/virtualenvs/space-app-phFju0DF/lib/python3.6/site-packages (from pipenv==2018.10.13->-r requirements.txt (line 1)) (39.1.0)
Collecting virtualenv (from pipenv==2018.10.13->-r requirements.txt (line 1))
Downloading http://localhost:3141/root/pypi/+f/8b9/abfc51c38b70f/virtualenv-16.4.0-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 34.0MB/s
Installing collected packages: certifi, virtualenv-clone, virtualenv, pipenv
The script virtualenv-clone is installed in './bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The script virtualenv is installed in './bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The scripts pipenv and pipenv-resolver are installed in './bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed certifi-2018.11.29 pipenv-2018.10.13 virtualenv-16.4.0 virtualenv-clone-0.5.1
Running post-build hooks
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
python: can't open file 'manage.py': [Errno 2] No such file or directory
Backing up previous build to: /home/user/Dev/space-app/.platform/local/builds/default-old.tar.gz
Creating symbolic links to mimic shared file mounts
Symlinking logs to .platform/local/shared/logs
Build complete for application app
Web root: /home/user/Dev/space-app/_www
Cleaning up...
我要添加我的.platform.app.yaml
:
name: 'app'
type: 'python:3.6'
dependencies:
python3:
pip: '19.0.2'
# pipenv: '2018.10.13'
relationships:
database: "postgresqldb:postgresql"
web:
upstream:
socket_family: unix
commands:
start: "gunicorn -w 4 -b unix:$SOCKET myapp.wsgi:application"
locations:
"/":
passthru: true
"/static":
root: "static"
expires: 1h
allow: true
disk: 512
mounts:
'logs':
source: local
source_path: logs
hooks:
build: |
pip install -r requirements.txt
# pipenv install --system --deploy
mkdir logs
python manage.py collectstatic
rm -rf logs
deploy: |
python manage.py migrate
谢谢。
答案 0 :(得分:1)
我非常建议您运行某种virtualenv。.并且您已经安装了pipenv ...我不会混合使用系统python和该项目的python ...
以下内容在本地和服务器上应该都能很好地工作...
hooks:
build: |
pipenv install -r requirements.txt
pipenv run python manage.py collectstatic
deploy: |
pipenv run python manage.py migrate