Skip to content
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

Move configuration of python version and project name into pyproject.toml #817

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mathijssh
Copy link

Moved configuration of
- 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).

Also added a short README.md.

- 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)
@mathijssh
Copy link
Author

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.

Copy link
Member

@DavHau DavHau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An easier command to update the lock file is nix run .#default.lock

Comment on lines +15 to +18
[tool.dream2nix]
project-folder = "my_project"
python-version = "python311"
pypi-snapshot-date = "2024-03-01"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@@ -12,7 +12,7 @@ in {
];

deps = {nixpkgs, ...}: {
python = nixpkgs.python310;
python = nixpkgs.${pyproject.tool.dream2nix.python-version};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@phaer phaer added the python label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants