- We use
uv, install it if you do not yet have it. Run these commands:
mkdir [project-name] # this will make a folder for your project
cd [project-name] # this will go into the folder. If using VSCode, you can open the folder in VSCode with `code [project-name]`
uv init --package # this creates a package with the name of the folder ([project-name])- Install
ruff,pre-commitandtyas dev dependencies in thepyproject.tomlfile. This is done by running:
uv add ruff pre-commit ty --dev- Copy the
.pre-commit-config.yamland.gitignorefile from this repo to the root of your project, overwriting the.gitignorefile generated withuv init --package. In the future, remember to actively edit the.gitignorefile if the need arises in order to prevent repo clutter. Then you can run:
uv run pre-commit install- Create a new repo in the ReLU-NTNU organisation on GitHub. You do not need to add a license,
.gitignore, orREADME.md. Then, copy the URL of the repo which should appear after creating the repo. This should look something likehttps://github.com/ReLU-NTNU/solution-seeker.git. Then, set up git for your project with these commands:
git remote add origin [url]
git add .
git commit -m "initial commit"
git push -u origin main- When a new developer clones the repository, they will need to do a few things. Assuming they are using
uv:
uv sync # this creates a virtual environment and installs the dependencies
source .venv/bin/activate # this activates the virtual environment in the terminal. If using VSCode, you should also select the virtual environment in the bottom left corner, or using the "Python: Select Interpreter" VSCode command
uv run pre-commit install # this installs the pre-commit hooks-
pre-commitwill now run every time the user tries to commit changes to the repository. If the pre-commit hooks fail, the user will not be able to commit the changes. This is to maintain main branch protection and code quality. Tests hooks could also be added here, but that is not included in this repo. The pre-commit hooks should fix the files it found an error with, so if the developer stages the file again with for examplegit add [file-name], the pre-commit hooks should pass. -
It is recommended to get a basic understanding of how to use
uv. Especially, you have to add dependencies in the right way usinguv add {package-name}anduv add {package-name} --devfor development dependencies. -
Remember to create a
scripts/andnotebooks/folder when you need to store scripts and notebooks. -
Using the
--packageflag when creating a new project withuvwill create a function insrc/{package-name}/__init__.pythat can be run withuv run {package-name}because of the reference created inpyproject.tomlunder[project.scripts]. This is useful for running the application you are developing.