<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: David Dobrinskiy</title>
    <description>The latest articles on DEV Community by David Dobrinskiy (@ddobrinskiy).</description>
    <link>https://dev.to/ddobrinskiy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1002625%2F9c7dceba-5f9f-443b-a315-0a81df68bfca.jpeg</url>
      <title>DEV Community: David Dobrinskiy</title>
      <link>https://dev.to/ddobrinskiy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ddobrinskiy"/>
    <language>en</language>
    <item>
      <title>nbdev formating and linting</title>
      <dc:creator>David Dobrinskiy</dc:creator>
      <pubDate>Fri, 06 Jan 2023 21:04:35 +0000</pubDate>
      <link>https://dev.to/ddobrinskiy/nbdev-formating-and-linting-4jkd</link>
      <guid>https://dev.to/ddobrinskiy/nbdev-formating-and-linting-4jkd</guid>
      <description>&lt;ul&gt;
&lt;li&gt;  Introduction
&lt;/li&gt;
&lt;li&gt;  nbqa
&lt;/li&gt;
&lt;li&gt;  black
&lt;/li&gt;
&lt;li&gt;  isort and mypy
&lt;/li&gt;
&lt;li&gt;  Automating your flows with
Makefile
&lt;/li&gt;
&lt;li&gt;  pre-commit

&lt;ul&gt;
&lt;li&gt;  install and configure
pre-commit
&lt;/li&gt;
&lt;li&gt;  create
.pre-commit-config.yaml
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;  reproducible&lt;br&gt;
environments with Pipenv/Poetry/virtualenv
&lt;/li&gt;

&lt;li&gt;  Concusion
&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;nbdev is a great tool.&lt;/p&gt;

&lt;p&gt;However some of you may not be comfortable with the default &lt;a href="https://docs.fast.ai/dev/style.html" rel="noopener noreferrer"&gt;fastai&lt;br&gt;
codestyle&lt;/a&gt;, or maybe your team is&lt;br&gt;
already using a different one.&lt;/p&gt;

&lt;p&gt;This post will show you how to integrate your nbdev workflows with&lt;br&gt;
industry standard tools like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://github.com/psf/black" rel="noopener noreferrer"&gt;black&lt;/a&gt; , The uncompromising code
formatter&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://pycqa.github.io/isort/" rel="noopener noreferrer"&gt;isort&lt;/a&gt; , A Python utility / library
to sort imports.&lt;/li&gt;
&lt;li&gt;  &lt;a href="http://www.mypy-lang.org/" rel="noopener noreferrer"&gt;mypy&lt;/a&gt; , Optional static typing for
Python&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://pre-commit.com/" rel="noopener noreferrer"&gt;pre-commit&lt;/a&gt; , A framework for managing and
maintaining multi-language pre-commit hooks.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An astute reader may notice that one can enable&lt;br&gt;
&lt;code&gt;black_formatting = True&lt;/code&gt; in &lt;code&gt;settings.ini&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;However,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;this will only format the code in the module, not the code in the&lt;br&gt;
notebook.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;this does not allow you to use other tools like &lt;code&gt;isort&lt;/code&gt; or &lt;code&gt;mypy&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  nbqa
&lt;/h2&gt;

&lt;p&gt;use &lt;a href="https://nbqa.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;nbqa&lt;/a&gt; to format and verify&lt;br&gt;
code in your notebooks&lt;/p&gt;

&lt;p&gt;nbqa is a tool that allows you to run any tool (formatter/linter) on&lt;br&gt;
your notebooks, without having to worry about the details.&lt;/p&gt;
&lt;h2&gt;
  
  
  black
&lt;/h2&gt;

&lt;p&gt;Black is a python code formatter that is becoming the de-facto standard&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;nbqa

nbqa black nbs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  isort and mypy
&lt;/h2&gt;

&lt;p&gt;isort will sort your imports, and mypy will check your type annotations&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;isort mypy

nbqa isort nbs/
nbqa mypy nbs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Automating your flows with Makefile
&lt;/h2&gt;

&lt;p&gt;But you are already using nbdev command-line arguments like&lt;br&gt;
&lt;code&gt;nbdev_export&lt;/code&gt; and &lt;code&gt;nbdev_test&lt;/code&gt;, who wants to remember more commands?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.gnu.org/software/make/" rel="noopener noreferrer"&gt;Make&lt;/a&gt; is a great tool for&lt;br&gt;
automating your workflows, usually comes pre-installed on most unix&lt;br&gt;
systems.&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;Makefile&lt;/code&gt; in the root of your project and add the following&lt;br&gt;
lines:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Makefile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="c"&gt;# Makefile
&lt;/span&gt;&lt;span class="nl"&gt;format&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    nbqa black nbs/
    nbqa isort nbs/
    nbqa mypy nbs/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can run &lt;code&gt;make format&lt;/code&gt; to format your notebooks.&lt;/p&gt;

&lt;p&gt;Let’s add more commands to our &lt;code&gt;Makefile&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Makefile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="nl"&gt;format&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    nbqa black nbs/
    nbqa isort nbs/
    nbqa mypy nbs/

&lt;span class="nl"&gt;export&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    nbdev_export

&lt;span class="nl"&gt;mypy&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    nbqa mypy nbs/ &lt;span class="nt"&gt;--ignore-missing-imports&lt;/span&gt; &lt;span class="nt"&gt;--check-untyped-defs&lt;/span&gt;

&lt;span class="nl"&gt;test&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    nbdev_test &lt;span class="nt"&gt;--n_workers&lt;/span&gt; 4

&lt;span class="nl"&gt;prepare&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="c"&gt;# Export, test, and clean notebooks, and render README if needed&lt;/span&gt;
    nbdev_prepare

&lt;span class="nl"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    nbdev_docs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now the cherry on top: Makefile supports dependecies, so we can&lt;br&gt;
chain commands together.&lt;/p&gt;

&lt;p&gt;add this to your &lt;code&gt;Makefile&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Makefile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight make"&gt;&lt;code&gt;&lt;span class="nl"&gt;all&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;format prepare mypy&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;code&gt;make all&lt;/code&gt; will format your notebooks, export them, run mypy,&lt;br&gt;
run tests and update README.md&lt;/p&gt;
&lt;h2&gt;
  
  
  pre-commit
&lt;/h2&gt;

&lt;p&gt;Want to automate your formatting even more?&lt;/p&gt;

&lt;p&gt;Force your team to format their notebooks before committing?&lt;/p&gt;

&lt;p&gt;Use &lt;a href="https://pre-commit.com/" rel="noopener noreferrer"&gt;pre-commit&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  install and configure pre-commit
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;pre-commit &lt;span class="c"&gt;# install &lt;/span&gt;

pre-commit &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="c"&gt;# enable for this repo&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  create .pre-commit-config.yaml
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;.pre-commit-config.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/fastai/nbdev&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2.2.10&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbdev_clean&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbdev_export&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Add nbqa hooks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.pre-commit-config.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/nbQA-dev/nbQA&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.5.3&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbqa-mypy&lt;/span&gt;
        &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--ignore-missing-imports"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--check-untyped-defs"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
        &lt;span class="na"&gt;additional_dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mypy"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;types-toml"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;types-requests"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbqa-black&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbqa-isort&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;control your hooks behaviour&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.pre-commit-config.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/nbQA-dev/nbQA&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;1.5.3&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbqa-mypy&lt;/span&gt;
        &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--ignore-missing-imports"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--check-untyped-defs"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# pass args to mypy&lt;/span&gt;
        &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;directory_to_exclude/.*"&lt;/span&gt; &lt;span class="c1"&gt;# eclude any directory/files from formatting&lt;/span&gt;
        &lt;span class="na"&gt;additional_dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mypy"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;types-toml"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;types-requests"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# install additional dependencies&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbqa-black&lt;/span&gt;
        &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;directory_to_exclude/.*"&lt;/span&gt; &lt;span class="c1"&gt;# eclude any directory/files from formatting&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nbqa-isort&lt;/span&gt;
        &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;directory_to_exclude/.*"&lt;/span&gt; &lt;span class="c1"&gt;# eclude any directory/files from formatting&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  reproducible environments with Pipenv/Poetry/virtualenv
&lt;/h2&gt;

&lt;p&gt;Sometimes you may run into reproducibility issues, where your notebook&lt;br&gt;
works on your machine, but not on your team’s.&lt;/p&gt;

&lt;p&gt;The best way to avoid it is to use a dependency manager, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://pipenv.pypa.io/en/latest/index.html" rel="noopener noreferrer"&gt;Pipenv&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://python-poetry.org/" rel="noopener noreferrer"&gt;Poetry&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://virtualenv.pypa.io/en/latest/" rel="noopener noreferrer"&gt;virtualenv&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But how do you integrate it with nbdev, since it uses &lt;code&gt;settings.ini&lt;/code&gt; to&lt;br&gt;
manage dependencies?&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://dev.to/ddobrinskiy/reproducible-environment-in-nbdev-with-pipenv-4h05"&gt;this blog post&lt;/a&gt; I show an example of&lt;br&gt;
how to use Pipenv with nbdev.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concusion
&lt;/h2&gt;

&lt;p&gt;I hope you find this post useful.&lt;/p&gt;

&lt;p&gt;These changes may make nbdev more friendly to a team environment.&lt;/p&gt;

&lt;p&gt;Please don’t hesitate to post any questions or comments below.&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>jokes</category>
    </item>
    <item>
      <title>Reproducible environment in nbdev with Pipenv</title>
      <dc:creator>David Dobrinskiy</dc:creator>
      <pubDate>Fri, 06 Jan 2023 21:04:15 +0000</pubDate>
      <link>https://dev.to/ddobrinskiy/reproducible-environment-in-nbdev-with-pipenv-4h05</link>
      <guid>https://dev.to/ddobrinskiy/reproducible-environment-in-nbdev-with-pipenv-4h05</guid>
      <description>&lt;ul&gt;
&lt;li&gt;  Introduction
&lt;/li&gt;
&lt;li&gt;  Some background on Pipenv
&lt;/li&gt;
&lt;li&gt;  Creating a Pipenv environment
&lt;/li&gt;
&lt;li&gt;  Syncing your
&lt;code&gt;Pipfile&lt;/code&gt; to &lt;code&gt;setup.py&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  pre-commit hook
&lt;/li&gt;
&lt;li&gt;  Extra reading:
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If you’re reading this, you’re probably familiar with&lt;br&gt;
&lt;a href="https://nbdev.fast.ai/" rel="noopener noreferrer"&gt;nbdev&lt;/a&gt;, a system for creating Python libraries&lt;br&gt;
from Jupyter notebooks.&lt;/p&gt;

&lt;p&gt;The only trouble I have with it is keeping track of dependencies,&lt;br&gt;
especially when you have multiple projects or expect other people to use&lt;br&gt;
your code.&lt;/p&gt;

&lt;p&gt;In this post, I’ll show you how to set up a new nbdev project using&lt;br&gt;
&lt;a href="https://pipenv.pypa.io/en/latest/" rel="noopener noreferrer"&gt;Pipenv&lt;/a&gt;, a tool for managing Python&lt;br&gt;
dependencies. This will allow you to easily create a new project,&lt;br&gt;
install dependencies, and run your code without having to worry about&lt;br&gt;
setting up a virtual environment.&lt;/p&gt;
&lt;h2&gt;
  
  
  Some background on Pipenv
&lt;/h2&gt;

&lt;p&gt;If you’re not familiar with Pipenv, it’s a tool for managing Python&lt;br&gt;
dependencies. It’s similar to&lt;br&gt;
&lt;a href="https://virtualenv.pypa.io/en/latest/" rel="noopener noreferrer"&gt;virtualenv&lt;/a&gt;,&lt;br&gt;
&lt;a href="https://docs.conda.io/en/latest/" rel="noopener noreferrer"&gt;conda&lt;/a&gt; or&lt;br&gt;
&lt;a href="https://python-poetry.org/" rel="noopener noreferrer"&gt;poetry&lt;/a&gt;, but it’s a bit more user-friendly.&lt;/p&gt;

&lt;p&gt;Setting up a new project with Pipenv is easy. You just need to run&lt;br&gt;
&lt;code&gt;pipenv install&lt;/code&gt; in the project directory. This will create a new&lt;br&gt;
virtual environment and install all the dependencies listed in the&lt;br&gt;
&lt;code&gt;Pipfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to add a new dependency, you can run&lt;br&gt;
&lt;code&gt;pipenv install &amp;lt;package_name&amp;gt;&lt;/code&gt;. This will install the package and add&lt;br&gt;
it to the &lt;code&gt;Pipfile&lt;/code&gt;, keeping track of the version you installed.&lt;/p&gt;

&lt;p&gt;If you want to install a specific version of a package, you can run&lt;br&gt;
&lt;code&gt;pipenv install &amp;lt;package_name&amp;gt;==&amp;lt;version&amp;gt;&lt;/code&gt;. This will install the&lt;br&gt;
package and add it to the &lt;code&gt;Pipfile&lt;/code&gt; with the specified version.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating a Pipenv environment
&lt;/h2&gt;

&lt;p&gt;install pipenv:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;pipenv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;install some generic dependencies for our project (optional):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipenv &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"requests==2.28.1"&lt;/span&gt; &lt;span class="s2"&gt;"pandas==1.5.2"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now install the &lt;strong&gt;required&lt;/strong&gt; dependencies for our guide:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;pipenv-setup &lt;span class="s2"&gt;"vistir==0.6.1"&lt;/span&gt; nbdev &lt;span class="nt"&gt;--dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is now a &lt;code&gt;Pipfile&lt;/code&gt; and &lt;code&gt;Pipfile.lock&lt;/code&gt; in the root of our project.&lt;br&gt;
Let’s add the following to the &lt;code&gt;Pipfile&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pipfile&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="p"&gt;[[&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;]]&lt;/span&gt;
&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://pypi.org/simple&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;verify_ssl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;true&lt;/span&gt;
&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pypi&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;requests&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;==2.28.1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;pandas&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;==1.5.2&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;dev&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;packages&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;nbdev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;pipenv&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;setup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;vistir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;==0.6.1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;requires&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;python_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;3.10&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Activate your new environment by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipenv shell
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Syncing your &lt;code&gt;Pipfile&lt;/code&gt; to &lt;code&gt;setup.py&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Lucky for us, this has already been solved in&lt;br&gt;
&lt;a href="https://github.com/Madoshakalaka/pipenv-setup" rel="noopener noreferrer"&gt;pipenv-setup&lt;/a&gt; package.&lt;/p&gt;

&lt;p&gt;First, install it by running&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;pipenv-setup &lt;span class="s2"&gt;"vistir==0.6.1"&lt;/span&gt; &lt;span class="nt"&gt;--dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let’s sync our &lt;code&gt;setup.py&lt;/code&gt; with &lt;code&gt;Pipfile&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv-setup &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="nt"&gt;--pipfile&lt;/span&gt; &lt;span class="nt"&gt;--dev&lt;/span&gt;

No setup&lt;span class="o"&gt;()&lt;/span&gt; call found &lt;span class="k"&gt;in &lt;/span&gt;setup.py
can not perform &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Huh, an error. What’s going on here? Let’s check the &lt;code&gt;setup.py&lt;/code&gt; file&lt;br&gt;
that was generated by nbdev:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;setup.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;setuptools&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="n"&gt;install_requires&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requirements&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;extras_require&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dev&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dev_requirements&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;dependency_links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dep_links&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The issue is that &lt;code&gt;pipenv-setup&lt;/code&gt; expects us to call &lt;code&gt;setup(...)&lt;/code&gt;, not&lt;br&gt;
&lt;code&gt;setuptools.setup(...)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That is easy enough to fix by changing our function call:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;setup.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;setuptools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;setup&lt;/span&gt;
&lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="n"&gt;install_requires&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requirements&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;extras_require&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dev&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dev_requirements&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;dependency_links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cfg&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dep_links&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running the command, we get another error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv-setup &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="nt"&gt;--pipfile&lt;/span&gt; &lt;span class="nt"&gt;--dev&lt;/span&gt;

Error parsing setup.py: install_requires is not a list
can not perform &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s make our setup.py compatible with &lt;code&gt;pipenv-setup&lt;/code&gt; by changing&lt;br&gt;
several arguments, namely:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;code&gt;install_requires&lt;/code&gt; should be a list&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;extras_require&lt;/code&gt; should be a dictionary&lt;/li&gt;
&lt;li&gt;  &lt;code&gt;dependency_links&lt;/code&gt; should be a list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;setup.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;setuptools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;setup&lt;/span&gt;
&lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="n"&gt;install_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="n"&gt;extras_require&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{},&lt;/span&gt;
    &lt;span class="n"&gt;dependency_links&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
    &lt;span class="bp"&gt;...&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;pipenv-setup &lt;span class="nb"&gt;sync&lt;/span&gt; &lt;span class="nt"&gt;--pipfile&lt;/span&gt; &lt;span class="nt"&gt;--dev&lt;/span&gt;

reformatted setup.py
setup.py was successfully updated
5 default packages from Pipfile synced to setup.py
13 dev packages from Pipfile synced to setup.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🎉 SUCCESS! 🎉&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;setup.py&lt;/code&gt; is now in sync with our &lt;code&gt;Pipfile&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;now every time someone installs our package, they will get the same&lt;br&gt;
dependencies as we do.&lt;/p&gt;

&lt;p&gt;Installation with only the default dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt;

OR

pip &lt;span class="nb"&gt;install &lt;/span&gt;your_package_name &lt;span class="c"&gt;# if you've already published your package&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Installation with all the dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s1"&gt;'.[dev]'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;updated setup.py example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;setup.py&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;install_requires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;requests==2.28&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pandas&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bleak&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rich&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;aranet4&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="n"&gt;extras_require&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dev&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;black[jupyter]==22.12.0&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;blacken-docs==1.12.1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;isort==5.10.1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jupyter==1.*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;mypy&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nbdev==2.3.9&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nbqa==1.5.3&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pre-commit==2.20&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;types-requests&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;types-toml&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;ipykernel&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pipenv-setup&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vistir==0.6.1&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;dependency_links&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[],&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  pre-commit hook
&lt;/h2&gt;

&lt;p&gt;Odds are you’ll forget to run &lt;code&gt;pipenv-setup sync&lt;/code&gt; every time you add a&lt;br&gt;
new dependency.&lt;/p&gt;

&lt;p&gt;To fix this, we can add a pre-commit hook to our project. This will run&lt;br&gt;
&lt;code&gt;pipenv-setup sync&lt;/code&gt; every time we commit changes to our &lt;code&gt;Pipfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;First, install and activate &lt;code&gt;pre-commit&lt;/code&gt; in your repo:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pipenv &lt;span class="nb"&gt;install &lt;/span&gt;pre-commit &lt;span class="nt"&gt;--dev&lt;/span&gt;

pre-commit &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, add the following to your &lt;code&gt;.pre-commit-config.yaml&lt;/code&gt; file:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.pre-commit-config.yaml&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/Madoshakalaka/pipenv-setup&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v3.2.0&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;pipenv-setup&lt;/span&gt;
        &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;--dev&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;--pipfile&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
        &lt;span class="na"&gt;additional_dependencies&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vistir==0.6.1"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now on every commit, &lt;code&gt;pipenv-setup&lt;/code&gt; will check that your &lt;code&gt;Pipfile&lt;/code&gt; and&lt;br&gt;
&lt;code&gt;setup.py&lt;/code&gt; are in sync.&lt;/p&gt;

&lt;p&gt;If you forget to run &lt;code&gt;pipenv-setup sync --pipfile --dev&lt;/code&gt;, you’ll get an&lt;br&gt;
error and won’t be able to commit until you fix it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extra reading:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://nbdev.fast.ai/" rel="noopener noreferrer"&gt;nbdev docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://pipenv.pypa.io/en/latest/" rel="noopener noreferrer"&gt;Pipenv docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://setuptools.pypa.io/en/latest/userguide/quickstart.html" rel="noopener noreferrer"&gt;setuptools
docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://github.com/Madoshakalaka/pipenv-setup" rel="noopener noreferrer"&gt;pipenv-setup docs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>New library to develop streamlit apps in jupyter</title>
      <dc:creator>David Dobrinskiy</dc:creator>
      <pubDate>Thu, 05 Jan 2023 20:43:22 +0000</pubDate>
      <link>https://dev.to/ddobrinskiy/new-library-to-develop-streamlit-apps-in-jupyter-13di</link>
      <guid>https://dev.to/ddobrinskiy/new-library-to-develop-streamlit-apps-in-jupyter-13di</guid>
      <description>&lt;p&gt;Hey there, I created a library &lt;a href="https://github.com/ddobrinskiy/streamlit-jupyter"&gt;streamlit-jupyter&lt;/a&gt; to allow for seamless creation of streamlit apps in jupyter notebooks.&lt;/p&gt;

&lt;p&gt;A nifty little alternative to &lt;a href="https://github.com/voila-dashboards/voila"&gt;voila&lt;/a&gt;, one might say.&lt;/p&gt;

&lt;p&gt;The way this works is it detects your environment, and if the script is run from a jupyter notebook, then it wraps existing streamlit methods to replace them with ipywidgets alternatives - that way you can code as you would in streamlit, and then displays your page as-you-code.&lt;/p&gt;

&lt;p&gt;Then you export your notebook to a &lt;code&gt;.py&lt;/code&gt; file, and run it via streamlit as usual (no change in behaviour there)&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;streamlit_jupyter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;

&lt;p&gt;Take a look at our &lt;a href="https://github.com/ddobrinskiy/streamlit-jupyter/blob/master/examples/99_example.ipynb"&gt;example notebook&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main idea is for you experiment and develop in your notebook,&lt;br&gt;
visually see all the pieces, and then convert the notebook to &lt;code&gt;.py&lt;/code&gt; to&lt;br&gt;
be run by streamlit&lt;/p&gt;

&lt;p&gt;start by importing streamlit and patching it with streamlit-jupyter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;streamlit&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;streamlit_jupyter&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StreamlitPatcher&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tqdm&lt;/span&gt;

&lt;span class="n"&gt;StreamlitPatcher&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;jupyter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# register streamlit with jupyter-compatible wrappers
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now develop your notebook as usual, but with the ability to use&lt;br&gt;
Streamlit widgets and components.&lt;/p&gt;

&lt;p&gt;See how it works below, and check out the &lt;a href="https://github.com/ddobrinskiy/streamlit-jupyter/blob/master/examples/99_example.ipynb"&gt;example&lt;/a&gt; (it also incudes a nifty alternative to nbconvert that strips out all the magics and other irrelevant stuff)&lt;/p&gt;

&lt;h2&gt;
  
  
  Demonstration
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Jupyter&lt;/th&gt;
&lt;th&gt;Streamlit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Markdown and headings&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U8fvQaXb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img1_jupyter.png" alt="alt" width="880" height="711"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--e6dn5qG0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img1_streamlit.png" alt="alt" width="880" height="211"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Interactive data entry&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dmt8hZs5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img2_jupyter.png" alt="alt" width="880" height="648"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pfCSEVRz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img2_streamlit.png" alt="alt" width="880" height="458"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Pick and choose&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UaTw4uds--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img5_jupyter.gif" alt="alt" width="880" height="938"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_oJOwuOZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img5_streamlit.gif" alt="alt" width="880" height="540"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dataframes, caching and progress bars&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PrPVK8hM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img3_jupyter.gif" alt="alt" width="880" height="541"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wgEFLjB5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img3_streamlit.gif" alt="alt" width="880" height="359"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Plots&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nbGNqtjV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img4_jupyter.png" alt="alt" width="880" height="760"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2ESoCTPt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/ddobrinskiy/streamlit-jupyter/raw/master/images/img4_streamlit.png" alt="alt" width="880" height="517"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  ps
&lt;/h2&gt;

&lt;p&gt;This is a very early beta and my first try at open source, so please share your thoughts and reach out with any questions/critiques!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
