-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for data_files #890
Comments
I used data_files to ship systemd unit file. This is a very important feature ! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@sdispater I guess this would wait for post 1.0, right ? |
This is critical for a (basic) gui app |
Do I understand correctly, that data_files that live next to the package modules are supported? So, this layout should work and config_data.csv will be packaged?
|
Every time I jump head first into a new tool, I smash my face into the bottom of the pool. |
This should now be covered by https://python-poetry.org/docs/pyproject/#include-and-exclude. If this is not the case, please feel free to comment here or open a new issue with the specific scenario not covered. |
that doesn't let you specify where they should go? how are users supposed to install a .desktop for DE integration? |
There are at least two use cases:
AIUI include/exclude mechanism do not match either, they just add it to the package Now, substantially, if my package is going to be installed in Those two use cases specify something as much required to be able to move from setuptools, as not implemented yet in poetry. note: package_data can be implemented with include, but does not provide a lot of flexibility. we have to hardcode lots of path, pacakge_data is package oriented (as make sense to be, managing packaging). also the empty package '' use case is extremely important: |
@kalfa, as you later realized, include/exclude matches exactly the first use case you linked, package data. Can you provide a concrete example of package data that is easy to do with setuptools but difficult with Poetry? |
Package data is less expressive with include/exclude and more difficult to read. Setup tools approach is more compact and readable
With poetry I have to specify a list of more obscure patterns. But for simple enough projects, is good enough. As you said, i understood later the potentiality. What is missing is the other use case, which this ticket is about, and has been closed and IMHO should be reopened I'm porting setup.py files to pyproject.toml and trying to build the same wheel. Happy to find out I'm wrong and it's possible |
Yeah .desktop files need explicit support and I don't think poetry has a
way to install them into the appropriate /usr/share/applications folder.
…On Fri, May 29, 2020, 16:14 Cosimo Alfarano ***@***.***> wrote:
Package data is less expressive with include/exclude and more difficult to
read.
Overall it is possible to achieve most if not all use cases.
Setup tools approach is more compact and readable
- Install the directory asset in each package.
- install the directory foo in package X
'':'assets/*',
'X':'foo/*'
With poetry I have to specify a list of more obscure patterns. But for
simple enough projects, is good enough. As you said, i understood later the
potentiality.
What is missing is the other use case, which this ticket is about, and has
been closed and IMHO should be reopened
I'm porting setup.py files to pyproject.toml and trying to build the same
wheel. Happy to find out I'm wrong and it's possible
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#890 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABLU44JYVWSTC7TRT6OUSTRUAJS3ANCNFSM4GXACQWQ>
.
|
"data_files" are delivered relative to |
Another use-case is the distribution of man pages with the package. |
I tried to move a unix console app following FHS from setuptools to poetry but was stuck in this issue and looks like will have to rollback :( @kalfa in the post above you wrote that
Could you please provide an example of how I can achieve this with poetry:
|
I don't think you can yet (unless in the meantime I wrote my comments it's been implemented and I'm unaware of it). Only package_data has a way in poetry. What you mentioned is the same use case of desktop files & co. |
From my point of view (and many others) using The idea that pip-installing a project could result in files being written to random locations on the local file system is discomforting. Things like: It is true, that there is a need for such things, in particular for applications. But from what I understood Python's packaging ecosystem was initially built with libraries in mind, applications were (and still very much are) some kind of second class citizens in a sense. So packaging applications in order to distribute them on PyPI is still very awkward. There are many other issues showing this divide between libraries and applications all around the Python packaging ecosystem in general, poetry included (but not poetry's fault in any sense, as far as I have seen). My usual recommendation when something like The setuptools I will also add that for things such as configuration files, user data files, cache files, etc. you should have a look at So, in short: |
To add onto @sinoroc's excellent explanation, remember that Python is a cross-platform language. People install Python software on Windows, and if you publish an application on PyPI, Windows users might expect that it will work on their system. If you install platform-specific files (e.g. |
@sinoroc From what I see in this issue, it looks like the reason
Even without Additionally, Your recommendation for using tools like pyinstaller, briefcase, Debian packages, etc. isn't really possible for application developers in a lot of cases. If, for example, an application wanted to support only Linux, there are still a lot of different kinds of package formats that the application developer would have to support. For that reason, distribution-specific package formats are usually created and maintained specifically for those distributions by someone on behalf of the distribution, rather than the maintainer of the application. Also, many of these formats take advantage of using the application's setuptools setup to install data files (see for example pybuild).
@thejohnfreeman To address your concern of Linux-only applications on PyPI, it is not a requirement that Poetry packages are published to PyPI. A lot of applications won't be. Also, PyPI has classifiers to mark applications as supporting only Linux. Users should not be blindly installing applications from PyPI --- that is a recipe for disaster. |
@thomassross I totally understand your point of view. But my point still stands: I do not believe There are obviously very legitimate use cases where So I would side on not adding support for |
I am interested in
Neither Was this closed because there has been no work on it? Or was it closed because a PR to add this feature would be rejected? |
It seems that |
@N-Coder , can you open another bug explicitly about jupyther and mentioning this bug please? This bug is now closed, but I think it is still worth it underlining |
I guess #4013 describes the issue from the Jupyter side or would you want a feature request for replicating the |
Hello! I'm trying to assess how this feature would be used generally. Hatchling supports a |
In my case, I need to install a manpage and a zsh completion file, so for me, yes. |
@ofek the link you provided results in a 404 error. I think the following links to what you intended: https://hatch.pypa.io/latest/plugins/builder/#options |
Thanks! Hatch was adopted by the PyPA so the docs site was moved. |
I created a poetry plugin that adds support for data_files in pyproject.toml: https://github.com/spoorn/poeblix, https://pypi.org/project/poeblix/ |
@spoorn did you get a jupyter plugin packaged with poetry working with your plugin. Do you have an example? |
@spoorn, it's an incredible amount of work you've done! I think you should ask maintainers to mention this plugin in docs somehow. |
@N-Coder I got this working with nbconvert template files. Example: https://github.com/spoorn/poeblix/blob/main/test/positive_cases/happy_case_example/pyproject.toml @droserasprout Thanks! Up to the poetry maintainers |
Update our pyproject.toml file to include some non-Python data files, e.g., our container image and assets. This way, we can use `poetry build` to create a source distribution / Python wheel from our source repository. Note that this list of data files is already defined in our `setup.py` script. In that script, one can find some extra goodies: 1. We can conditionally include data files in our Python package. We use this to include Qubes data only in our Qubes packages. 2. We can specify where will the data files be installed in the end-user system. The above are non-goals for Poetry [1], especially (2), because modern Python wheels are not supposed to install files in arbitrary places within the user's host, nor should the install invocation use sudo. Instead, this is a task that's better suited for the .deb / .rpm packages. So, why do we bother updating our `pyproject.toml` and not use `setup.py` instead? Because `setup.py` is deprecated [2,3], and the latest Python packaging RFCs [4], as well as most recent Fedora guidelines [5] use `pyproject.toml` as the source of truth, instead of `setup.py`. In subsequent commits, we will also use just `pyproject.toml` for RPM packaging. [1]: python-poetry/poetry#890 [2]: https://peps.python.org/pep-0517/#source-trees [3]: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html [4]: https://peps.python.org/pep-0517/ [5]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/
Update our pyproject.toml file to include some non-Python data files, e.g., our container image and assets. This way, we can use `poetry build` to create a source distribution / Python wheel from our source repository. Note that this list of data files is already defined in our `setup.py` script. In that script, one can find some extra goodies: 1. We can conditionally include data files in our Python package. We use this to include Qubes data only in our Qubes packages. 2. We can specify where will the data files be installed in the end-user system. The above are non-goals for Poetry [1], especially (2), because modern Python wheels are not supposed to install files in arbitrary places within the user's host, nor should the install invocation use sudo. Instead, this is a task that's better suited for the .deb / .rpm packages. So, why do we bother updating our `pyproject.toml` and not use `setup.py` instead? Because `setup.py` is deprecated [2,3], and the latest Python packaging RFCs [4], as well as most recent Fedora guidelines [5] use `pyproject.toml` as the source of truth, instead of `setup.py`. In subsequent commits, we will also use just `pyproject.toml` for RPM packaging. [1]: python-poetry/poetry#890 [2]: https://peps.python.org/pep-0517/#source-trees [3]: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html [4]: https://peps.python.org/pep-0517/ [5]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/
Update our pyproject.toml file to include some non-Python data files, e.g., our container image and assets. This way, we can use `poetry build` to create a source distribution / Python wheel from our source repository. Note that this list of data files is already defined in our `setup.py` script. In that script, one can find some extra goodies: 1. We can conditionally include data files in our Python package. We use this to include Qubes data only in our Qubes packages. 2. We can specify where will the data files be installed in the end-user system. The above are non-goals for Poetry [1], especially (2), because modern Python wheels are not supposed to install files in arbitrary places within the user's host, nor should the install invocation use sudo. Instead, this is a task that's better suited for the .deb / .rpm packages. So, why do we bother updating our `pyproject.toml` and not use `setup.py` instead? Because `setup.py` is deprecated [2,3], and the latest Python packaging RFCs [4], as well as most recent Fedora guidelines [5] use `pyproject.toml` as the source of truth, instead of `setup.py`. In subsequent commits, we will also use just `pyproject.toml` for RPM packaging. [1]: python-poetry/poetry#890 [2]: https://peps.python.org/pep-0517/#source-trees [3]: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html [4]: https://peps.python.org/pep-0517/ [5]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/
Update our pyproject.toml file to include some non-Python data files, e.g., our container image and assets. This way, we can use `poetry build` to create a source distribution / Python wheel from our source repository. Note that this list of data files is already defined in our `setup.py` script. In that script, one can find some extra goodies: 1. We can conditionally include data files in our Python package. We use this to include Qubes data only in our Qubes packages. 2. We can specify where will the data files be installed in the end-user system. The above are non-goals for Poetry [1], especially (2), because modern Python wheels are not supposed to install files in arbitrary places within the user's host, nor should the install invocation use sudo. Instead, this is a task that's better suited for the .deb / .rpm packages. So, why do we bother updating our `pyproject.toml` and not use `setup.py` instead? Because `setup.py` is deprecated [2,3], and the latest Python packaging RFCs [4], as well as most recent Fedora guidelines [5] use `pyproject.toml` as the source of truth, instead of `setup.py`. In subsequent commits, we will also use just `pyproject.toml` for RPM packaging. [1]: python-poetry/poetry#890 [2]: https://peps.python.org/pep-0517/#source-trees [3]: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html [4]: https://peps.python.org/pep-0517/ [5]: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Poetry does not current support the setup(data_files:[]) element which allows you to include datafiles which live outside of the package files area. This functionality is generally used for shipping non-code files which might be necessary for your library to run, or for other libraries to build. Examples include protobuf .proto files, avro schemas, thrift idl, etc.
The text was updated successfully, but these errors were encountered: