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?
Can a tourist shoot a gun in the USA?
Will a coyote attack my dog on a leash while I'm on a hiking trail?
Labeling matrices/rectangles and drawing Sigma inside rectangle
How can I answer high-school writing prompts without sounding weird and fake?
Is there ever any indication in the MCU as to how Spider-Man got his powers?
Jumping frame contents with beamer and pgfplots
Would an 8% reduction in drag outweigh the weight addition from this custom CFD-tested winglet?
Is it possible to create different colors in rocket exhaust?
German characters on US-International keyboard layout
Does gravity affect the time evolution of a QM wave function?
51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?
Why are solar panels kept tilted?
Is Germany still exporting arms to countries involved in Yemen?
Unexpected Netflix account registered to my Gmail address - any way it could be a hack attempt?
Help in identifying a mystery wall socket
Frame adjustment for engine
Rounding a number extracted by jq to limit the decimal points
Why did the metro bus stop at each railway crossing, despite no warning indicating a train was coming?
Anatomically Correct Carnivorous Tree
Why do the lights go out when someone enters the dining room on this ship?
Solubility in different pressure conditions
Is taking modulus on both sides of an equation valid?
What is the largest number of identical satellites launched together?
return tuple of uncopyable objects
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 height:90px;width:728px;box-sizing:border-box;
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
896
896
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/3.0/"u003ecc by-sa 3.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.5k116184
16.5k116184
answered May 2 at 13:25
RSHAPRSHAP
1,071417
1,071417
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
648114
648114
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
311
311
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
8,8531728
8,8531728
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
14.9k24558
14.9k24558
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