From 68d7fad707c63f699050623366c7009e69eb4130 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 9 Feb 2022 13:58:04 +0100 Subject: [PATCH 1/5] Remove conda devlop. --- docs/source/tutorials/how_to_set_up_a_project.rst | 6 ++---- src/_pytask/collect.py | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/tutorials/how_to_set_up_a_project.rst b/docs/source/tutorials/how_to_set_up_a_project.rst index bdfb146da..bd61207cc 100644 --- a/docs/source/tutorials/how_to_set_up_a_project.rst +++ b/docs/source/tutorials/how_to_set_up_a_project.rst @@ -120,10 +120,6 @@ Then, install the package into your environment with .. code-block:: console - $ conda develop . - - # or - $ pip install -e . Both commands will produce an editable install of the project which means any changes in @@ -138,6 +134,8 @@ the source files of the package are reflected in the installed version of the pa For a more sophisticated setup where versions are managed via tags on the repository, check out `setuptools_scm `_. + The tool is also used in `cookiecutter-pytask-project + `_. Further Reading diff --git a/src/_pytask/collect.py b/src/_pytask/collect.py index d56b5f282..bcd3e6286 100644 --- a/src/_pytask/collect.py +++ b/src/_pytask/collect.py @@ -52,6 +52,8 @@ def pytask_collect(session: Session) -> bool: session=session, reports=session.collection_reports, tasks=session.tasks ) + breakpoint() + return True From 273dc90bdc59d726e9ffaf4d68dd501f24624d53 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Wed, 9 Feb 2022 14:01:43 +0100 Subject: [PATCH 2/5] Remove breakpoint. --- src/_pytask/collect.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/_pytask/collect.py b/src/_pytask/collect.py index bcd3e6286..d56b5f282 100644 --- a/src/_pytask/collect.py +++ b/src/_pytask/collect.py @@ -52,8 +52,6 @@ def pytask_collect(session: Session) -> bool: session=session, reports=session.collection_reports, tasks=session.tasks ) - breakpoint() - return True From 6fda33ce4a2d67756a139f6ccd9e4e92baa85429 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 10 Feb 2022 01:04:27 +0100 Subject: [PATCH 3/5] Align the installation of the project with setuptools quickstart. --- .../tutorials/how_to_set_up_a_project.rst | 64 +++++++++++++------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/docs/source/tutorials/how_to_set_up_a_project.rst b/docs/source/tutorials/how_to_set_up_a_project.rst index bd61207cc..ed0ded70f 100644 --- a/docs/source/tutorials/how_to_set_up_a_project.rst +++ b/docs/source/tutorials/how_to_set_up_a_project.rst @@ -8,7 +8,8 @@ of the most elementary pieces. .. seealso:: - If you want to start from a template or take inspiration from previous projects, look at :doc:`../how_to_guides/bp_templates_and_projects`. + If you want to start from a template or take inspiration from previous projects, + look at :doc:`../how_to_guides/bp_templates_and_projects`. The directory structure @@ -26,7 +27,9 @@ The following directory tree is an example of how a project can be set up. │ ├────config.py │ └────... │ - ├───setup.py + ├───setup.cfg + │ + ├───pyproject.toml │ ├───.pytask.sqlite3 │ @@ -94,40 +97,59 @@ The build directory ``bld`` is created automatically during the execution. It is to store the products of tasks and can be deleted to rebuild the entire project. -``setup.py`` -~~~~~~~~~~~~ +Install the project +~~~~~~~~~~~~~~~~~~~ -The ``setup.py`` is useful to turn the source directory into a Python package. It allows -to perform imports from ``src``. E.g., ``from src.config import SRC``. +Some files are necessary to turn the source directory into a Python package. It allows +to perform imports from ``my_project``. E.g., ``from my_project.config import SRC``. -Here is the content of the file. +For that, we need two files. First, we need a ``setup.cfg`` which contains the name and +version of the package and where the source code can be found. -.. code-block:: python +.. code-block:: ini + + # Content of setup.cfg + + [metadata] + name = my_project + version = 0.0.1 - # Content of setup.py + [options] + packages = find: + package_dir = + =src - from setuptools import setup + [options.packages.find] + where = src +Secondly, you need a ``pyproject.toml`` with this content: - setup( - name="my_project", - version="0.0.1", - packages=find_packages(where="src"), - package_dir={"": "src"}, - ) +.. code-block:: toml -Then, install the package into your environment with + # Content of pyproject.toml + + [build-system] + requires = ["setuptools"] + build-backend = "setuptools.build_meta" + +.. seealso:: + + You find this and more information in the documentation for `setuptools + `_. + +Now, you can install the package into your environment with .. code-block:: console $ pip install -e . -Both commands will produce an editable install of the project which means any changes in -the source files of the package are reflected in the installed version of the package. +This command will trigger an editable install of the project which means any changes in +the source files of the package are immediately reflected in the installed version of +the package. -.. tip:: +.. important:: - Do not forget to rerun the editable install every time you recreate your Python + Do not forget to rerun the editable install should you recreate your Python environment. .. tip:: From c23abdcd6d4a09e362a2fa65a18e82dac1aefea1 Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 10 Feb 2022 01:09:39 +0100 Subject: [PATCH 4/5] fix. --- docs/source/tutorials/how_to_set_up_a_project.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/source/tutorials/how_to_set_up_a_project.rst b/docs/source/tutorials/how_to_set_up_a_project.rst index ed0ded70f..51577812c 100644 --- a/docs/source/tutorials/how_to_set_up_a_project.rst +++ b/docs/source/tutorials/how_to_set_up_a_project.rst @@ -100,11 +100,12 @@ to store the products of tasks and can be deleted to rebuild the entire project. Install the project ~~~~~~~~~~~~~~~~~~~ -Some files are necessary to turn the source directory into a Python package. It allows -to perform imports from ``my_project``. E.g., ``from my_project.config import SRC``. +Two files are necessary to turn the source directory into a Python package. It allows to +perform imports from ``my_project``. E.g., ``from my_project.config import SRC``. We +also need ``pip >= 21.1``. -For that, we need two files. First, we need a ``setup.cfg`` which contains the name and -version of the package and where the source code can be found. +First, we need a ``setup.cfg`` which contains the name and version of the package and +where the source code can be found. .. code-block:: ini From 917fc2000c8c974a56eedf267761221cbede036f Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Thu, 10 Feb 2022 12:04:08 +0100 Subject: [PATCH 5/5] Update changes.rst --- docs/source/changes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/changes.rst b/docs/source/changes.rst index 04642ab5e..5d852c26d 100644 --- a/docs/source/changes.rst +++ b/docs/source/changes.rst @@ -14,6 +14,7 @@ all releases are available on `PyPI `_ and exception as an input. Closes :gh:`145`. - :gh:`213` improves coverage and reporting. - :gh:`215` makes the help pages of the CLI prettier. +- :gh:`217` enhances the tutorial on how to set up a project. 0.1.7 - 2022-01-28