admin管理员组文章数量:1026989
I have a Python project with a flat layout that has some resource files. My pyproject.toml
has the following entries:
[tool.setuptools]
packages = [
"linton",
"linton.subcommand",
]
[tool.setuptools.package-data]
linton = ["init-pages/**"]
and the following layout:
linton
├── argparse_util.py
├── init-pages
│ ├── Author.in.txt
│ ├── body.in.md
│ ├── breadcrumb.in.py
│ ├── email.in.py
│ ├── Email.in.txt
│ ├── index.nancy.html
│ ├── lastmodified.in.py
│ ├── markdown-to-html.in.sh
│ ├── menudirectory.in.py
│ ├── pageinsite.in.py
│ ├── path-to-root.in.py
│ ├── Sample page
│ │ ├── body.in.md
│ │ └── index.nancy.html
│ ├── style.css
│ ├── template.in.html
│ └── Title.in.txt
├── __init__.py
├── __main__.py
├── subcommand
│ ├── init.py
│ ├── publish.py
│ └── serve.py
└── warnings_util.py
Note the init-pages
directory: it contains resource files for a linton init
command, which, like many similar tools, creates a template project (in this case, a web site), and copies files into it (the contents of init-pages
).
Also note that init-pages
contains some .py
files.
Packaging this project works fine: the source files and resource files are included as expected by pip.
The surprise to me is that when I pip install
this project, pip compiles the .py
files in the init-pages
directory, although this directory is not included in packages
and is only marked as package data.
I am unable to find any documentation about how pip decides which files to byte-compile on installation. I can turn it off globally, but of course I don't want to do that, and it doesn't help my users.
I could also work around the problem by making linton init
skip the generated __pycache__
directory when copying the resource files into the user's project. But it seems wrong that they exist in the first place, and I would like to prevent this.
I have a Python project with a flat layout that has some resource files. My pyproject.toml
has the following entries:
[tool.setuptools]
packages = [
"linton",
"linton.subcommand",
]
[tool.setuptools.package-data]
linton = ["init-pages/**"]
and the following layout:
linton
├── argparse_util.py
├── init-pages
│ ├── Author.in.txt
│ ├── body.in.md
│ ├── breadcrumb.in.py
│ ├── email.in.py
│ ├── Email.in.txt
│ ├── index.nancy.html
│ ├── lastmodified.in.py
│ ├── markdown-to-html.in.sh
│ ├── menudirectory.in.py
│ ├── pageinsite.in.py
│ ├── path-to-root.in.py
│ ├── Sample page
│ │ ├── body.in.md
│ │ └── index.nancy.html
│ ├── style.css
│ ├── template.in.html
│ └── Title.in.txt
├── __init__.py
├── __main__.py
├── subcommand
│ ├── init.py
│ ├── publish.py
│ └── serve.py
└── warnings_util.py
Note the init-pages
directory: it contains resource files for a linton init
command, which, like many similar tools, creates a template project (in this case, a web site), and copies files into it (the contents of init-pages
).
Also note that init-pages
contains some .py
files.
Packaging this project works fine: the source files and resource files are included as expected by pip.
The surprise to me is that when I pip install
this project, pip compiles the .py
files in the init-pages
directory, although this directory is not included in packages
and is only marked as package data.
I am unable to find any documentation about how pip decides which files to byte-compile on installation. I can turn it off globally, but of course I don't want to do that, and it doesn't help my users.
I could also work around the problem by making linton init
skip the generated __pycache__
directory when copying the resource files into the user's project. But it seems wrong that they exist in the first place, and I would like to prevent this.
本文标签: How can I stop resource files that are Python source from being compiled by pipStack Overflow
版权声明:本文标题:How can I stop resource files that are Python source from being compiled by pip? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745669546a2162378.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论