-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add "Project best practices" page #1760
base: main
Are you sure you want to change the base?
Conversation
…H/ecosystem-best-practices
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.
Great work!
hosting platform. GitHub is based on [Git](https://git-scm.com/) (a version | ||
control system) and provides a large set of tools to help collaborate on your | ||
project and keep it to a high quality. See [Github |
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.
hosting platform. GitHub is based on [Git](https://git-scm.com/) (a version | |
control system) and provides a large set of tools to help collaborate on your | |
project and keep it to a high quality. See [Github | |
hosting platform. GitHub is based on [Git](https://git-scm.com/), a version | |
control system. It provides a large set of tools to collaborate and | |
maintain high quality. See [Github |
and a [code of | ||
conduct](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-code-of-conduct-to-your-project). | ||
|
||
* **GitHub actions** |
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.
* **GitHub actions** | |
* **GitHub actions** |
conduct](https://docs.github.com/en/communities/setting-up-your-project-for-healthy-contributions/adding-a-code-of-conduct-to-your-project). | ||
|
||
* **GitHub actions** | ||
|
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.
Software projects benefit from using continuous integration (CI) and continuous deployment (CD): | |
* [Continuous integration](https://www.atlassian.com/continuous-delivery/continuous-integration): automating the integration of changes to your code, including through the use of automated tests to ensure your changes do not break the project. | |
* [Continuous deployment](https://www.ibm.com/topics/continuous-deployment): automation of your deployment/release process. Often, continuous deployment can be semi-automated, such as requiring a human to initiate the deployment. |
|
||
* **GitHub actions** | ||
|
||
This feature runs scripts when certain events happen in your GitHub repo. For |
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.
This feature runs scripts when certain events happen in your GitHub repo. For | |
GitHub Actions allows you to use both CI and CD in your project by providing | |
you a free cloud-based runner to run scripts and tests when certain events | |
happen in your GitHub repo, such as opening a pull request. For |
– to make sure code meets some criteria before being pushed to certain | ||
branches. | ||
|
||
The rest of this page will assume you have your project hosted on GitHub. |
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.
The rest of this page will assume you have your project hosted on GitHub. | |
The rest of this page will assume you have your project hosted on GitHub, although | |
you are welcome to other providers like GitLab. |
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.
The rest of this page will assume you have your project hosted on GitHub. | |
The rest of this page will assume you have your project hosted on GitHub, although | |
you are welcome to use other providers like GitLab. |
* Python's built-in [`unittest`](https://docs.python.org/3/library/unittest.html) | ||
|
||
You can also consider using [`tox`](https://tox.wiki/en/4.18.0/) to test your | ||
project against different versions of Python. |
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.
project against different versions of Python. | |
project against different versions of Python. Tox | |
[can be used](https://python-poetry.org/docs/faq/#is-tox-supported) with Poetry. |
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.
Consider instead "Tox is compatible with Poetry" to avoid passive voice
[`bandit`](https://bandit.readthedocs.io/en/latest/) for security scanning. | ||
|
||
Once you've set your tools up, you can use a [GitHub action](#github) to make | ||
sure all code pushed to your repository has been linted. |
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.
sure all code pushed to your repository has been linted. | |
sure all code pushed to your repository has been linted. | |
Document how to run the linters and formatters in your README.md or CONTRIBUTOR.md. |
A linter is a tool that detects (and sometimes corrects) common problems in | ||
your code. A popular linter for Python is | ||
[`ruff`](https://docs.astral.sh/ruff/). Other popular tools include | ||
[`mypy`](https://www.mypy-lang.org/) for type-checking, and | ||
[`bandit`](https://bandit.readthedocs.io/en/latest/) for security scanning. |
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.
A linter is a tool that detects (and sometimes corrects) common problems in | |
your code. A popular linter for Python is | |
[`ruff`](https://docs.astral.sh/ruff/). Other popular tools include | |
[`mypy`](https://www.mypy-lang.org/) for type-checking, and | |
[`bandit`](https://bandit.readthedocs.io/en/latest/) for security scanning. | |
A linter is a tool that detects (and sometimes corrects) common problems in | |
your code. Formatters will auto-format your code to use a consistent style. | |
A popular linter for Python is | |
[`ruff`](https://docs.astral.sh/ruff/), which also | |
includes a formatter (based on the popular tool [Black](https://black.readthedocs.io/en/stable/)). | |
Other popular tools include | |
[`mypy`](https://www.mypy-lang.org/) for type-checking, and | |
[`bandit`](https://bandit.readthedocs.io/en/latest/) for security scanning. |
The simplest way to list your requirements is to put the Python version you're | ||
using in your `README` and include a | ||
[`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) | ||
file in your repository. However, this means you must manually identify your | ||
requirements and keep the file in sync. | ||
|
||
Tools such as [Poetry](https://python-poetry.org/) solve this problem by | ||
managing dependencies for you, which means they can keep track of everything | ||
you've installed. Installing a dependency through Poetry will add it to a | ||
"lock" file, which keeps track of the exact versions of each package you have | ||
installed. Users can use the lockfile to replicate your environment. |
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.
The simplest way to list your requirements is to put the Python version you're | |
using in your `README` and include a | |
[`requirements.txt`](https://pip.pypa.io/en/stable/reference/requirements-file-format/) | |
file in your repository. However, this means you must manually identify your | |
requirements and keep the file in sync. | |
Tools such as [Poetry](https://python-poetry.org/) solve this problem by | |
managing dependencies for you, which means they can keep track of everything | |
you've installed. Installing a dependency through Poetry will add it to a | |
"lock" file, which keeps track of the exact versions of each package you have | |
installed. Users can use the lockfile to replicate your environment. | |
Traditionally, many Python projects use a `requirements.txt` file to list the project's dependencies. | |
You may also see `requirements-dev.txt` to list dependencies only used for contributing to | |
the project, such as linters or test runners. This approach can be fine, but it has two issues: | |
1) no "lockfiles", and 2) you still need to set up metadata about your project. | |
Instead of the traditional requirements.txt approach, build tools such as [Poetry](https://python-poetry.org/) improve dependency management. Poetry also ensures that you properly set up metadata for your project, | |
such as which Python versions you support; this metadata is necessary to | |
[package your project](#package-your-project). | |
Installing a dependency through Poetry will add it to a "lockfile", | |
which keeps track of the exact versions of each package you have | |
installed. Lockfiles are crucial for | |
["supply chain security"](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-supply-chain-security). | |
Lockfiles also ensure that your project will not break overnight due to new releases of dependencies | |
breaking your project; with a lockfile, your dependencies will only change when you intentionally upgrade. |
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.
@Eric-Arellano Is it important to put "supply chain security" in quotes? I'd leave them off unless it's confusing otherwise.
|
||
## Dependency management | ||
|
||
If you don't clearly specify your project's dependencies, users (including your |
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.
If you don't clearly specify your project's dependencies, users (including your | |
Most projects depend on other projects, such as Qiskit or NumPy. | |
If you don't clearly specify your project's dependencies, users (including your |
@@ -39,6 +39,15 @@ | |||
"url": "https://github.com/Qiskit/qiskit/blob/main/MAINTAINING.md" | |||
} | |||
] | |||
}, | |||
{ | |||
"title": "Creating a Qiskit-based project", |
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.
"title": "Creating a Qiskit-based project", | |
"title": "Create a Qiskit-based project", |
Sometimes it feels awkward to do so but we try to avoid -ing in titles for consistency and to clearly suggest action
@@ -0,0 +1,132 @@ | |||
--- | |||
title: Project setup and best practices | |||
description: Testing, packaging, and code quality best practices for your Python project. |
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.
description: Testing, packaging, and code quality best practices for your Python project. | |
description: Testing, packaging, and code-quality best practices for your Python project. |
all of which improve your users' experience. If you're releasing research code, | ||
following best practices will also help others reproduce your results. | ||
|
||
Once you've polished it up, consider adding your project to the [Qiskit |
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.
Once you've polished it up, consider adding your project to the [Qiskit | |
Once you've put the finishing touches on it, consider adding your project to the [Qiskit |
|
||
Some key features are: | ||
|
||
* **Issues and Pull requests** |
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.
* **Issues and Pull requests** | |
* **Issues and pull requests** |
|
||
This feature runs scripts when certain events happen in your GitHub repo. For | ||
example, you can run your [test suite](#test-your-project) when you push new | ||
code or automatically [publishing your package](#package-your-project) when |
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.
code or automatically [publishing your package](#package-your-project) when | |
code or automatically [publish your package](#package-your-project) when |
[`mypy`](https://www.mypy-lang.org/) for type-checking, and | ||
[`bandit`](https://bandit.readthedocs.io/en/latest/) for security scanning. | ||
|
||
Once you've set your tools up, you can use a [GitHub action](#github) to make |
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.
Once you've set your tools up, you can use a [GitHub action](#github) to make | |
Once you've set up your tools, you can use a [GitHub action](#github) to make |
Adds a new page on best practices for ecosystem projects.
Link to preview