1

I am working on a project and I have cloned a repository from github.
After first compile I realized that the project that I cloned has some dependencies and they were in requirements.txt file.

I know I have to install these packages, but I dont want to cause I am on windows development environment and after finishing my project I am going to publish it to my ubuntu production environment and I dont want to take the hassle of double installation.

I have two options:

  1. Using a virtualenv and installing those packages inside it

  2. Downloading the packages and use them the direct way using import foldername

I wanna avoid the first option cause I have less control over my project and the problem gets bigger and bigger If for example I were inside another project's virtualenv and wanted to run my project's main.py file from its own virtualenv and etc... Also moving the virtualenv from windows (bat files) to linux (bash / sh files) seems ugly to me and directs me to approaches that I choose to better avoid.

The second option is my choice. for example I need to use the future package. The scenario would be downloading the package using pip download future and when done extracting the tar.gz file, inside the src folder I can see the future package folder, And I use it with import future_package.src.future without even touching anything else.

enter image description here

Aside from os.path problems (which assume I take care of):

Is this good practice?

I am not running the setup.py preventing any installation. Can it cause problems?

Is there any better approach that involves less work (like the second one) or the better one is my mentioned first approach?

UPDATE 1: I have extracted future and certifi packages which were part of the requirements of my project and I used them the direct way and it is working in this particular case.

  • I am, quite honestly, still unclear on the original premise of why creating a virtualenv and letting pip install all dependencies is such a terrible move… – deceze Jul 26 '17 at 08:14
  • @deceze It is not terrible move, I said it is an option, I know I have to use virtualenv somedays and they are perfect choices for fast developement, but I personally try to skip automated things like pip and want to have control over my stuff, and If I can simply `extract`, `move` and call `import` why should I bother using virtualenv for a simple project (and maybe doable on more complex ones)? – Amir Hossein Baghernezad Jul 26 '17 at 08:41
  • Because dependencies *can* get very complex and that's exactly the problem package managers like pip solve…!? If there's only two dependencies you can extract by hand and those happen to be self contained… great! Lucky you. But wait until you're trying to install a library that has dozens of dependencies which each also have dozens of dependencies. Good luck tracking all the right versions down by hand. – deceze Jul 26 '17 at 08:43
  • @deceze well I said simple projects, but you are right then :) – Amir Hossein Baghernezad Jul 26 '17 at 08:49
  • Modern software development which largely builds systems on systems on systems does have its own complexities, and tools like pip and virtualenv exist to make those complexities more manageable. If you want to be productive/build complex stuff, it's something you pretty much have to accept. – deceze Jul 26 '17 at 08:49
  • @deceze what about installing them inside a virtualenv and moving them from `site-packages` inside virtualenv to the directory that i want to import them? Does using virtualenv has advantages than this? – Amir Hossein Baghernezad Jul 26 '17 at 12:06
  • I'm not quite sure why you would go through so much trouble… You create the virtualenv in the directory you want to work in (as opposed to installing those packages globally). Beyond that you shouldn't be sweating the details too much; whether the packages are installed in some managed sub-directory of that virtualenv or somewhere that you would like shouldn't make much of a difference. You shouldn't be swimming against the tide unless you have a really good reason to do so. – deceze Jul 26 '17 at 12:16
  • @deceze well my reason is portability. assume I wanted to run my project on mac. now what? I should create a requirement file from my project inside windows and write a script for mac to do: (1. create a venv 2. install requirement file packages inside it 3. run it) I want to eliminate 1 and 2. – Amir Hossein Baghernezad Jul 26 '17 at 12:52
  • Then see https://stackoverflow.com/q/26019920/476, https://stackoverflow.com/q/106725/476, https://stackoverflow.com/q/28237312/476 – deceze Jul 26 '17 at 13:02

0 Answers0