Move configuration of python version and project name into pyproject.toml - #817
Move configuration of python version and project name into pyproject.toml#817mathijssh wants to merge 4 commits into
Conversation
- Python version - Project folder - PyPi snapshot date into the `pyproject.toml` configuration file. Leverages the possibility to create arbitrary configuration in the [tool] table (more info: https://packaging.python.org/en/latest/specifications/pyproject-toml/#arbitrary-tool-configuration-the-tool-table)
|
P.S. Apologies, I seem to have made a slight mistake by directly committing my changes to |
DavHau
left a comment
There was a problem hiding this comment.
This approach inspired me and I would like to pick up your idea with [tool.dream2nix] and implement in in a more generic way.
If you can change this PR to just add the relevant readme changes without the tool.dream2nix part, I'm happy to merge it.
P.S. Apologies, I seem to have made a slight mistake by directly committing my changes to main (even though I forked the repo). Please let me know in case you would like me to close it and re-open with a PR from a feature branch.
No worries, it is not relevant to me as a maintainer which branch name you use on your fork since your branches never directly affect what's going on at dream2nix upstream.
|
|
||
| 1. Modify `pyproject.toml` according to your project, and optionally rename the `my_project` directory | ||
| 2. Enable environment `$ nix develop --impure` to start shell environment (will build all dependencies on first run and after any updates) | ||
| 3. Update the `lock.json` by running the command generated by dream2nix (see terminal output, `bash -c $(nix-build...` or something similar) |
There was a problem hiding this comment.
An easier command to update the lock file is nix run .#default.lock
| [tool.dream2nix] | ||
| project-folder = "my_project" | ||
| python-version = "python311" | ||
| pypi-snapshot-date = "2024-03-01" |
There was a problem hiding this comment.
While I like this idea in general, I would like to implement this in a more generic way, so that everything from, for example tool.draem2nix.config gets mapped to the package's config.
For now I'd prefer not to add these, because we will have to deprecate them again once the generic implementation is in place, and users will face breakages.
|
|
||
| deps = {nixpkgs, ...}: { | ||
| python = nixpkgs.python310; | ||
| python = nixpkgs.${pyproject.tool.dream2nix.python-version}; |
There was a problem hiding this comment.
I think we could parse the python version directly from the requires_python field using pyproject.nix.
But maybe this can be done in a separate PR.
If you are interested in working on this, you can see how to access the pyproject.nix library if you look at the WIP-python-pdm module as an example that already uses this lib (it doesn't parse yet the python version, though).
Moved configuration of
- Python version
- Project folder
- PyPi snapshot date
into the
pyproject.tomlconfiguration file. Leverages the possibility to create arbitrary configuration in the [tool] table (more info: https://packaging.python.org/en/latest/specifications/pyproject-toml/#arbitrary-tool-configuration-the-tool-table).Also added a short README.md.