-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Description | ||
Creates an isolated development enviroment for developing your own python project. | ||
|
||
|
||
### How to use | ||
|
||
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) | ||
|
||
To add new python packages to your project, modify `pyproject.toml` and re-run steps 2 and 3. | ||
|
||
To integrate with your IDE, run `which python` from within the activated development environment, and point the interpreter path in your IDE to its output. Make sure to run/start your IDE from within the activated development environment, so it will be able to find the installed python packages. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ in { | |
]; | ||
|
||
deps = {nixpkgs, ...}: { | ||
python = nixpkgs.python310; | ||
python = nixpkgs.${pyproject.tool.dream2nix.python-version}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we could parse the python version directly from the |
||
}; | ||
|
||
inherit (pyproject.project) name version; | ||
|
@@ -24,12 +24,12 @@ in { | |
buildPythonPackage = { | ||
format = lib.mkForce "pyproject"; | ||
pythonImportsCheck = [ | ||
"my_tool" | ||
pyproject.tool.dream2nix.project-folder | ||
]; | ||
}; | ||
|
||
pip = { | ||
pypiSnapshotDate = "2023-08-27"; | ||
pypiSnapshotDate = pyproject.tool.dream2nix.pypi-snapshot-date; | ||
requirementsList = | ||
pyproject.build-system.requires | ||
or [] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import requests | ||
|
||
|
||
print("Hello World!") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,13 @@ build-backend = "setuptools.build_meta" | |
name = "my-tool" | ||
description = "my tool" | ||
version = "1.0.0" | ||
|
||
requires-python = ">=3.11.0" | ||
dependencies = [ | ||
"requests" | ||
"requests", | ||
] | ||
|
||
[tool.dream2nix] | ||
project-folder = "my_project" | ||
python-version = "python311" | ||
pypi-snapshot-date = "2024-03-01" | ||
Comment on lines
+15
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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. |
There was a problem hiding this comment.
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