【发布时间】:2019-02-11 14:39:39
【问题描述】:
我正在试验 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
提前致谢。
【问题讨论】:
-
find . -regex '.*requirements.txt$'给你什么? -
find . -regex '.*requirements.txt$'./requirements.txt ./.platform/local/deps/python3/requirements.txt -
你的构建钩子里有什么?当您自己运行它而不是使用
platform build时会发生什么? -
Royall,我只有
pip install -r requirements.txt指令。显然我需要在运行它之前更改目录。我正在再次阅读文档,因为我似乎还缺少其他东西:docs.platform.sh/configuration/app/build.html#hooks。在本地/手动运行我的应用程序效果很好。我希望相同的 .platform.app.yaml 可以在本地和远程工作。