3

I have a question that I cannot seem to find the right answer for (perhaps I am articulating it incorrectly).

My program is dependent on Numpy and datetime. should I include those inside the modules folder? Or is it assumed that some of the fundamental packages are already going to be installed on the computer the end user will use?

Layout:

PROGRAM_NAME/
-main
-Readme
--/Modules
  -__init__
  -constants
  -program_name
DanOPT
  • 128
  • 2
  • 13
rivesalex
  • 31
  • 2
  • TL;DR: use a [build system](https://peps.python.org/pep-0517/). There are many to chose from, some published by the PSF/PPA, some made by third-parties. Using any one will allow users to install all of your packages dependencies automatically just by e.g. `pip install`ing your package. – Brian61354270 Mar 01 '23 at 01:23

2 Answers2

1

Edit: You could start by adding a requirements.txt to your project, although this is outdated advice if you want to build a package, but will be fine for small projects. If you want to build a package, take a look at this documentation about PEP517: https://peps.python.org/pep-0517/

You can also use other build tools to build packages like https://github.com/python-poetry/poetry

This shell command will export your projects dependencies as a file named requirements.txt:

pip freeze > requirements.txt

Once you’ve got your requirements file, you can head over to a different computer or new virtual environment and run the following:

pip install -r requirements.txt

A requirements file is a list of all of a project’s dependencies. This includes the dependencies needed by the dependencies. It also contains the specific version of each dependency, specified with a double equals sign (==).

Read more here: https://realpython.com/lessons/using-requirement-files/

DanOPT
  • 128
  • 2
  • 13
  • Thanks for the suggestion, it IS a pretty simple program, and based on the questions it seems that it will be best practice to have a method that allows an end user to install required packages. – rivesalex Mar 02 '23 at 01:06
0

The best place to put dependencies would be in a requirements.txt file. Then to install all the requirements, use pip install -r /path/to/requirements.txt.

More information on requirements.txt can be found here in the pip documentation.

Zelkins
  • 723
  • 1
  • 5
  • 22