现代化的python项目模版
Project description
modern python project
create a repository in github
- gitignore
- license
- readme
global tools
pyenv
brew install pyenv
# modify shell
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
# build dependencies of python
brew install openssl readline sqlite3 xz zlib
source ~/.bash_profile
python
pyenv install 3.9.0
# make python version in local directory
pyenv local 3.9.0
poetry
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
-
open a new shell, initialize python project
peotry init -n
-
修改
project.toml
-
增加
src
, 在其中增加modern_python
package repository --> kebab casemodern-python
python package --> snake casemodern_python
-
__init__.py
# src/modern_python/__init__.py __version__ = "0.1.0"
-
创建python虚拟环境
poetry install # run python inside the new venv poetry run python
-
添加依赖
poetry add click
initial code
在 src/modern_python
中创建 console.py
在 project.toml
中
[tool.poetry.scripts]
modern-python = "modern_python.console:main"
# install
poetry install
# run
poetry run modern-python
添加 requests
test
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
modern-python-0.3.1.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for modern_python-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae679c192c640a8bced637242350f8af1278ad41f1b0d7c7c18eab66e2b11f44 |
|
MD5 | 6cdd013e8c1b66ac0a93d9c69fe97971 |
|
BLAKE2b-256 | 3264c74d91b46cfc2ae0b5c6424b1b4cf911751e24f67f0b0bd311f39bd4ca4b |