What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?
Conveying the idea of "It's piece of cake" by "simple comme bonjour" or "bête comme chou"
What is the design rationale for having armor and magic penetration mechanics?
Why are Starfleet vessels designed with nacelles so far away from the hull?
How can AnyDVD destroy a DVD drive?
Is a light year a different distance if measured from a moving object?
Sanitize and build data structure from Consul configuration
A replacement for NextPermutation in Combinatorica
Can digital computers understand infinity?
What is the type of this light bulb?
Is fascism intrinsically violent?
What is it called when you use wrong but smart arguments?
Can you set fire to beer barrels?
Does the warlock's Gift of the Ever-Living Ones eldritch invocation work with potions or healing spells cast on you by others?
7 mentions of night in Gospel of John
Why does 1.1.1.1 not resolve archive.is?
Proofreading a novel: is it okay to use a question mark with an exclamation mark - "?!"
How to respond to "Why didn't you do a postdoc after your PhD?"
I got this nail stuck in my tire, should I plug or replace?
Diamondize Some Text
Is there a push, in the United States, to use gender-neutral language and gender pronouns (when they are given)?
Can you take an Immortal Phoenix out of the game?
How did Ron get five hundred Chocolate Frog cards?
Did smallpox emerge in 1580?
Simple way to make circular arrow arc?
What if the end-user didn't have the required library?
What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
My Python project uses various kind of libraries. What is the protocol if the end-user didn't have one or any of them?
Should a window pop up and notify him/her which package and version to download in his/her environment? Or I should include the libraries within my project?
What's the proper action?
python python-3.x
add a comment
|
My Python project uses various kind of libraries. What is the protocol if the end-user didn't have one or any of them?
Should a window pop up and notify him/her which package and version to download in his/her environment? Or I should include the libraries within my project?
What's the proper action?
python python-3.x
Depends on what you mean by "proper".
– Scott Hunter
May 2 at 13:20
Related: Best practice to install dependencies?
– Aran-Fey
May 2 at 13:22
add a comment
|
My Python project uses various kind of libraries. What is the protocol if the end-user didn't have one or any of them?
Should a window pop up and notify him/her which package and version to download in his/her environment? Or I should include the libraries within my project?
What's the proper action?
python python-3.x
My Python project uses various kind of libraries. What is the protocol if the end-user didn't have one or any of them?
Should a window pop up and notify him/her which package and version to download in his/her environment? Or I should include the libraries within my project?
What's the proper action?
python python-3.x
python python-3.x
edited May 2 at 22:17
Kepler 186
asked May 2 at 13:17
Kepler 186Kepler 186
946 bronze badges
946 bronze badges
Depends on what you mean by "proper".
– Scott Hunter
May 2 at 13:20
Related: Best practice to install dependencies?
– Aran-Fey
May 2 at 13:22
add a comment
|
Depends on what you mean by "proper".
– Scott Hunter
May 2 at 13:20
Related: Best practice to install dependencies?
– Aran-Fey
May 2 at 13:22
Depends on what you mean by "proper".
– Scott Hunter
May 2 at 13:20
Depends on what you mean by "proper".
– Scott Hunter
May 2 at 13:20
Related: Best practice to install dependencies?
– Aran-Fey
May 2 at 13:22
Related: Best practice to install dependencies?
– Aran-Fey
May 2 at 13:22
add a comment
|
5 Answers
5
active
oldest
votes
Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is
In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires
key) that would be installed along with your package when the end-user installs it.
The end user could then use pip to install your package eg
pip install YourPackage
and all dependencies listed in setup.py would be installed first.
Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with
pip install -r requirements.txt YourPackage
See this guide for building a python package,
setuptools documentation
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
1
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
2
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
2
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in itssetup('requires'=[...])
field, they will be fetched automatically if you try to install your package
– Arne
May 2 at 14:05
1
@Kepler186 And if the end user usespip3
instead? Or if they usepython -m pip
instead (becausepip
isn't in the environment variables)? There are many flaws with your os approach.
– MilkyWay90
May 2 at 23:49
|
show 8 more comments
To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.
Files that I am aware of
requirements.txt: very simple
setup.py: Used when you publish your project on sides like pypi https://stackoverflow.com/a/1472014/8411228
Pipfile: The way to go when you work in an virtualenv https://docs.pipenv.org/en/latest/
environment.yml: Used for Conda environments https://tdhopper.com/blog/my-python-environment-workflow-with-conda/#fn:requirements-conda
add a comment
|
Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.
PyInstaller Quickstart
This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.
add a comment
|
Here is where packaging a python project into a module comes handy modules
We include a requirements.txt
file which contains all python module requirements needed for that python library, and installs them automatically when the module is setup.
A good primer on how to setup your module to be distributable is Structuring your project
Just arequirements.txt
is not enough right? I think you also need an__init__.py
,setup.py
and maybe more. docs.python-guide.org/writing/structure
– 3UqU57GnaX
May 2 at 13:24
Yes, the question was about how to installed required libraries, which are listed inrequirements.txt
, and on top of it, we have these things you mentioned!
– Devesh Kumar Singh
May 2 at 13:25
add a comment
|
So you made a package. Now you will want to share it. What next?
Developer
Goal - make a distribution (also called a "package") to share
Preamble
You are now packaging your package and wish to distribute it. There are two main kinds of packages:
- an application: deploy a source to a server, github, website e.g. CLI
- a library: publish a source distribution (sdist) or binary (e.g. wheel) usually to PyPI via
twine
Traditional Ways
Several files may be included in a distribution, but here are the main ones:
- source: your code
setup.py
: specify metadata, and dependencies required to make an sdist.requirements.txt
: a list of dependencies
Contemporary Ways
Use pyproject.toml
to specify which tool to use in creating your sdist or binary:
Modern tools to create + deploy/publish a package include:
pipenv
: makes a package and substitutesrequirements.txt
(recommended by PyPA)- develop:
> pipenv install <dependency>
,> pipenv install
- publish:
> pipenv -e .
+twine
- develop:
poetry
: makes a package and publishes to PyPI- develop
> poetry add <dependency>
,> poetry install
- publish:
> poetry publish
- develop
flit
: makes a package and publishes to PyPI- develop:
> flit install
- publish:
> flit publish
- develop:
The first two options have features to make clean virtual environments and safely install dependencies using lock files. I would encourage exploring these newer options later on as they clear up a lot of packaging headaches by obviating setup.py
and setuptools
.
User
Goal - get a package and install it with dependencies
Traditional Ways
Applications have a variety of deployment methods, e.g. uploading your app to a hosting service e.g. heroku, DigitalOcean, etc. The user may indirectly interface with your app through a website, CLI or more.
Libraries are often uploaded to PyPI. From here the user can usually install a package using pip
independent from how they are made:
> pip install <package>
(recommended)> pip install <packatge> -r requirements
(explicit, optional)
These commandline invocations will fetch the distribution from PyPI, install the package and specified dependencies.
Contemporary Ways
Here are some alternatives to pip
:
pipx
: "safely" install packages in isolated environments> pipx install <package>
See Also
Official docs on publishing packages by PyPA
Tutorial on How To Package Your Python Code
Podcast interview with B. Cannon onpyproject.toml
and modern packaging tools
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55953391%2fwhat-if-the-end-user-didnt-have-the-required-library%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is
In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires
key) that would be installed along with your package when the end-user installs it.
The end user could then use pip to install your package eg
pip install YourPackage
and all dependencies listed in setup.py would be installed first.
Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with
pip install -r requirements.txt YourPackage
See this guide for building a python package,
setuptools documentation
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
1
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
2
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
2
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in itssetup('requires'=[...])
field, they will be fetched automatically if you try to install your package
– Arne
May 2 at 14:05
1
@Kepler186 And if the end user usespip3
instead? Or if they usepython -m pip
instead (becausepip
isn't in the environment variables)? There are many flaws with your os approach.
– MilkyWay90
May 2 at 23:49
|
show 8 more comments
Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is
In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires
key) that would be installed along with your package when the end-user installs it.
The end user could then use pip to install your package eg
pip install YourPackage
and all dependencies listed in setup.py would be installed first.
Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with
pip install -r requirements.txt YourPackage
See this guide for building a python package,
setuptools documentation
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
1
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
2
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
2
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in itssetup('requires'=[...])
field, they will be fetched automatically if you try to install your package
– Arne
May 2 at 14:05
1
@Kepler186 And if the end user usespip3
instead? Or if they usepython -m pip
instead (becausepip
isn't in the environment variables)? There are many flaws with your os approach.
– MilkyWay90
May 2 at 23:49
|
show 8 more comments
Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is
In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires
key) that would be installed along with your package when the end-user installs it.
The end user could then use pip to install your package eg
pip install YourPackage
and all dependencies listed in setup.py would be installed first.
Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with
pip install -r requirements.txt YourPackage
See this guide for building a python package,
setuptools documentation
Whatever your project is, you could try making it into a python package that the end-user would install. The way this works is
In the root directory of your package you would include a setup.py. You could include in this file a list of requirements/dependencies (the install_requires
key) that would be installed along with your package when the end-user installs it.
The end user could then use pip to install your package eg
pip install YourPackage
and all dependencies listed in setup.py would be installed first.
Additionally, as @Devesh Kumar Singh pointed out in his comment, you could also include a requirements.txt file. The user could then install using this file with
pip install -r requirements.txt YourPackage
See this guide for building a python package,
setuptools documentation
edited May 2 at 19:26
Mooseman
16.7k11 gold badges61 silver badges85 bronze badges
16.7k11 gold badges61 silver badges85 bronze badges
answered May 2 at 13:25
RSHAPRSHAP
1,1754 silver badges24 bronze badges
1,1754 silver badges24 bronze badges
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
1
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
2
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
2
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in itssetup('requires'=[...])
field, they will be fetched automatically if you try to install your package
– Arne
May 2 at 14:05
1
@Kepler186 And if the end user usespip3
instead? Or if they usepython -m pip
instead (becausepip
isn't in the environment variables)? There are many flaws with your os approach.
– MilkyWay90
May 2 at 23:49
|
show 8 more comments
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
1
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
2
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
2
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in itssetup('requires'=[...])
field, they will be fetched automatically if you try to install your package
– Arne
May 2 at 14:05
1
@Kepler186 And if the end user usespip3
instead? Or if they usepython -m pip
instead (becausepip
isn't in the environment variables)? There are many flaws with your os approach.
– MilkyWay90
May 2 at 23:49
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
Interesting. Also, I could just include os.system("pip install -r requirements.txt") in the setup.py right? Or the requirements.txt meant to be read by the user?
– Kepler 186
May 2 at 13:54
1
1
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
@RSHAP No, that would conflate the environment with the dependencies
– Arne
May 2 at 13:59
2
2
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
@RSHAP dstufft on the matter: caremad.io/posts/2013/07/setup-vs-requirement
– Arne
May 2 at 14:00
2
2
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in its
setup('requires'=[...])
field, they will be fetched automatically if you try to install your package– Arne
May 2 at 14:05
yes, if you build your code into a package and have set up setup.py correctly by giving it all the dependencies in its
setup('requires'=[...])
field, they will be fetched automatically if you try to install your package– Arne
May 2 at 14:05
1
1
@Kepler186 And if the end user uses
pip3
instead? Or if they use python -m pip
instead (because pip
isn't in the environment variables)? There are many flaws with your os approach.– MilkyWay90
May 2 at 23:49
@Kepler186 And if the end user uses
pip3
instead? Or if they use python -m pip
instead (because pip
isn't in the environment variables)? There are many flaws with your os approach.– MilkyWay90
May 2 at 23:49
|
show 8 more comments
To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.
Files that I am aware of
requirements.txt: very simple
setup.py: Used when you publish your project on sides like pypi https://stackoverflow.com/a/1472014/8411228
Pipfile: The way to go when you work in an virtualenv https://docs.pipenv.org/en/latest/
environment.yml: Used for Conda environments https://tdhopper.com/blog/my-python-environment-workflow-with-conda/#fn:requirements-conda
add a comment
|
To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.
Files that I am aware of
requirements.txt: very simple
setup.py: Used when you publish your project on sides like pypi https://stackoverflow.com/a/1472014/8411228
Pipfile: The way to go when you work in an virtualenv https://docs.pipenv.org/en/latest/
environment.yml: Used for Conda environments https://tdhopper.com/blog/my-python-environment-workflow-with-conda/#fn:requirements-conda
add a comment
|
To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.
Files that I am aware of
requirements.txt: very simple
setup.py: Used when you publish your project on sides like pypi https://stackoverflow.com/a/1472014/8411228
Pipfile: The way to go when you work in an virtualenv https://docs.pipenv.org/en/latest/
environment.yml: Used for Conda environments https://tdhopper.com/blog/my-python-environment-workflow-with-conda/#fn:requirements-conda
To show other users, what libraries are needed for your project, you have multiple options. All options are some kind of files, that say which libraries are needed for this project.
Files that I am aware of
requirements.txt: very simple
setup.py: Used when you publish your project on sides like pypi https://stackoverflow.com/a/1472014/8411228
Pipfile: The way to go when you work in an virtualenv https://docs.pipenv.org/en/latest/
environment.yml: Used for Conda environments https://tdhopper.com/blog/my-python-environment-workflow-with-conda/#fn:requirements-conda
answered May 2 at 13:28
Uli SotschokUli Sotschok
8624 silver badges14 bronze badges
8624 silver badges14 bronze badges
add a comment
|
add a comment
|
Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.
PyInstaller Quickstart
This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.
add a comment
|
Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.
PyInstaller Quickstart
This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.
add a comment
|
Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.
PyInstaller Quickstart
This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.
Another option: You can use PyInstaller to freeze (packages) Python applications into stand-alone executables, under Windows, GNU/Linux, Mac OS X, FreeBSD, Solaris and AIX.
PyInstaller Quickstart
This has worked very well for me. Indeed, you do not have to worry about whether the final user has Python installed.
answered May 2 at 16:18
user11293039user11293039
411 bronze badge
411 bronze badge
add a comment
|
add a comment
|
Here is where packaging a python project into a module comes handy modules
We include a requirements.txt
file which contains all python module requirements needed for that python library, and installs them automatically when the module is setup.
A good primer on how to setup your module to be distributable is Structuring your project
Just arequirements.txt
is not enough right? I think you also need an__init__.py
,setup.py
and maybe more. docs.python-guide.org/writing/structure
– 3UqU57GnaX
May 2 at 13:24
Yes, the question was about how to installed required libraries, which are listed inrequirements.txt
, and on top of it, we have these things you mentioned!
– Devesh Kumar Singh
May 2 at 13:25
add a comment
|
Here is where packaging a python project into a module comes handy modules
We include a requirements.txt
file which contains all python module requirements needed for that python library, and installs them automatically when the module is setup.
A good primer on how to setup your module to be distributable is Structuring your project
Just arequirements.txt
is not enough right? I think you also need an__init__.py
,setup.py
and maybe more. docs.python-guide.org/writing/structure
– 3UqU57GnaX
May 2 at 13:24
Yes, the question was about how to installed required libraries, which are listed inrequirements.txt
, and on top of it, we have these things you mentioned!
– Devesh Kumar Singh
May 2 at 13:25
add a comment
|
Here is where packaging a python project into a module comes handy modules
We include a requirements.txt
file which contains all python module requirements needed for that python library, and installs them automatically when the module is setup.
A good primer on how to setup your module to be distributable is Structuring your project
Here is where packaging a python project into a module comes handy modules
We include a requirements.txt
file which contains all python module requirements needed for that python library, and installs them automatically when the module is setup.
A good primer on how to setup your module to be distributable is Structuring your project
edited May 2 at 13:26
answered May 2 at 13:22
Devesh Kumar SinghDevesh Kumar Singh
18.1k4 gold badges15 silver badges34 bronze badges
18.1k4 gold badges15 silver badges34 bronze badges
Just arequirements.txt
is not enough right? I think you also need an__init__.py
,setup.py
and maybe more. docs.python-guide.org/writing/structure
– 3UqU57GnaX
May 2 at 13:24
Yes, the question was about how to installed required libraries, which are listed inrequirements.txt
, and on top of it, we have these things you mentioned!
– Devesh Kumar Singh
May 2 at 13:25
add a comment
|
Just arequirements.txt
is not enough right? I think you also need an__init__.py
,setup.py
and maybe more. docs.python-guide.org/writing/structure
– 3UqU57GnaX
May 2 at 13:24
Yes, the question was about how to installed required libraries, which are listed inrequirements.txt
, and on top of it, we have these things you mentioned!
– Devesh Kumar Singh
May 2 at 13:25
Just a
requirements.txt
is not enough right? I think you also need an __init__.py
, setup.py
and maybe more. docs.python-guide.org/writing/structure– 3UqU57GnaX
May 2 at 13:24
Just a
requirements.txt
is not enough right? I think you also need an __init__.py
, setup.py
and maybe more. docs.python-guide.org/writing/structure– 3UqU57GnaX
May 2 at 13:24
Yes, the question was about how to installed required libraries, which are listed in
requirements.txt
, and on top of it, we have these things you mentioned!– Devesh Kumar Singh
May 2 at 13:25
Yes, the question was about how to installed required libraries, which are listed in
requirements.txt
, and on top of it, we have these things you mentioned!– Devesh Kumar Singh
May 2 at 13:25
add a comment
|
So you made a package. Now you will want to share it. What next?
Developer
Goal - make a distribution (also called a "package") to share
Preamble
You are now packaging your package and wish to distribute it. There are two main kinds of packages:
- an application: deploy a source to a server, github, website e.g. CLI
- a library: publish a source distribution (sdist) or binary (e.g. wheel) usually to PyPI via
twine
Traditional Ways
Several files may be included in a distribution, but here are the main ones:
- source: your code
setup.py
: specify metadata, and dependencies required to make an sdist.requirements.txt
: a list of dependencies
Contemporary Ways
Use pyproject.toml
to specify which tool to use in creating your sdist or binary:
Modern tools to create + deploy/publish a package include:
pipenv
: makes a package and substitutesrequirements.txt
(recommended by PyPA)- develop:
> pipenv install <dependency>
,> pipenv install
- publish:
> pipenv -e .
+twine
- develop:
poetry
: makes a package and publishes to PyPI- develop
> poetry add <dependency>
,> poetry install
- publish:
> poetry publish
- develop
flit
: makes a package and publishes to PyPI- develop:
> flit install
- publish:
> flit publish
- develop:
The first two options have features to make clean virtual environments and safely install dependencies using lock files. I would encourage exploring these newer options later on as they clear up a lot of packaging headaches by obviating setup.py
and setuptools
.
User
Goal - get a package and install it with dependencies
Traditional Ways
Applications have a variety of deployment methods, e.g. uploading your app to a hosting service e.g. heroku, DigitalOcean, etc. The user may indirectly interface with your app through a website, CLI or more.
Libraries are often uploaded to PyPI. From here the user can usually install a package using pip
independent from how they are made:
> pip install <package>
(recommended)> pip install <packatge> -r requirements
(explicit, optional)
These commandline invocations will fetch the distribution from PyPI, install the package and specified dependencies.
Contemporary Ways
Here are some alternatives to pip
:
pipx
: "safely" install packages in isolated environments> pipx install <package>
See Also
Official docs on publishing packages by PyPA
Tutorial on How To Package Your Python Code
Podcast interview with B. Cannon onpyproject.toml
and modern packaging tools
add a comment
|
So you made a package. Now you will want to share it. What next?
Developer
Goal - make a distribution (also called a "package") to share
Preamble
You are now packaging your package and wish to distribute it. There are two main kinds of packages:
- an application: deploy a source to a server, github, website e.g. CLI
- a library: publish a source distribution (sdist) or binary (e.g. wheel) usually to PyPI via
twine
Traditional Ways
Several files may be included in a distribution, but here are the main ones:
- source: your code
setup.py
: specify metadata, and dependencies required to make an sdist.requirements.txt
: a list of dependencies
Contemporary Ways
Use pyproject.toml
to specify which tool to use in creating your sdist or binary:
Modern tools to create + deploy/publish a package include:
pipenv
: makes a package and substitutesrequirements.txt
(recommended by PyPA)- develop:
> pipenv install <dependency>
,> pipenv install
- publish:
> pipenv -e .
+twine
- develop:
poetry
: makes a package and publishes to PyPI- develop
> poetry add <dependency>
,> poetry install
- publish:
> poetry publish
- develop
flit
: makes a package and publishes to PyPI- develop:
> flit install
- publish:
> flit publish
- develop:
The first two options have features to make clean virtual environments and safely install dependencies using lock files. I would encourage exploring these newer options later on as they clear up a lot of packaging headaches by obviating setup.py
and setuptools
.
User
Goal - get a package and install it with dependencies
Traditional Ways
Applications have a variety of deployment methods, e.g. uploading your app to a hosting service e.g. heroku, DigitalOcean, etc. The user may indirectly interface with your app through a website, CLI or more.
Libraries are often uploaded to PyPI. From here the user can usually install a package using pip
independent from how they are made:
> pip install <package>
(recommended)> pip install <packatge> -r requirements
(explicit, optional)
These commandline invocations will fetch the distribution from PyPI, install the package and specified dependencies.
Contemporary Ways
Here are some alternatives to pip
:
pipx
: "safely" install packages in isolated environments> pipx install <package>
See Also
Official docs on publishing packages by PyPA
Tutorial on How To Package Your Python Code
Podcast interview with B. Cannon onpyproject.toml
and modern packaging tools
add a comment
|
So you made a package. Now you will want to share it. What next?
Developer
Goal - make a distribution (also called a "package") to share
Preamble
You are now packaging your package and wish to distribute it. There are two main kinds of packages:
- an application: deploy a source to a server, github, website e.g. CLI
- a library: publish a source distribution (sdist) or binary (e.g. wheel) usually to PyPI via
twine
Traditional Ways
Several files may be included in a distribution, but here are the main ones:
- source: your code
setup.py
: specify metadata, and dependencies required to make an sdist.requirements.txt
: a list of dependencies
Contemporary Ways
Use pyproject.toml
to specify which tool to use in creating your sdist or binary:
Modern tools to create + deploy/publish a package include:
pipenv
: makes a package and substitutesrequirements.txt
(recommended by PyPA)- develop:
> pipenv install <dependency>
,> pipenv install
- publish:
> pipenv -e .
+twine
- develop:
poetry
: makes a package and publishes to PyPI- develop
> poetry add <dependency>
,> poetry install
- publish:
> poetry publish
- develop
flit
: makes a package and publishes to PyPI- develop:
> flit install
- publish:
> flit publish
- develop:
The first two options have features to make clean virtual environments and safely install dependencies using lock files. I would encourage exploring these newer options later on as they clear up a lot of packaging headaches by obviating setup.py
and setuptools
.
User
Goal - get a package and install it with dependencies
Traditional Ways
Applications have a variety of deployment methods, e.g. uploading your app to a hosting service e.g. heroku, DigitalOcean, etc. The user may indirectly interface with your app through a website, CLI or more.
Libraries are often uploaded to PyPI. From here the user can usually install a package using pip
independent from how they are made:
> pip install <package>
(recommended)> pip install <packatge> -r requirements
(explicit, optional)
These commandline invocations will fetch the distribution from PyPI, install the package and specified dependencies.
Contemporary Ways
Here are some alternatives to pip
:
pipx
: "safely" install packages in isolated environments> pipx install <package>
See Also
Official docs on publishing packages by PyPA
Tutorial on How To Package Your Python Code
Podcast interview with B. Cannon onpyproject.toml
and modern packaging tools
So you made a package. Now you will want to share it. What next?
Developer
Goal - make a distribution (also called a "package") to share
Preamble
You are now packaging your package and wish to distribute it. There are two main kinds of packages:
- an application: deploy a source to a server, github, website e.g. CLI
- a library: publish a source distribution (sdist) or binary (e.g. wheel) usually to PyPI via
twine
Traditional Ways
Several files may be included in a distribution, but here are the main ones:
- source: your code
setup.py
: specify metadata, and dependencies required to make an sdist.requirements.txt
: a list of dependencies
Contemporary Ways
Use pyproject.toml
to specify which tool to use in creating your sdist or binary:
Modern tools to create + deploy/publish a package include:
pipenv
: makes a package and substitutesrequirements.txt
(recommended by PyPA)- develop:
> pipenv install <dependency>
,> pipenv install
- publish:
> pipenv -e .
+twine
- develop:
poetry
: makes a package and publishes to PyPI- develop
> poetry add <dependency>
,> poetry install
- publish:
> poetry publish
- develop
flit
: makes a package and publishes to PyPI- develop:
> flit install
- publish:
> flit publish
- develop:
The first two options have features to make clean virtual environments and safely install dependencies using lock files. I would encourage exploring these newer options later on as they clear up a lot of packaging headaches by obviating setup.py
and setuptools
.
User
Goal - get a package and install it with dependencies
Traditional Ways
Applications have a variety of deployment methods, e.g. uploading your app to a hosting service e.g. heroku, DigitalOcean, etc. The user may indirectly interface with your app through a website, CLI or more.
Libraries are often uploaded to PyPI. From here the user can usually install a package using pip
independent from how they are made:
> pip install <package>
(recommended)> pip install <packatge> -r requirements
(explicit, optional)
These commandline invocations will fetch the distribution from PyPI, install the package and specified dependencies.
Contemporary Ways
Here are some alternatives to pip
:
pipx
: "safely" install packages in isolated environments> pipx install <package>
See Also
Official docs on publishing packages by PyPA
Tutorial on How To Package Your Python Code
Podcast interview with B. Cannon onpyproject.toml
and modern packaging tools
edited May 4 at 21:59
answered May 3 at 19:40
pylangpylang
17.2k5 gold badges59 silver badges64 bronze badges
17.2k5 gold badges59 silver badges64 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55953391%2fwhat-if-the-end-user-didnt-have-the-required-library%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Depends on what you mean by "proper".
– Scott Hunter
May 2 at 13:20
Related: Best practice to install dependencies?
– Aran-Fey
May 2 at 13:22