pyloong / cookiecutter-pythonic-project Goto Github PK
View Code? Open in Web Editor NEWA cookiecutter template for Pythonic project
Home Page: https://pyloong.github.io/cookiecutter-pythonic-project/
License: MIT License
A cookiecutter template for Pythonic project
Home Page: https://pyloong.github.io/cookiecutter-pythonic-project/
License: MIT License
经测试,在 setup.cfg
文件中的 [options.package_data]
指定数据文件后,通过 python -m build
打包,生成的 sdist 源码包中没有数据文件,生成的 whl 二进制包中有数据文件。当相同的数据文件出现 [options.data_files]
中时, sdist 源码包中有数据文件。
根据 Python Packaging User Guide 文档 Including files in source distributions with MANIFEST.in 中有这么一句 all files specified by the package_data and data_files setup() arguments
,只能根据上面结果猜测是两个条件都存在时才有效。
根据 Setuptools 文档 Data Files Support 中有提到,当配置 include_package_data=True
参数时,要加载的数据文件必须在 MANIFEST.in
文件中指定。但继续描述说如果需要更精准的控制数据文件,可以使用 package_data
关键字。我的理解是存在一个 或 的关系,而在 whl 二进制包也确实是这样,只不过 sdist 源码包有区别。
在此做出猜想,要么是打包时,加载逻辑出现了 Bug ,要么是描述有问题。而且现在打包相关的工具在疯狂迭代。所以做出兼容可能是更好的选择吧。
在项目模板中增加 MANIFEST.in
文件,方便配置打包时要加载的数据文件。
一个 Django 项目的示例文件
include MANIFEST.in
include LICENSE
include *.md
graft docs
graft tests
recursive-include src/globiz_rates fixtures/*.json
global-exclude __pycache__
global-exclude *.py[co]
根据 2019-06-04 发布的 PEP 602 - Python的年度发布周期 中描述:
1.5 年(17 个月)开发一个大版本
5 年的支持
Python 3.(X+1).0
在会在Python 3.X.0 Beta 1
发布后,开始新版本的开发。即每年开发一个新版本。
发布路线图:
Python 3.7 的一个重大改动,是将 Asyncio 作为内置模块可用。在后面的 Python 3.8 和 Python 3.9 都对异步做了大量的优化和改进。同时后面两个版本也对类型标注和检查做了很大的改进。
再了解社区情况,现在大量第三方库已经做了对 Python 3.9 的支持,进行了 CI 测试。少量第三方库已经进行了 Python 3.10 的测试。
在操作系统上,Ubuntu 和 Centos 的最新发新版,都自带了 Python 3.9 。据了解, AWS 的一些环境默认也是 Python 3.9 。
鉴于社区使用程度,现在有必要将 Python 的升级计划提上日程。以便未来的新项目能直接从 Python 3.9 开始,减少日后适配项目的数量。
如果交互提示输入的项目名结尾有空格,会出现如下情况:
project_name [My Project]: globiz-rates
project_slug [globiz_rates_]:
自动删除结尾空格
tasks:
The --dev option is deprecated, use the `--group dev` notation instead.
ref: https://python-poetry.org/docs/pyproject/#scripts
config error:
actually:
[tool.poetry.scripts]
my_package_cli = 'my_package.console:run'
gh-action 中 使用 matrix
策略没有正确配置 python 版本,导致在执行 test 时,使用 os 的默认版本 python 3.8
相关资料: Using a matrix for your jobs ,actions/setup-python
- uses: actions/setup-python@v4
with:
python-version: "3.10"
PEP-484 的新特性在社区应用越来越广泛。而且越来越多的工具都在新版本中逐步适配静态类型,并使用 mypy 进行检查。
这么做的目的是为了尽早的在编码阶段发现程序中可能出现的错误。
为了强调 Git 的使用,在项目完成后,默认执行一次 Git 提交。这么做有两个好处:
在 cookiecutter 的 post_hook 中使用多进程调用 Git 的命令行,对项目进行一次初始化提交。
在项目模板中的 gitlab-ci.yml
文件中,仍然使用 python setup.py
构建项目。由于之前已经调整使用 PEP-517 规范,此时应该使用 python -m build
构建
在生成项目时,选择使用 github
的 CI 时,生成的 gitflows 文件有错误存在。
The workflow is not valid. Job deploy depends on unknown job build.
gitflow 中的 deploy
任务依赖的的 build
任务不存在。
deploy
任务依赖 test
任务和 lint
任务
deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'file2mongo'
runs-on: ubuntu-latest
needs:
- test
- linting
使用 base_dir
传递到配置对象中,使用 settings.BASEDIR
是获取不到的,应该使用 settings.BASE_DIR
settings.BASEDIR
-> settings.BASE_DIR
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.