<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>@Summitt Dweller’s Personal Blog - Venv2022-09-26T12:00:16-05:00</title>
    <link>https://blog.summittdweller.com/tags/venv2022-09-26t120016-0500/</link>
    <description>All entries in Venv2022-09-26T12:00:16-05:00 on Personal Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    
    <lastBuildDate>Sat, 24 Sep 2022 14:26:44 -0500</lastBuildDate>
    <atom:link href="https://blog.summittdweller.com/tags/venv2022-09-26t120016-0500/" rel="self" type="application/rss+xml" />
    
      
      <item>
        <title>Proper Python</title>
        <link>https://blog.summittdweller.com/posts/2022/09/proper-python/</link>
        <pubDate>Sat, 24 Sep 2022 14:26:44 -0500</pubDate>
        <author>Mark McFate</author>
        <guid>https://blog.summittdweller.com/posts/2022/09/proper-python/</guid>
        <description>&lt;p&gt;What follows is the &lt;code&gt;README.md&lt;/code&gt; file from my &lt;em&gt;GitHub&lt;/em&gt; repo where &lt;a href=&#34;https://blog.summittdweller.com&#34;&gt;https://blog.summittdweller.com&lt;/a&gt; is built.  It outlines how to &amp;ldquo;properly&amp;rdquo; add Python to a project such that we can create an easily reproducible &amp;ldquo;virtual environment&amp;rdquo; without storing the necessary Python libraries in &lt;em&gt;GitHub&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;From the &lt;code&gt;README.md&lt;/code&gt;&amp;hellip;&lt;/p&gt;
&lt;!-- hugo: layouts/shortcodes/original.html --&gt;
&lt;div class=&#34;original&#34;&gt;
# blogs-SummittDweller
&lt;p&gt;The Python portions of this repo were gleaned from &lt;a href=&#34;https://github.com/SummittDweller/hikes&#34;&gt;https://github.com/SummittDweller/hikes&lt;/a&gt;.
This is the repo for my &lt;a href=&#34;https://blog.SummittDweller.com/&#34;&gt;https://blog.SummittDweller.com/&lt;/a&gt; static website.&lt;/p&gt;
&lt;h2 id=&#34;latest-python-improvements&#34;&gt;Latest Python Improvements&lt;/h2&gt;
&lt;p&gt;Using guidance at &lt;a href=&#34;https://predictivehacks.com/how-to-work-with-vs-code-and-virtual-environments-in-python/&#34;&gt;https://predictivehacks.com/how-to-work-with-vs-code-and-virtual-environments-in-python/&lt;/a&gt; I successfully created a new &lt;code&gt;.venv&lt;/code&gt; virtual environment.  The commands I used to do this were&amp;hellip;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;╭─mark@Marks-Mac-Mini ~/GitHub/blogs-SummittDweller ‹main*›
╰─$ python3 -m venv .venv

╭─mark@Marks-Mac-Mini ~/GitHub/blogs-SummittDweller ‹main*›
╰─$ source .venv/bin/activate

(.venv) ╭─mark@Marks-Mac-Mini ~/GitHub/blogs-SummittDweller ‹main› 
╰─$ pip3 freeze &amp;gt; python-requirements.txt

(.venv) ╭─mark@Marks-Mac-Mini ~/GitHub/blogs-SummittDweller ‹main*›
╰─$ pip3 install -r python-requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then I used &lt;code&gt;COMMAND-SHIFT-P&lt;/code&gt; to select and &lt;code&gt;Python: Select interpreter&lt;/code&gt; to choose the new &lt;code&gt;.venv&lt;/code&gt; Python.  After that&amp;hellip;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;(.venv) ╭─mark@Marks-Mac-Mini ~/GitHub/blogs-SummitDweller ‹main*›
╰─$ python3 consolidate.py --start 20220806 --end 20220825

(.venv) ╭─mark@Marks-Mac-Mini ~/GitHub/blogs-SummitDweller ‹main*›
╰─$ hugo server
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;rebuilding-a-local-environment&#34;&gt;Rebuilding a Local Environment&lt;/h2&gt;
&lt;p&gt;Based on guideance from &lt;a href=&#34;https://stackoverflow.com/questions/6590688/is-it-bad-to-have-my-virtualenv-directory-inside-my-git-repository&#34;&gt;https://stackoverflow.com/questions/6590688/is-it-bad-to-have-my-virtualenv-directory-inside-my-git-repository&lt;/a&gt; I&amp;rsquo;ve reconstructed this project such that Python artifacts do NOT propogate into Github.&lt;/p&gt;
&lt;p&gt;The project should automatically &amp;ldquo;rebuild&amp;rdquo; as necessary when opened in VSCode, but if the Python virtual environment needs to be recreated use&amp;hellip;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;source .venv/bin/activate &amp;amp;&amp;amp; pip3 install -r python-requirements.txt
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;deployment-via-digitalocean&#34;&gt;Deployment via DigitalOcean&lt;/h2&gt;
&lt;p&gt;In order to deploy this &lt;code&gt;starter&lt;/code&gt; static app on &lt;em&gt;DigitalOcean&lt;/em&gt; I had to PERMANENTLY move all of my Python components (&lt;code&gt;.py&lt;/code&gt; scripts and &lt;code&gt;requirements.txt&lt;/code&gt;) to a &lt;code&gt;.python&lt;/code&gt; directory to hide it from view during app creation.  Before moving these elements &lt;em&gt;DigitalOcean&lt;/em&gt; would consistently try to deploy my app as Python, and that&amp;rsquo;s not right.&lt;/p&gt;
&lt;p&gt;See &lt;em&gt;DigitalOcean&lt;/em&gt; ticket [#06849069] &lt;code&gt;Hugo static site with Python components builds fail&lt;/code&gt; for details.&lt;/p&gt;
&lt;p&gt;The response I received from &lt;em&gt;DigitalOcean&lt;/em&gt;&amp;hellip;&lt;/p&gt;
&lt;!-- hugo: layouts/shortcodes/original.html --&gt;
&lt;div class=&#34;original&#34;&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thanks for contacting DigitalOcean.&lt;/p&gt;
&lt;p&gt;We appreciate you reaching out to us about your Hugo static site. From what you mentioned it does sound like your app is getting detected as a python webservice rather then a static site due to the requirements.txt file you had in the root of your repo.&lt;/p&gt;
&lt;p&gt;Unfortunately this is currently what App platform uses to detect applications as python apps. Either having a requirements.txt file or a setup.py file will cause that detection. Our engineers are looking into options to specify the build pack used rather then relying upon the auto detection, which would address this issue in your case, but don&amp;rsquo;t have a timeline yet for implementing it.&lt;/p&gt;
&lt;p&gt;In the mean time the work around that you have specified here should work fine for this. It should cause the app to be detected as a static site rather then python. Hopefully it isn&amp;rsquo;t impacting anything else in your app&amp;rsquo;s build process.&lt;/p&gt;
&lt;p&gt;If you have any questions, please let us know.&lt;/p&gt;
&lt;p&gt;Regards,
Nate
Senior Cloud Support Engineer
Check out our community for great tutorials, articles and FAQs!
digitalocean.com/community&lt;/p&gt;
&lt;p&gt;ref:_00Df218t5m._5004P21l4JM:ref&lt;/p&gt;
&lt;/div&gt;
&lt;!-- /hugo: layouts/shortcodes/original.html --&gt;
&lt;h3 id=&#34;remedy&#34;&gt;Remedy&lt;/h3&gt;
&lt;p&gt;Based on the response above I&amp;rsquo;m making final changes to eliminate the &lt;code&gt;.python&lt;/code&gt; folder, renaming &lt;code&gt;.python/requirements.txt&lt;/code&gt; as &lt;code&gt;python-requirements.txt&lt;/code&gt;, and pulling all other contents of &lt;code&gt;.python&lt;/code&gt; into the root of the project.&lt;/p&gt;
&lt;/div&gt;
&lt;!-- /hugo: layouts/shortcodes/original.html --&gt;
</description>
      </item>
      
    
  </channel>
</rss>
