Showing preview only (478K chars total). Download the full file or copy to clipboard to get everything.
Repository: PyAr/fades
Branch: master
Commit: a281c68b6b7e
Files: 88
Total size: 452.7 KB
Directory structure:
gitextract_2mmkzg90/
├── .flake8
├── .github/
│ └── workflows/
│ ├── integtests.yaml
│ └── tests.yaml
├── .gitignore
├── .readthedocs.yaml
├── AUTHORS
├── COPYING
├── HOWTO_RELEASE.txt
├── LICENSE
├── MANIFEST.in
├── README.rst
├── bin/
│ ├── fades
│ └── fades.cmd
├── build_readme
├── docs/
│ ├── Makefile
│ ├── conf.py
│ ├── index.rst
│ ├── pydepmanag.rst
│ ├── readme.rst
│ └── requirements.txt
├── fades/
│ ├── __init__.py
│ ├── __main__.py
│ ├── _version.py
│ ├── cache.py
│ ├── envbuilder.py
│ ├── file_options.py
│ ├── helpers.py
│ ├── logger.py
│ ├── main.py
│ ├── multiplatform.py
│ ├── parsing.py
│ ├── pipmanager.py
│ └── pkgnamesdb.py
├── man/
│ └── fades.1
├── pkg/
│ ├── debian/
│ │ ├── changelog
│ │ ├── compat
│ │ ├── control
│ │ ├── copyright
│ │ ├── rules
│ │ └── watch
│ └── snap/
│ └── snapcraft.yaml
├── press.txt
├── requirements.txt
├── resources/
│ ├── gifs/
│ │ └── gifs.rst
│ ├── notes.txt
│ ├── slides.odp
│ ├── slides_LT.odp
│ └── video/
│ └── script.ods
├── setup.py
├── test
├── testdev
├── testdev.bat
└── tests/
├── __init__.py
├── conftest.py
├── examples/
│ ├── pypi_get_version_fail.json
│ └── pypi_get_version_ok.json
├── integtest.py
├── test_cache/
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_caches.py
│ ├── test_comparisons.py
│ ├── test_remove.py
│ ├── test_selection.py
│ └── test_store.py
├── test_envbuilder.py
├── test_file_options.py
├── test_files/
│ ├── fades_as_part_of_other_word.py
│ ├── no_req.py
│ ├── req_all.py
│ ├── req_class.py
│ ├── req_def.py
│ ├── req_mixed_backends.py
│ ├── req_module.py
│ ├── req_module_2.py
│ └── req_module_3.py
├── test_helpers.py
├── test_infra.py
├── test_logger.py
├── test_main.py
├── test_multiplatform.py
├── test_parsing/
│ ├── test_docstrings.py
│ ├── test_file.py
│ ├── test_file_reqs.py
│ ├── test_manual.py
│ ├── test_reqs.py
│ └── test_vcs_dependency.py
├── test_pipmanager.py
└── test_pkgnamesdb.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .flake8
================================================
[flake8]
max-line-length=99
exclude=.git
select=E,W,F,C,N
ignore=
================================================
FILE: .github/workflows/integtests.yaml
================================================
name: Integration Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
archlinux:
runs-on: ubuntu-latest
container:
# Use https://github.com/gilgamezh/archlinux-python39 to save the python build time
image: gilgamezh/archlinux-python39:latest
volumes:
- ${{ github.workspace }}:/fades
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
pacman -Suy --noconfirm python3 python-packaging
- name: Simple fades run
run: |
cd /fades
bin/fades -v -d pytest -x pytest --version
- name: Using a different Python
run: |
python bin/fades -v --python=python3.9 -d pytest -x pytest -v --integtest-pyversion=3.9 tests/integtest.py
fedora:
runs-on: ubuntu-latest
container:
image: fedora:latest
volumes:
- ${{ github.workspace }}:/fades
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install dependencies
run: |
yum install --assumeyes python3.13 python-packaging
- name: Simple fades run
run: |
cd /fades
bin/fades -v -d pytest -x pytest --version
- name: Using a different Python
run: |
yum install --assumeyes python3.9
cd /fades
python3.13 bin/fades -v --python=python3.9 -d pytest -x pytest -v --integtest-pyversion=3.9 tests/integtest.py
native-windows:
strategy:
matrix:
# just a selection otherwise it's too much
# - latest OS (left here even if it's only one to simplify upgrading later)
# - oldest and newest Python
os: [windows-2025]
python-version: [3.8, "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v5
id: matrixpy
with:
python-version: ${{ matrix.python-version }}
- name: Also set up Python 3.10 for cross-Python test
uses: actions/setup-python@v5
id: otherpy
with:
python-version: "3.10"
- name: Install dependencies
run: |
${{ steps.matrixpy.outputs.python-path }} -m pip install -U packaging
- name: Simple fades run
run: |
${{ steps.matrixpy.outputs.python-path }} bin/fades -v -d pytest -x pytest --version
- name: Using a different Python
run: |
${{ steps.matrixpy.outputs.python-path }} bin/fades -v --python=${{ steps.otherpy.outputs.python-path }} -d pytest -x pytest -v --integtest-pyversion=3.10 tests/integtest.py
native-generic:
strategy:
matrix:
# just a selection otherwise it's too much
# - latest OSes
# - oldest and newest Python
os: [ubuntu-24.04, macos-15]
python-version: [3.8, "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v5
id: matrixpy
with:
python-version: ${{ matrix.python-version }}
- name: Also set up Python 3.10 for cross-Python test
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
${{ steps.matrixpy.outputs.python-path }} -m pip install -U packaging
- name: Simple fades run
run: |
${{ steps.matrixpy.outputs.python-path }} bin/fades -v -d pytest -x pytest --version
- name: Using a different Python
run: |
${{ steps.matrixpy.outputs.python-path }} bin/fades -v --python=python3.10 -d pytest -x pytest -v --integtest-pyversion=3.10 tests/integtest.py
================================================
FILE: .github/workflows/tests.yaml
================================================
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
run-tests:
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04, macos-14, macos-15, windows-2022, windows-2025]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -U -r requirements.txt
- name: Run tests
run: |
pytest
================================================
FILE: .gitignore
================================================
# Generated as a side effect of development
README.html
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
.mypy_cache/
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# archlinux
!pkg/archlinux/PKGBUILD
pkg/archlinux/*
# Ides
.vscode/
.idea/
================================================
FILE: .readthedocs.yaml
================================================
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
---
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
sphinx:
configuration: docs/conf.py
python:
install:
- requirements: docs/requirements.txt
================================================
FILE: AUTHORS
================================================
Alejandro Dau <alejandro@dau.com.ar>
Andrés Delfino <adelfino@gmail.com>
Ariel Rossanigo <arielrossanigo@gmail.com>
Berenice Larsen Pereyra <berelarsenp@gmail.com>
David Litvak Bruno <david.litvakb@gmail.com>
Diego Duncan <diegoduncan21@gmail.com>
Diego Mascialino <dmascialino@gmail.com>
Eduardo Enriquez <eduardo.a.enriquez@gmail.com>
Facundo Batista <facundo@taniquetil.com.ar>
FaQ <facundofc@gmail.com>
Filipe Ximenes <filipeximenes@gmail.com>
gera <gera@satellogic.com>
jairot <jairotrad@gmail.com>
Javier Andres Mansilla <jmansilla@machinalis.com>
Juan <juan.carizza@gmail.com>
Juan Carlos <juancarlospaco@gmail.com>
Lucio Torre <lucio@satellogic.com>
Manuel Kaufmann <humitos@gmail.com>
Martin Alderete <malderete@gmail.com>
matuu <matu.varela@gmail.com>
Nicolás Demarchi <mail@gilgamezh.me>
Ricardo Kirkner <ricardo@kirkner.com.ar>
Rushil Patel <rushil.patel20@imperial.ac.uk>
================================================
FILE: COPYING
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
================================================
FILE: HOWTO_RELEASE.txt
================================================
Steps before a release is done
------------------------------
Check all is crispy
rm -rf build dist
./setup.py clean build
./setup.py clean sdist
Edit the ``fades/_version.py`` file properly, then tag and commit/push
git tag release-VERSION
git commit -am "Release VERSION"
git push --tag
How to release it to PyPI
-------------------------
Dead simple:
rm -rf build dist
./setup.py clean sdist
fades -d twine -x twine upload dist/fades-*
How to create a .deb
--------------------
Create the tarball:
rm -rf build dist
./setup.py clean sdist
Copy this tarball to a clean dir, renaming as "orig"
mkdir /tmp/fades_pack
cp dist/fades-X.Y.tar.gz /tmp/fades_pack/fades_X.Y.orig.tar.gz
cd /tmp/fades_pack
Most of next instructions come from http://wiki.debian.org/Python/GitPackaging
tar -xf fades_X.Y.orig.tar.gz
cd fades-X.Y
git init
git add .
git commit -m "import fades_X.Y.orig.tar.gz"
git checkout -b upstream
pristine-tar commit ../fades_X.Y.orig.tar.gz upstream
git-dpm init ../fades_X.Y.orig.tar.gz
Copy the project's debian dir and change changelog (be sure that this
"debian" dir is properly updated in the project... notably, be sure
copyright year is current one and also that no new dependencies were
introduced since last release).
cp -pr $DEVEL/fades/pkg/debian .
dch # doing the following:
- version should be (X.Y-1) unstable
- just leave one "* Initial release."
Continue with preparations:
git add debian/*
git commit -m "Added debian dir."
git-dpm prepare
git-dpm status
Build the .deb
debuild -us -uc -I -i
To test the .deb you just created:
sudo dpkg -i *.deb
If you want to uninstall it do:
sudo dpkg -r fades
How to release it to Debian
---------------------------
Need just to report a bug very similar to this one: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=814913
For that, just run the following and answer the questions:
reportbug -B debian
(I had to do that twice, not sure why: first time it asked some questions and then errored out, second time it picked up from there and finish the job)
How to release it to Arch
-------------------------
Changes should be applied in the AUR repo ``ssh://aur@aur.archlinux.org/fades.git``
Edit ``pkg/archlinux/PKGBUILD`` and set *pkgver* and *sha256sums*, then run
``makepkg --printsrcinfo > .SRCINFO`` to update the .SRCINFO file.
Finally commit and push the changes. The package will be automatically updated in AUR.
``https://aur.archlinux.org/packages/fades``
How to release it to the Snap store
-----------------------------------
Edit the snapcraft yaml and change the "version" number
vi pkg/snap/snapcraft.yaml
Build the snap (no need to specify the YAML, there is a hidden symlink to it):
snapcraft
Push it to the store and release:
snapcraft push fades_6.0_amd64.snap
snapcraft release fades <revno just pushed> edge beta
Test it:
sudo snap install fades --channel=beta --classic
/snap/fades/current/bin/fades -V
If all is fine, release it to candidate:
snapcraft release fades <revno just pushed> candidate
Announce internally: telegram, fades mail list.
Wait 3 days or so, and release to stable:
snapcraft release fades <revno just pushed> stable
Announce in the snapcraft forum, something similar to:
https://forum.snapcraft.io/t/call-for-testing-fades-7/5070
Read the Docs
-------------
- go and login there, go to "fades" project
- in "Versions" tab, activate the new version (corresponding to the release in github)
- in "Administrator" tab, go to option "Advanced configuration" at the left, choose latest release as "default version"
- verify all latest is seen in
http://fades.rtfd.org/
How to sign the files
---------------------
If you are putting files to download (notably, installators: .deb,
tarballs, etc) it's a good idea to sign them and offer checksums, in
case of somebody wanting to validate the files.
To sign it:
gpg --armor --sign --detach-sig FILENAME
To create the checksum:
sha1sum FILENAME > FILENAME.sha1
Final steps
-----------
- Remember to update the .deb and .tar.gz in www.taniquetil.com.ar/fades
- Create a change log and send press releases:
- a tweet,
- PyAr mail list, IRC and Telegram group
- fades' Telegram group and mail list
- python-announces
================================================
FILE: LICENSE
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
================================================
FILE: MANIFEST.in
================================================
include README.rst
include COPYING
include AUTHORS
include man/fades.1
================================================
FILE: README.rst
================================================
What is fades?
==============
.. image:: https://github.com/PyAr/fades/actions/workflows/test.uaml/badge.svg
:target: https://github.com/PyAr/fades/actions/workflows/test.uaml/badge.svg
.. image:: https://readthedocs.org/projects/fades/badge/?version=latest
:target: http://fades.readthedocs.org/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://badge.fury.io/py/fades.svg
:target: https://badge.fury.io/py/fades
.. image:: https://coveralls.io/repos/PyAr/fades/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/PyAr/fades?branch=master
.. image:: https://build.snapcraft.io/badge/PyAr/fades.svg
:target: https://build.snapcraft.io/user/PyAr/fades
:alt: Snap Status
.. image:: https://ci.appveyor.com/api/projects/status/crkqv82t1l731fms/branch/master?svg=true
:target: https://ci.appveyor.com/project/facundobatista/fades
:alt: Appveyor Status
fades is a system that automatically handles the virtual environments in the
cases normally found when writing scripts and simple programs, and
even helps to administer big projects.
.. image:: resources/logo256.png
*fades* will automagically create a new virtual environment (or reuse a previous
created one), installing the necessary dependencies, and execute
your script inside that virtual environment, with the only requirement
of executing the script with *fades* and also marking the required
dependencies.
*(If you don't have a clue why this is necessary or useful, I'd recommend you
to read this small text about* `Python and the Management of Dependencies
<https://github.com/PyAr/fades/blob/master/docs/pydepmanag.rst>`_ *.)*
The first non-option parameter (if any) would be then the child program
to execute, and any other parameters after that are passed as is to that
child script.
*fades* can also be executed without passing a child script to execute:
in this mode it will open a Python interactive interpreter inside the
created/reused virtual environment (taking dependencies from ``--dependency`` or
``--requirement`` options).
.. contents::
How to use it?
==============
Click in the following image to see a video/screencast that shows most of
fades features in just 5'...
.. image:: resources/video/screenshot.png
:target: https://www.youtube.com/watch?v=BCTd_TyCm98
...or inspect `these several small GIFs <resources/gifs/gifs.rst>`_ that
show each a particular `fades` functionality, but please keep also reading
for more detailed information...
Yes, please, I want to read
---------------------------
When you write an script, you have to take two special measures:
- need to execute it with *fades* (not *python*)
- need to mark those dependencies
At the moment you execute the script, fades will search a
virtual environment with the marked dependencies, if it doesn't exists
fades will create it, and execute the script in that environment.
How to execute the script with fades?
-------------------------------------
You can always call your script directly with fades::
fades myscript.py
However, for you to not forget about fades and to not execute it
directly with python, it's better if you put at the beggining of
the script the indication for the operating system that it should
be executed with fades... ::
#!/usr/bin/env fades
...and also set the executable bit in the script::
chmod +x yourscript.py
You can also execute scripts directly from the web, passing directly the
URL of the pastebin where the script is pasted (most common pastebines are
supported, pastebin.com, gist, linkode.org, but also it's supported if
the URL points to the script directly)::
fades http://myserver.com/myscript.py
How to mark the dependencies to be installed?
---------------------------------------------
The procedure to mark a module imported by the script as a *dependency
to be installed by fades* is by using a comment.
This comment will normally be in the same line of the import (recommended,
less confusing and less error prone in the future), but it also can be in
the previous one.
The simplest comment is like::
import somemodule # fades
from somepackage import othermodule # fades
The ``fades`` is mandatory, in this examples the repository is PyPI,
see `About different repositories`_ below for other examples.
With that comment, *fades* will install automatically in the virtual environment the
``somemodule`` or ``somepackage`` from PyPI.
Also, you can indicate a particular version condition, examples::
import somemodule # fades == 3
import somemodule # fades >= 2.1
import somemodule # fades >=2.1,<2.8,!=2.6.5
Sometimes, the project itself doesn't match the name of the module; in
these cases you can specify the project name (optionally, before the
version)::
import bs4 # fades beautifulsoup4
import bs4 # fades beautifulsoup4 == 4.2
What if no script is given to execute?
--------------------------------------
If no script or program is passed to execute, *fades* will provide a virtual environment
with all the indicated dependencies, and then open an interactive interpreter
in the context of that virtual environment.
Here is where it comes very handy the ``-i/--ipython`` option, if that REPL
is preferred over the standard one.
In the case of using an interactive interpreter, it's also very useful to
make *fades* to automatically import all the indicated dependencies,
passing the ``--autoimport`` parameter.
Other ways to specify dependencies
----------------------------------
Apart of marking the imports in the source file, there are other ways
to tell *fades* which dependencies to install in the virtual environment.
One way is through command line, passing the ``--dependency`` parameter.
This option can be specified multiple times (once per dependency), and
each time the format is ``repository::dependency``. The dependency may
have versions specifications, and the repository is optional (defaults
to 'pypi').
Another way is to specify the dependencies in a text file, one dependency
per line, with each line having the format previously described for
the ``--dependency`` parameter. This file is then indicated to fades
through the ``--requirement`` parameter. This option can be specified
multiple times.
In case of multiple definitions of the same dependency, command line
overrides everything else, and requirements file overrides what is
specified in the source code.
Finally, you can include package names in the script docstring, after
a line where "fades" is written, until the end of the docstring;
for example::
"""Script to do stuff.
It's a very important script.
We need some dependencies to run ok, installed by fades:
request
otherpackage
"""
About different repositories
----------------------------
*fades* supports installing the required dependencies from multiples repositories: besides PyPI, you can specify URLs that can point to projects from GitHub, Launchpad, etc. (basically, everything that is supported by ``pip`` itself).
When a dependency is specified, *fades* deduces the proper repository. For example, in the following examples *fades* will install requests from the latest revision from PyPI in the first case, and in the second case the latest revision from the project itself from GitHub::
-d requests
-d git+https://github.com/kennethreitz/requests.git#egg=requests
If you prefer, you can be explicit about which kind of repository *fades* should use, prefixing the dependency with the special token double colon (``::``)::
-d pypi::requests
-d vcs::git+https://github.com/kennethreitz/requests.git#egg=requests
There are two basic repositories: ``pypi`` which will make *fades* to install the desired dependency from PyPI, and ``vcs``, which will make *fades* to treat the dependency as a URL for a version control system site. In the first case, for PyPI, a full range of version comparators can be specified, as usual. For ``vcs`` repositories, though, the comparison is always exact: if the very same dependency is specified, a *virtual environment* is reused, otherwise a new one will be created and populated.
In both cases (specifying the repository explicitly or implicitly) there is no difference if the dependency is specified in the command line, in a ``requirements.txt`` file, in the script's docstring, etc. In the case of marking the ``import`` directly in the script, it slightly different.
When marking the ``import`` it normally happens that the package itself to be installed has the name of the imported module, and because of that it can only be found in PyPI. So, in the following cases the ``pypi`` repository is not only deduced, but unavoidable::
import requests # fades
from foo import bar # fades
import requests # fades <= 3
But if the package is specified (normally needed because it's different than the module name), or if a version control system URL is specified, the same possibilities stated above are available: let *fades* to deduce the proper repository or mark it explicitly::
import bs4 # fades beautifulsoup
import bs4 # fades pypi::beautifulsoup
import requests # fades git+https://github.com/kennethreitz/requests.git#egg=requests
import requests # fades vcs::git+https://github.com/kennethreitz/requests.git#egg=requests
One last detail about the ``vcs`` repository: the format to write the URLs is the same (as it's passed without modifications) than what ``pip`` itself supports (see `pip docs <https://pip.readthedocs.io/en/stable/reference/pip_install/#vcs-support>`_ for more details).
Furthermore, you can install from local projects. It's just fine to use a
dependency that starts with ``file:``. E.g. (please note the triple slash,
because we're mixing the protocol indication with the path)::
fades -d file:///home/crazyuser/myproject/allstars/
How to control the virtual environment creation and usage?
----------------------------------------------------------
You can influence several details of all the virtual environment related process.
The most important detail is which version of Python will be used in
the virtual environment. Of course, the corresponding version of Python needs to
be installed in your system, but you can control exactly which one to use.
No matter which way you're executing the script (see above), you can
pass a ``-p`` or ``--python`` argument, indicating the Python version to
be used just with the number (``3.9``), the whole name (``python3.9``) or
the whole path (``/usr/bin/python3.9``).
Other detail is the verbosity of *fades* when telling what is doing. By
default, *fades* only will use stderr to tell if a virtual environment is being
created, and to let the user know that is doing an operation that
requires an active network connection (e.g. installing a new dependency).
If you call *fades* with ``-v`` or ``--verbose``, it will send all internal
debugging lines to stderr, which may be very useful if any problem arises.
On the other hand if you pass the ``-q`` or ``--quiet`` parameter, *fades*
will not show anything (unless it has a real problem), so the original
script stderr is not polluted at all.
If you want to use IPython shell you need to call *fades* with ``-i`` or
``--ipython`` option. This option will add IPython as a dependency to *fades*
and it will launch this shell instead of the python one.
You can also use ``--system-site-packages`` to create a venv with access to
the system libs.
Finally, no matter how the virtual environment was created, you can always get the
base directory of the virtual environment in your system using the ``--where`` (or its
alias ``--get-venv-dir``) option.
Running programs in the context of the virtual environment
----------------------------------------------------------
The ``-x/--exec`` parameter allows you to execute any program (not just
a Python one) in the context of the virtual environment.
By default the mandatory given argument is considered the executable
name, relative to the environment's ``bin`` directory, so this is
specially useful to execute installed scripts/program by the declared
dependencies. E.g.::
fades -d flake8 -x flake8 my_script_to_be_verified_by_flake8.py
Take in consideration that you can pass an absolute path and it will be
respected (but not a relative path, as it will depend of the virtual environment
location).
For example, if you want to run a shell script that in turn runs a Python
program that needs to be executed in the context of the virtual environment, you
can do the following::
fades -r requirements.txt --exec /var/lib/foobar/special.sh
Finally, if the intended code to run is prepared to be executed as a module
(what you would normally run as `python3 -m some_module`), you can
use the same parameter with *fades* to run that module inside the virtual environment::
fades -r requirements.txt -m some_module
How to deal with packages that are upgraded in PyPI
---------------------------------------------------
When you tell *fades* to create a virtual environment using one dependency and
don't specify a version, it will install the latest one from PyPI.
For example, you do ``fades -d foobar`` and it installs foobar in
version 7. At some point, there is a new version of foobar in PyPI,
version 8, but if do ``fades -d foobar`` it will just reuse previously
created virtual environment, with version 7, not downloading the new version and
creating a new virtual environment with it!
You can tell fades to do otherwise, just do::
fades -d foobar --check-updates
...and *fades* will search updates for the package on PyPI, and as it will
found version 8, will create a new virtual environment using the latest version. You
can also use the ``-U`` option as an alias for ``--check-updates``::
fades -d foobar -U
From this moment on, if you request ``fades -d foobar`` it will bring the
virtual environment with the new version. If you want to get a virtual environment with
not-the-latest version for any dependency, just specify the proper versions.
You can even use the ``--check-updates`` parameter when specifying the package
version. Say you call ``fades -d foobar==7``, *fades* will install version 7 no
matter which one is the latest. But if you do::
fades -d foobar==7 --check-updates
...it will still use version 7, but will inform you that a new version
is available!
What about pinning dependencies?
--------------------------------
One nice benefit of *fades* is that every time dependencies change in your
project, you actually get to use a new virtual environment automatically.
If you don't pin the dependencies in your requirements file, this has
another nice side effect: everytime you use them in a new environment (or
if you have `--check-updates` set) you will get latest versions, effectively
avoiding the trap of sticking in old versions forever.
However, this has a bad side. If it happens that a dependency of your
project released a revision between the moment you run the tests and the
moment your project is deployed to the server, it may happen that you
actually put in production an untested combination. Furthermore, it may
happen that even if you do pin your dependencies, the dependencies of
those dependencies may not be pinned, and you get into the same situation.
For example, you may have the ``requests == 2.19.1`` dependency, but
``requests`` declares its own dependencies, for example
``chardet >= 3.0.2``, and when running tests locally you may get ``chardet``
in version ``3.0.3``, but nothing guarantees you that when deploying your
project to a server (effectively building everything from scratch) you will
not get a newer version of ``chardet``, which may be totally fine but in fact
it's something that you did NOT test locally.
Here is where *fades* comes to the rescue with the ``--freeze`` option. If
this parameter is given, *fades* will operate exactly as it normally would,
but also will dump the result of ``pip freeze`` into the specified file.
So to continue with the example above, you could run your tests like::
fades -d "requests == 2.19.1" --freeze=reqs-frozen.txt -x python3 -m unittest
...which will leave you ``reqs-frozen.txt`` with a content similar to::
certifi==2018.4.16
chardet==3.0.4
pip==18.0
requests==2.19.1
...
And then you could use *that file* for deployment, which has *all packages*
pinned, so you will get exactly what you was expecting.
Under the hood options
----------------------
For particular use cases you can send specifics arguments to the ``venv`` module, ``pip`` and ``python`` itself, using the ``--venv-options``, ``--pip-options`` and ``--python-options`` modifiers respectively. You have to use that argument for each argument sent.
Examples:
``fades -d requests --venv-options="--symlinks"``
``fades -d requests --pip-options="--index-url='http://example.com'"``
``fades --python-options=-B foo.py``
Setting options using config files
----------------------------------
You can also configure fades using `.ini` config files. fades will search config files in
`/etc/fades/fades.ini`, the path indicated by `xdg` for your system
(for example `~/config/fades/fades.ini`) and `.fades.ini`.
So you can have different settings at system, user and project level.
With fades installed you can get your config dir running::
python -c "from fades.helpers import get_confdir; print(get_confdir())"
The config files are in `.ini` format. (configparser) and fades will search for a `[fades]` section.
You have to use the same configurations that in the CLI. The only difference is with the config
options with a dash, it has to be replaced with a underscore.::
[fades]
ipython=true
verbose=true
python=python3
check_updates=true
dependency=requests;django>=1.8 # separated by semicolon
There is a little difference in how fades handle these settings: "dependency", "pip-options" and
"venv-options". In these cases you have to use a semicolon separated list.
The most important thing is that these options will be merged. So if you configure in
`/etc/fades/fades.ini` "dependency=requests" you will have requests in all the virtual environments
created by fades.
How to clean up old virtual environments?
-----------------------------------------
When using *fades* virtual environments are something you should not have to think about.
*fades* will do the right thing and create a new virtual environment that matches the required
dependencies. There are cases however when you'll want to do some clean up to remove
unnecessary virtual environments from disk.
By running *fades* with the ``--rm`` argument, *fades* will remove the
virtual environment matching the provided UUID if such environment exists (one easy
way to find out the environment's UUID is calling *fades* with the
``--where`` option).
Another way to clean up the cache is to remove all venvs that haven't been used for some time.
In order to do this you need to call *fades* with ``--clean-unused-venvs``.
When fades it's called with this option, it runs in mantain mode, this means that fades will exit
after finished this task.
All virtual environments that haven't been used for more days than the value indicated in param will be
removed.
It is recommended to have some automatically way of run this option;
ie, add a cron task that perform this command::
fades --clean-unused-venvs=42
Some command line examples
--------------------------
Execute ``foo.py`` under *fades*, passing the ``--bar`` parameter to the child program, in a virtual environment with the dependencies indicated in the source code::
fades foo.py --bar
Execute ``foo.py`` under *fades*, showing all the *fades* messages (verbose mode)::
fades -v foo.py
Execute ``foo.py`` under *fades* (passing the ``--bar`` parameter to it), in a virtual environment with the dependencies indicated in the source code and also ``dependency1`` and ``dependency2`` (any version > 3.2)::
fades -d dependency1 -d "dependency2>3.2" foo.py --bar
Execute the Python interactive interpreter in a virtual environment with ``dependency1`` installed::
fades -d dependency1
Execute the Python interactive interpreter in a virtual environment after installing there all dependencies taken from the ``requirements.txt`` file::
fades -r requirements.txt
Execute the Python interactive interpreter in a virtual environment after installing there all dependencies taken from files ``requirements.txt`` and ``requirements_devel.txt``::
fades -r requirements.txt -r requirements_devel.txt
Use the ``django-admin.py`` script to start a new project named ``foo``, without having to have django previously installed::
fades -d django -x django-admin.py startproject foo
Remove a virtual environment matching the given uuid from disk and cache index::
fades --rm 89a2bf83-c280-4918-a78d-c35506efd69d
Download the script from the given pastebin and executes it (previously building a virtual environment for the dependencies indicated in that pastebin, of course)::
fades http://linkode.org/#4QI4TrPlGf1gK2V7jPBC47
Run all the tests in a project (running ``pytest`` directly as a module, for better behaviour) and at the same time freeze dependencies for later deployment::
fades -r requirements.txt --freeze -m pytest -v
Some examples using fades in project scripts
--------------------------------------------
Including *fades* in project helper scripts makes it easy to stop
worrying about the virtual environment activation/deactivation when working
in that project, and also solves the problem of needing to
update/change/fix an already created virtual environment if the
dependencies change.
This is an example of how a script to run your project may look like::
#!/bin/sh
if (command -v fades > /dev/null)
then
# fades FTW!
fades -r requirements.txt bin/start
else
echo 2
# hope you are in the correct virtual environment
python3 bin/start
fi
To run the tests, it's super handy to have a script that also takes care
of the development dependencies::
#!/bin/sh
fades -r requirements.txt -r reqs-dev.txt -x python -m pytest -s "$@"
What if Python is updated in my system?
---------------------------------------
The virtual environments created by fades depend on the Python version used to
create them, considering its major and minor version.
This means that if run fades with a Python version and then run it again
with a different Python version, it may need to create a new virtual environment.
Let's see some examples. Let's say you run fades with ``python``, which
is a symlink in your ``/usr/bin/`` to ``python3.6`` (running it directly
by hand or because fades is installed to use that Python version).
If you have Python 3.6.2 installed in your system, and it's upgraded to
Python 3.6.3, fades will keep reusing the already created virtual environments, as
only the micro version changed, not minor or major.
But if Python 3.7 is installed in your system, and the default ``python``
is pointed to this new one, fades will start creating all the
virtual environments again, with this new version.
This is a good thing, because you want that the dependencies installed
with one specific Python in the virtual environment are kept being used by the
same Python version.
However, if you want to avoid this behaviour, be sure to always call fades
with the specific Python version (``/usr/bin/python3.6`` or ``python3.6``,
for example), so it won't matter if a new version is available in the
system.
How to install it
=================
Several instructions to install ``fades`` in different platforms.
Simplest way
------------
In some systems you can install ``fades`` directly, no needing to
install previously any dependency.
If you are in debian unstable or testing, just do:
sudo apt-get install fades
For Arch Linux, you can install it from the **AUR** using any `AUR helper <https://wiki.archlinux.org/index.php/AUR_helpers>`_, e.g. with ``pikaur``:
pikaur -S fades
In systems with Snaps:
snap install fades --classic
(why `--classic`? Because it's the only way that `fades` could, from
inside the snap, access the rest of the system in case you want to
use a different Python version, or a dependency that needs
compilation, etc).
For Mac OS X (and `Homebrew <http://brew.sh/>`_):
brew install fades
Else, keep reading to know how to install the dependencies first, and
``fades`` in your system next.
Dependencies
------------
Besides needing Python 3.6 or greater, fades depends on the ``python-xdg`` package. This package should be installed on any GNU/Linux OS wiht a freedesktop.org GUI. However it is an **optional** dependency.
You can install it in Ubuntu/Debian with::
apt-get install python3-xdg
And on Arch Linux with::
pacman -S python-xdg
For others debian and ubuntu
----------------------------
If you are NOT in debian unstable or testing (if you are, see
above for better instructions), you can use this
`.deb <http://ftp.debian.org/debian/pool/main/f/fades/fades_9.0.1-2_all.deb>`_.
Download it and install doing::
sudo dpkg -i fades_*.deb
Using pip if you want
----------------------
::
pip3 install fades
Multiplatform tarball
---------------------
Finally you can always get the multiplatform tarball and install
it in the old fashion way::
wget http://ftp.debian.org/debian/pool/main/f/fades/fades_9.0.1.orig.tar.gz
tar -xf fades_*.tar.gz
cd fades-*
sudo ./setup.py install
Can I try it without installing it?
-----------------------------------
Yes! Branch the project and use the executable::
git clone https://github.com/PyAr/fades.git
cd fades
bin/fades your_script.py
What about Windows?
-------------------
Windows is a platform supported by fades.
However, we don't have a proper Windows installer (a ``.exe`` or
``.msi``), but you can install it using ``pip``, or from the tarball,
or try it directly from the project. All these options are properly
described above.
We *do* want to have a Windows installer. If you can help us in this
regard, please contact us. Also we would want a Travis running in
Windows so that GitHub runs all the tests in this platform too before
landing any code. Thanks!
Get some help, give some feedback
=================================
You can ask any question or send any recommendation or request to
the `mailing list <http://listas.python.org.ar/mailman/listinfo/fades>`_.
Come chat with us on IRC. The #fades channel is located at the `Freenode <http://freenode.net/>`_ network.
Also, you can open an issue
`here <https://github.com/PyAr/fades/issues/new>`_ (please do if you
find any problem!).
Thanks in advance for your time.
How to develop fades itself
===========================
Quick guide to get you up and running in fades development.
Getting the code
----------------
Clone the project::
git clone git@github.com:PyAr/fades.git
Install dependencies
--------------------
*fades* manages it's own dependencies, so there is nothing extra you need to install.
To try it, just do::
bin/fades -V
How to run the tests
--------------------
When starting development, at all times, and specially before wrapping up
a new branch, you need to be sure that all tests pass ok.
This is very simple, actually, just run::
./test
That will not only check test cases, but also that the code complies with
aesthetic recommendations, and that the README document has a proper format.
If you want to run *one* particular test, just specify it. Example::
./test tests.test_main:DepsMergingTestCase.test_two_different
Development process
-------------------
Just pick an issue from `the list <https://github.com/PyAr/fades/issues>`_.
Develop, assure ``./test`` is happy, commit, push, create a pull request, etc.
Please, if you aim for creating a Pull Request with new code (functionality
or fixes), include tests for your changes.
Thanks! Enjoy.
================================================
FILE: bin/fades
================================================
#!/usr/bin/env python3
#
# Copyright 2014 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Script to run the 'fades' utility."""
import os
import sys
try:
import packaging
except ImportError:
print("Import failed for `packaging` dependency. Please do `pip3 install packaging` and try again")
exit(-1)
# small hack to allow fades to be run directly from the project, using code
# from project itself, not anything already installed in the system
parent_dir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
if os.path.basename(parent_dir).startswith('fades'):
# inside the project or an opened tarball!!
sys.path.insert(0, parent_dir)
from fades import main, FadesError # noqa (imports after fixing the path, not at the top)
try:
rc = main.go()
except FadesError:
sys.exit(-1)
sys.exit(rc)
================================================
FILE: bin/fades.cmd
================================================
::
:: Copyright 2018 Facundo Batista, Nicolás Demarchi
::
:: This program is free software: you can redistribute it and/or modify it
:: under the terms of the GNU General Public License version 3, as published
:: by the Free Software Foundation.
::
:: This program is distributed in the hope that it will be useful, but
:: WITHOUT ANY WARRANTY; without even the implied warranties of
:: MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
:: PURPOSE. See the GNU General Public License for more details.
::
:: You should have received a copy of the GNU General Public License along
:: with this program. If not, see <http://www.gnu.org/licenses/>.
::
:: For further info, check https://github.com/PyAr/fades
:: Script to run the 'fades' utility in Windows
python -m fades %*
================================================
FILE: build_readme
================================================
FADES='./bin/fades -r requirements.txt'
python3 setup.py --long-description | $FADES -x rst2html5 > README.html
================================================
FILE: docs/Makefile
================================================
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " applehelp to make an Apple Help Book"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " coverage to run coverage check of the documentation (if enabled)"
clean:
rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/fades.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/fades.qhc"
applehelp:
$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
@echo
@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
@echo "N.B. You won't be able to view it unless you put it in" \
"~/Library/Documentation/Help or install it in your application" \
"bundle."
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/fades"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/fades"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
coverage:
$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
@echo "Testing of coverage in the sources finished, look at the " \
"results in $(BUILDDIR)/coverage/python.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
================================================
FILE: docs/conf.py
================================================
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'fades'
copyright = '2024, Facundo Batista, Nicolás Demarchi'
author = 'Facundo Batista, Nicolás Demarchi'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx_rtd_theme',
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
================================================
FILE: docs/index.rst
================================================
.. fades documentation master file, created by
sphinx-quickstart on Sat Dec 26 19:29:13 2015.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to fades's documentation!
=================================
Contents:
---------
.. toctree::
:maxdepth: 2
readme
development
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
================================================
FILE: docs/pydepmanag.rst
================================================
Python and the Management of Dependencies
=========================================
Python has an extensive standard library ("batteries included!"), but is
frequent the necessity of using other modules not included there, mostly
from the Python Package Index (`PyPI <https://pypi.python.org/pypi>`_).
The original way of installing those modules is at "system level"
(`sudo pip install foobar`), in the operating system in a general way,
making them available to be used by any program that is executed.
Beyond needing root or administrator level to install the dependencies in
that way, the first problem we find are conflicts: the typical case of two
programs needing two different versions of the same dependency, which can
not be achieved when installing the dependencies globally.
This is why is so normal in Python to use "virtual environments" (or
"virtualenvs"). A new virtualenv is created for each program, the needed
dependencies for each program are installed in the corresponding virtualenv,
and as stuff in a virtualenv is only accessible from inside the virtualenv,
there are no conflicts anymore.
At this point, however, we hit the problem of the administration of the
virtualenvs themselves: create them, install modules in them, activate them
to be uses by each program and deactivate them later, remember the names of
each environment for each program, etc.
To automatize this, `fades <https://fades.readthedocs.org/>`_ was born.
*fades* allows you to unleash all the power of virtualenvs without needing
to worry about them.
Do you want to execute a script that needs the ``foobar`` dependency?
``fades -d foobar script.py``
Do you want an interactive interpreter having ``foobar`` installed as
dependency? ``fades -d foobar``
Do you need to execute the script but with several dependencies, one with
a specific version? ``fades -d foo -d bar -d baz==1.1 script.py``
Do you have all the dependencies in a requirements file?
``fades -r requirements.txt script.py``
These are only simple examples of what you can do with *fades*. Virtual
environments are a very powerful tool, and automate and simplify their
use makes *fades* to have a lot of options, some that you will use
everyday, others that will prove useful in some specific situations.
Start to use *fades* step by step (`check the docs
<https://fades.readthedocs.org/en/latest/readme.html>`_) and will find
that it will solve the dependencies management in your programs and
scripts, using virtualenvs but without the complexity of having to deal
with them by hand.
================================================
FILE: docs/readme.rst
================================================
.. include:: ../README.rst
================================================
FILE: docs/requirements.txt
================================================
sphinx_rtd_theme
================================================
FILE: fades/__init__.py
================================================
# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Main package."""
from ._version import __version__, VERSION # NOQA; provides module level version attr
class FadesError(Exception):
"""Provides a Fades exception."""
REPO_PYPI = 'pypi'
REPO_VCS = 'vcs'
================================================
FILE: fades/__main__.py
================================================
"""Init file to allow execution of fades as a module."""
import sys
from fades import main, FadesError
try:
rc = main.go()
except FadesError:
sys.exit(-1)
sys.exit(rc)
================================================
FILE: fades/_version.py
================================================
"""Holder of the fades version number."""
VERSION = (9, 0, 2)
__version__ = '.'.join([str(x) for x in VERSION])
================================================
FILE: fades/cache.py
================================================
# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""The cache manager for virtualenvs."""
import json
import logging
import os
import time
from fades import REPO_VCS
from fades.multiplatform import filelock
from fades.parsing import VCSDependency, NameVerDependency
logger = logging.getLogger(__name__)
class VEnvsCache:
"""A cache for virtualenvs."""
def __init__(self, filepath):
"""Init."""
logger.debug("Using cache index: %r", filepath)
self.filepath = filepath
self.lockpath = filepath + ".lock"
def _venv_match(self, installed, requirements):
"""Return True if what is installed satisfies the requirements.
This method has multiple exit-points, but only for None (because
if *anything* is not satisified, the venv is no good). Only after
all was checked, and it didn't exit, the venv is ok and it so
returns the satisfying dependencies.
"""
if not requirements:
# special case for no requirements, where we can't actually
# check anything: the venv is useful if nothing installed too
return None if installed else []
satisfying_deps = []
for repo, req_deps in requirements.items():
useful_inst = set()
if repo not in installed:
# the venv doesn't even have the repo
return None
if repo == REPO_VCS:
inst_namevers = {(url, None) for url in installed[repo].keys()}
else:
inst_namevers = {(dep, ver) for (dep, ver) in installed[repo].items()}
for req in req_deps:
for inst_name, inst_ver in inst_namevers:
if req.name == inst_name and req.specifier.contains(inst_ver):
useful_inst.add((inst_name, inst_ver))
break
else:
# nothing installed satisfied that requirement
return None
# assure *all* that is installed is useful for the requirements
if useful_inst == inst_namevers:
inst_reqs = set()
for name, ver in inst_namevers:
if ver is None:
inst_reqs.add(VCSDependency(name))
else:
inst_reqs.add(NameVerDependency(name, ver))
satisfying_deps.extend(inst_reqs)
else:
return None
# it did it through!
return satisfying_deps
def _match_by_uuid(self, current_venvs, uuid):
"""Select a venv matching exactly by uuid."""
for venv_str in current_venvs:
venv = json.loads(venv_str)
env_path = venv.get('metadata', {}).get('env_path')
_, env_uuid = os.path.split(env_path)
if env_uuid == uuid:
return venv
def _select_better_fit(self, matching_venvs):
"""Receive a list of matching venvs, and decide which one is the best fit."""
# keep the venvs in a separate array, to pick up the winner, and the (sorted, to compare
# each dependency with its equivalent) in other structure to later compare
venvs = []
to_compare = []
for matching, venv in matching_venvs:
to_compare.append(sorted(matching, key=lambda req: getattr(req, 'key', '')))
venvs.append(venv)
# compare each n-tuple of dependencies to see which one is bigger, and add score to the
# position of the winner
scores = [0] * len(venvs)
for dependencies in zip(*to_compare):
if not isinstance(dependencies[0], NameVerDependency):
# only distribution URLs can be compared
continue
winner = dependencies.index(max(dependencies))
scores[winner] = scores[winner] + 1
# get the rightmost winner (in case of ties, to select the latest venv)
winner_pos = None
winner_score = -1
for i, score in enumerate(scores):
if score >= winner_score:
winner_score = score
winner_pos = i
return venvs[winner_pos]
def _match_by_requirements(self, current_venvs, requirements, interpreter, options):
"""Select a venv matching interpreter and options, complying with requirements.
Several venvs can be found in this case, will return the better fit.
"""
matching_venvs = []
for venv_str in current_venvs:
venv = json.loads(venv_str)
# simple filter, need to have exactly same options and interpreter
if venv.get('options') != options or venv.get('interpreter') != interpreter:
continue
# requirements complying: result can be None (no comply) or a score to later sort
matching = self._venv_match(venv['installed'], requirements)
if matching is not None:
matching_venvs.append((matching, venv))
if not matching_venvs:
return
return self._select_better_fit(matching_venvs)
def _select(self, current_venvs, requirements=None, interpreter='', uuid='', options=None):
"""Select which venv satisfy the received requirements."""
if uuid:
logger.debug("Searching a venv by uuid: %s", uuid)
venv = self._match_by_uuid(current_venvs, uuid)
else:
logger.debug("Searching a venv for: reqs=%s interpreter=%s options=%s",
requirements, interpreter, options)
venv = self._match_by_requirements(current_venvs, requirements, interpreter, options)
if venv is None:
logger.debug("No matching venv found :(")
return
logger.debug("Found a matching venv! %s", venv)
return venv['metadata']
def get_venv(self, requirements=None, interpreter='', uuid='', options=None):
"""Find a venv that serves these requirements, if any."""
lines = self._read_cache()
return self._select(lines, requirements, interpreter, uuid=uuid, options=options)
def get_venvs_metadata(self):
"""Yield metadata of each existing venv."""
for line in self._read_cache():
yield json.loads(line)['metadata']
def store(self, installed_stuff, metadata, interpreter, options):
"""Store the virtualenv metadata for the indicated installed_stuff."""
new_content = {
'timestamp': int(time.mktime(time.localtime())),
'installed': installed_stuff,
'metadata': metadata,
'interpreter': interpreter,
'options': options
}
logger.debug("Storing installed=%s metadata=%s interpreter=%s options=%s",
installed_stuff, metadata, interpreter, options)
with filelock(self.lockpath):
self._write_cache([json.dumps(new_content)], append=True)
def remove(self, env_path):
"""Remove metadata for a given virtualenv from cache."""
with filelock(self.lockpath):
cache = self._read_cache()
logger.debug("Removing virtualenv from cache: %s" % env_path)
lines = [
line for line in cache
if json.loads(line).get('metadata', {}).get('env_path') != env_path
]
self._write_cache(lines)
def _read_cache(self):
"""Read virtualenv metadata from cache."""
if os.path.exists(self.filepath):
with open(self.filepath, 'rt', encoding='utf8') as fh:
lines = [x.strip() for x in fh]
else:
logger.debug("Index not found, starting empty")
lines = []
return lines
def _write_cache(self, lines, append=False):
"""Write virtualenv metadata to cache."""
mode = 'at' if append else 'wt'
with open(self.filepath, mode, encoding='utf8') as fh:
fh.writelines(line + '\n' for line in lines)
================================================
FILE: fades/envbuilder.py
================================================
# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Tools to create, destroy and handle usage of virtual environments."""
import logging
import os
import pathlib
import shutil
from datetime import datetime, timezone
from venv import EnvBuilder
from uuid import uuid4
from fades import FadesError, REPO_PYPI, REPO_VCS
from fades import helpers
from fades.pipmanager import PipManager
from fades.multiplatform import filelock
logger = logging.getLogger(__name__)
# UTC can be imported directly from datetime from Python 3.11
UTC = timezone.utc
class _FadesEnvBuilder(EnvBuilder):
"""Create always a virtual environment.
This is structured as a class mostly to take advantage of EnvBuilder, not because
it's provides the best interface: external callers should just use module's ``create_env``
and ``destroy_env``.
"""
def __init__(self):
basedir = helpers.get_basedir()
self.env_path = os.path.join(basedir, str(uuid4()))
self.env_bin_path = ''
logger.debug("Env will be created at: %s", self.env_path)
if os.environ.get("SNAP"):
# running inside a snap: we need to avoid EnvBuilder ending up running ensurepip
# because it doesn't work properly (it does a special magic to run the script
# and ends up mixing external and internal pips)
self.pip_installed = False
else:
# try to install pip using default machinery (which will work in a lot
# of systems, noticeably it won't in some debians or ubuntus, like
# Trusty; in that cases mark it to install manually later)
try:
import ensurepip # NOQA
self.pip_installed = True
except ImportError:
self.pip_installed = False
super().__init__(with_pip=self.pip_installed, symlinks=True)
def create_with_external_venv(self, interpreter, options):
"""Create a virtual environment using the venv module externally."""
args = [interpreter, "-m", "venv", self.env_path]
args.extend(options)
if not self.pip_installed:
args.insert(3, '--without-pip')
try:
helpers.logged_exec(args)
except helpers.ExecutionError as error:
error.dump_to_log(logger)
raise FadesError("Failed to run venv module externally")
except Exception as error:
logger.exception("Error creating virtual environment: %s", error)
raise FadesError("General error while running external venv")
# XXX Facundo 2024-06-29: the helper uses pathlib; eventually everything will be
# pathlib (see #435), so these translations will be cleaned up
self.env_bin_path = str(helpers.get_env_bin_path(pathlib.Path(self.env_path)))
def create_env(self, interpreter, is_current, options):
"""Create the virtual environment and return its info."""
venv_options = options['venv_options']
if is_current:
# apply venv options
logger.debug("Creating virtual environment internally; options=%s", venv_options)
for option in venv_options:
attrname = option[2:].replace("-", "_") # '--system-packgs' -> 'system_packgs'
setattr(self, attrname, True)
self.create(self.env_path)
else:
logger.debug(
"Creating virtual environment with external venv; options=%s", venv_options)
self.create_with_external_venv(interpreter, venv_options)
logger.debug("env_bin_path: %s", self.env_bin_path)
# Re check if pip was installed (supporting both binary and .exe for Windows)
pip_bin = os.path.join(self.env_bin_path, "pip")
pip_exe = os.path.join(self.env_bin_path, "pip.exe")
if not (os.path.exists(pip_bin) or os.path.exists(pip_exe)):
logger.debug("pip isn't installed in the venv, setting pip_installed=False")
self.pip_installed = False
return self.env_path, self.env_bin_path, self.pip_installed
def post_setup(self, context):
"""Get the bin path from context."""
self.env_bin_path = context.bin_path
def create_venv(requested_deps, interpreter, is_current, options, pip_options, avoid_pip_upgrade):
"""Create a new virtualvenv with the requirements of this script."""
# create virtual environment
env = _FadesEnvBuilder()
env_path, env_bin_path, pip_installed = env.create_env(interpreter, is_current, options)
venv_data = {}
venv_data['env_path'] = env_path
venv_data['env_bin_path'] = env_bin_path
venv_data['pip_installed'] = pip_installed
# install deps
installed = {}
for repo in requested_deps.keys():
if repo in (REPO_PYPI, REPO_VCS):
mgr = PipManager(
env_bin_path, pip_installed=pip_installed, options=pip_options,
avoid_pip_upgrade=avoid_pip_upgrade)
else:
logger.warning("Install from %r not implemented", repo)
continue
installed[repo] = {}
repo_requested = requested_deps[repo]
logger.debug("Installing dependencies for repo %r: requested=%s", repo, repo_requested)
for dependency in repo_requested:
try:
mgr.install(dependency)
except Exception:
logger.debug("Installation Step failed, removing virtual environment")
destroy_venv(env_path)
raise FadesError('Dependency installation failed')
if repo == REPO_VCS:
# no need to request the installed version, as we'll always compare
# to the url itself
project = dependency.url
version = None
else:
# always store the installed dependency, as in the future we'll select the venv
# based on what is installed, not what used requested (remember that user may
# request >, >=, etc!)
project = dependency.name
version = mgr.get_version(project)
installed[repo][project] = version
logger.debug("Installed dependencies: %s", installed)
return venv_data, installed
def destroy_venv(env_path, venvscache=None):
"""Destroy a venv."""
# remove the venv itself in disk
logger.debug("Destroying virtual environment at: %s", env_path)
shutil.rmtree(env_path, ignore_errors=True)
# remove venv from cache
if venvscache is not None:
venvscache.remove(env_path)
class UsageManager:
"""Class to handle usage file and venv cleanning."""
def __init__(self, stat_file_path, venvscache):
"""Init."""
self.stat_file_path = stat_file_path
self.stat_file_lock = stat_file_path + '.lock'
self.venvscache = venvscache
self._create_initial_usage_file_if_not_exists()
def store_usage_stat(self, venv_data, cache):
"""Log an usage record for venv_data."""
with open(self.stat_file_path, 'at') as f:
self._write_venv_usage(f, venv_data)
def _create_initial_usage_file_if_not_exists(self):
if not os.path.exists(self.stat_file_path):
existing_venvs = self.venvscache.get_venvs_metadata()
with open(self.stat_file_path, 'wt') as f:
for venv_data in existing_venvs:
self._write_venv_usage(f, venv_data)
def _write_venv_usage(self, file_, venv_data):
_, uuid = os.path.split(venv_data['env_path'])
file_.write('{} {}\n'.format(uuid, self._datetime_to_str(datetime.now(UTC))))
def _datetime_to_str(self, datetime_):
return datetime.strftime(datetime_, "%Y-%m-%dT%H:%M:%S.%f")
def _str_to_datetime(self, str_):
return datetime.strptime(str_, "%Y-%m-%dT%H:%M:%S.%f")
def clean_unused_venvs(self, max_days_to_keep):
"""Compact usage stats and remove venvs.
This method loads the complete file usage in memory, for every venv compact all records in
one (the lastest), updates this info for every env deleted and, finally, write the entire
file to disk.
If something failed during this steps, usage file remains unchanged and can contain some
data about some deleted env. This is not a problem, the next time this function it's
called, this records will be deleted.
"""
with filelock(self.stat_file_lock):
now = datetime.now(UTC)
venvs_dict = self._get_compacted_dict_usage_from_file()
for venv_uuid, usage_date in venvs_dict.copy().items():
usage_date = self._str_to_datetime(usage_date)
if (now - usage_date).days > max_days_to_keep:
# remove venv from usage dict
del venvs_dict[venv_uuid]
venv_meta = self.venvscache.get_venv(uuid=venv_uuid)
if venv_meta is None:
# if meta isn't found means that something had failed previously and
# usage_file wasn't updated.
continue
env_path = venv_meta['env_path']
logger.info("Destroying virtual environment at: %s", env_path)
destroy_venv(env_path, self.venvscache)
self._write_compacted_dict_usage_to_file(venvs_dict)
def _get_compacted_dict_usage_from_file(self):
all_lines = open(self.stat_file_path).readlines()
return dict(x.split() for x in all_lines)
def _write_compacted_dict_usage_to_file(self, dict_usage):
with open(self.stat_file_path, 'wt') as file_:
for uuid, date in dict_usage.items():
file_.write('{} {}\n'.format(uuid, date))
================================================
FILE: fades/file_options.py
================================================
# Copyright 2016-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Parse fades options from config files."""
import logging
import os
from configparser import ConfigParser, NoSectionError
from fades.helpers import get_confdir
logger = logging.getLogger(__name__)
CONFIG_FILES = ("/etc/fades/fades.ini", os.path.join(get_confdir(), 'fades.ini'), ".fades.ini")
MERGEABLE_CONFIGS = ("dependency", "pip_options", "venv-options")
def options_from_file(args):
"""Get a argparse.Namespace and return it updated with options from config files.
Config files will be parsed with priority equal to his order in CONFIG_FILES.
"""
logger.debug("updating options from config files")
updated_from_file = []
for config_file in CONFIG_FILES:
logger.debug("updating from: %s", config_file)
parser = ConfigParser()
parser.read(config_file)
try:
items = parser.items('fades')
except NoSectionError:
continue
for config_key, config_value in items:
if config_value in ['true', 'false']:
config_value = config_value == 'true'
if config_key in MERGEABLE_CONFIGS:
current_value = getattr(args, config_key, [])
if current_value is None:
current_value = []
current_value.append(config_value)
setattr(args, config_key, current_value)
if not getattr(args, config_key, False) or config_key in updated_from_file:
# By default all 'store-true' arguments are False. So we only
# override them if they are False. If they are True means that the
# user is setting those on the CLI.
setattr(args, config_key, config_value)
updated_from_file.append(config_key)
logger.debug("updating %s to %s from file settings", config_key, config_value)
return args
================================================
FILE: fades/helpers.py
================================================
# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""A collection of utilities for fades."""
import os
import sys
import json
import logging
import subprocess
import tempfile
from http.server import HTTPStatus
from urllib import request, parse
from urllib.error import HTTPError
from packaging.requirements import Requirement
from packaging.version import Version
from fades import FadesError, _version
logger = logging.getLogger(__name__)
# command to retrieve the version from an external Python
SHOW_VERSION_CMD = """
import sys, json
d = dict(path=sys.executable)
d.update(zip('major minor micro releaselevel serial'.split(), sys.version_info))
print(json.dumps(d))
"""
# the url to query PyPI for project versions
BASE_PYPI_URL = 'https://pypi.org/pypi/{name}/json'
BASE_PYPI_URL_WITH_VERSION = 'https://pypi.org/pypi/{name}/{version}/json'
# prefix for all stdout lines when running a command
STDOUT_LOG_PREFIX = ":: "
# env var name provided by snappy where process can read/write; this path already includes
# 'fades' in it, it's a different dir for each user, and accessable by different versions of fades
SNAP_BASEDIR_NAME = 'SNAP_USER_COMMON'
class ExecutionError(Exception):
"""Execution of subprocess ended not in 0."""
def __init__(self, retcode, cmd, collected_stdout):
"""Init."""
self._retcode = retcode
self._cmd = cmd
self._collected_stdout = collected_stdout
super().__init__()
def dump_to_log(self, logger):
"""Send the cmd info and collected stdout to logger."""
logger.error("Execution ended in %s for cmd %s", self._retcode, self._cmd)
for line in self._collected_stdout:
logger.error(STDOUT_LOG_PREFIX + line)
def logged_exec(cmd):
"""Execute a command, redirecting the output to the log."""
logger = logging.getLogger('fades.exec')
logger.debug("Executing external command: %r", cmd)
p = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
stdout = []
for line in p.stdout:
line = line[:-1]
stdout.append(line)
logger.debug(STDOUT_LOG_PREFIX + line)
retcode = p.wait()
if retcode:
raise ExecutionError(retcode, cmd, stdout)
return stdout
def _get_basedirectory():
from xdg import BaseDirectory
return BaseDirectory
def _get_specific_dir(dir_type):
"""Get a specific directory, using some XDG base, with sensible default."""
if SNAP_BASEDIR_NAME in os.environ:
logger.debug("Getting base dir information from SNAP_BASEDIR_NAME env var.")
direct = os.path.join(os.environ[SNAP_BASEDIR_NAME], dir_type)
else:
try:
basedirectory = _get_basedirectory()
except ImportError:
logger.debug("Using last resort base dir: ~/.fades")
from os.path import expanduser
direct = os.path.join(expanduser("~"), ".fades")
else:
xdg_attrib = 'xdg_{}_home'.format(dir_type)
base = getattr(basedirectory, xdg_attrib)
direct = os.path.join(base, 'fades')
if not os.path.exists(direct):
os.makedirs(direct)
return direct
def get_basedir():
"""Get the base fades directory, from xdg or kinda hardcoded."""
return _get_specific_dir('data')
def get_confdir():
"""Get the config fades directory, from xdg or kinda hardcoded."""
return _get_specific_dir('config')
def _get_interpreter_info(interpreter=None):
"""Return the interpreter's full path using pythonX.Y format."""
if interpreter is None:
# If interpreter is None by default returns the current interpreter data.
major, minor = sys.version_info[:2]
executable = sys.executable
else:
args = [interpreter, '-c', SHOW_VERSION_CMD]
try:
requested_interpreter_info = logged_exec(args)
except Exception as error:
logger.error("Error getting requested interpreter version: %s", error)
raise FadesError("Could not get interpreter version")
requested_interpreter_info = json.loads(requested_interpreter_info[0])
executable = requested_interpreter_info['path']
major = requested_interpreter_info['major']
minor = requested_interpreter_info['minor']
if executable[-1].isdigit():
executable = executable.split(".")[0][:-1]
interpreter = "{}{}.{}".format(executable, major, minor)
return interpreter
def get_interpreter_version(requested_interpreter):
"""Return a 'sanitized' interpreter and indicates if it is the current one."""
logger.debug('Getting interpreter version for: %s', requested_interpreter)
current_interpreter = _get_interpreter_info()
logger.debug('Current interpreter is %s', current_interpreter)
if requested_interpreter is None:
return (current_interpreter, True)
requested_interpreter = _get_interpreter_info(requested_interpreter)
is_current = requested_interpreter == current_interpreter
logger.debug('Interpreter=%s. It is the same as fades?=%s',
requested_interpreter, is_current)
return (requested_interpreter, is_current)
def get_latest_version_number(project_name):
"""Return latest version of a package."""
try:
raw = request.urlopen(BASE_PYPI_URL.format(name=project_name)).read()
except HTTPError as error:
logger.warning("Network error. Error: %s", error)
raise error
try:
data = json.loads(raw.decode("utf8"))
latest_version = data["info"]["version"]
return latest_version
except (KeyError, ValueError) as error: # malformed json or empty string
logger.error("Could not get the version of the package. Error: %s", error)
raise error
def check_pypi_updates(dependencies):
"""Return a list of dependencies to upgrade."""
dependencies_up_to_date = []
for dependency in dependencies.get('pypi', []):
# get latest version from PyPI api
try:
latest_version = Version(get_latest_version_number(dependency.name))
except Exception as error:
logger.warning("--check-updates command will be aborted. Error: %s", error)
return dependencies
# get required version
if dependency.specifier:
spec = list(dependency.specifier)[0]
required_version = Version(spec.version)
dependencies_up_to_date.append(dependency)
if latest_version > required_version:
logger.info("There is a new version of %s: %s",
dependency.name, latest_version)
elif latest_version < required_version:
logger.warning("The requested version for %s is greater "
"than latest found in PyPI: %s",
dependency.name, latest_version)
else:
logger.info("The requested version for %s is the latest one in PyPI: %s",
dependency.name, latest_version)
else:
name_plus = "{}=={}".format(dependency.name, latest_version)
dependencies_up_to_date.append(Requirement(name_plus))
logger.info("The latest version of %r is %s and will use it.",
dependency.name, latest_version)
dependencies["pypi"] = dependencies_up_to_date
return dependencies
def _pypi_head_package(dependency):
"""Hit pypi with a http HEAD to check if pkg_name exists."""
if dependency.specifier:
spec = list(dependency.specifier)[0]
version = spec.version
url = BASE_PYPI_URL_WITH_VERSION.format(name=dependency.name, version=version)
else:
url = BASE_PYPI_URL.format(name=dependency.name)
logger.debug("Doing HEAD requests against %s", url)
req = request.Request(url, method='HEAD')
try:
response = request.urlopen(req)
except HTTPError as http_error:
if http_error.code == HTTPStatus.NOT_FOUND:
return False
else:
raise
if response.status == HTTPStatus.OK:
logger.debug("%r exists in PyPI.", dependency)
else:
# Maybe we are getting somethink like a redirect. In this case we are only
# warning to the user and trying to install the dependency.
# In the worst scenery fades will fail to install it.
logger.warning("Got a (unexpected) HTTP_STATUS=%r and reason=%r checking if %r exists",
response.status, response.reason, dependency)
return True
def check_pypi_exists(dependencies):
"""Check if the indicated dependencies actually exists in pypi."""
for dependency in dependencies.get('pypi', []):
logger.debug("Checking if %r exists in PyPI", dependency)
try:
exists = _pypi_head_package(dependency)
except Exception as error:
logger.error("Error checking %s in PyPI: %r", dependency, error)
raise FadesError("Could not check if dependency exists in PyPI")
else:
if not exists:
logger.error("%s doesn't exists in PyPI.", dependency)
return False
return True
class _ScriptDownloader:
"""Grouping of different backends downloaders."""
# a user-agent for hitting the network
USER_AGENT = "fades/{} (https://github.com/PyAr/fades/)".format(_version.__version__)
HEADERS_PLAIN = {
'Accept': 'text/plain',
'User-Agent': USER_AGENT,
}
HEADERS_JSON = {
'Accept': 'application/json',
'User-Agent': USER_AGENT,
}
# simple network locations to name map
NETLOCS = {
'linkode.org': 'linkode',
'pastebin.com': 'pastebin',
'gist.github.com': 'gist',
}
def __init__(self, url):
"""Init."""
self.url = url
self.name = self._decide()
def _decide(self):
"""Find out which method should be applied to download that URL."""
netloc = parse.urlparse(self.url).netloc
name = self.NETLOCS.get(netloc, 'raw')
return name
def get(self):
"""Get the script content from the URL using the decided downloader."""
method_name = "_download_" + self.name
method = getattr(self, method_name)
return method()
def _download_raw(self, url=None):
"""Download content from URL directly."""
if url is None:
url = self.url
req = request.Request(url, headers=self.HEADERS_PLAIN)
resp = request.urlopen(req)
# check if the response url is different than the original one; in this case we had
# redirected, and we need to pass the new url response through the proper
# pastebin-dependant adapter, so recursively go into another _ScriptDownloader
if resp.geturl() != url:
new_url = resp.geturl()
downloader = _ScriptDownloader(new_url)
logger.info(
"Download redirect detect, now downloading from %r using %r downloader",
new_url, downloader.name)
return downloader.get()
# simple non-redirect response
return resp.read().decode("utf8")
def _download_linkode(self):
"""Download content from Linkode pastebin."""
# build the API url
linkode_id = self.url.split("/")[-1]
if linkode_id.startswith("#"):
linkode_id = linkode_id[1:]
url = "https://linkode.org/api/1/linkodes/" + linkode_id
req = request.Request(url, headers=self.HEADERS_JSON)
resp = request.urlopen(req)
raw = resp.read()
data = json.loads(raw.decode("utf8"))
content = data['content']
return content
def _download_pastebin(self):
"""Download content from Pastebin itself."""
paste_id = self.url.split("/")[-1]
url = "https://pastebin.com/raw/" + paste_id
return self._download_raw(url)
def _download_gist(self):
"""Download content from github's pastebin."""
parts = parse.urlparse(self.url)
url = "https://gist.github.com" + parts.path + "/raw"
return self._download_raw(url)
def download_remote_script(url):
"""Download the content of a remote script to a local temp file."""
temp_fh = tempfile.NamedTemporaryFile('wt', encoding='utf8', suffix=".py", delete=False)
downloader = _ScriptDownloader(url)
logger.info(
"Downloading remote script from %r (using %r downloader) to %r",
url, downloader.name, temp_fh.name)
content = downloader.get()
temp_fh.write(content)
temp_fh.close()
return temp_fh.name
def get_env_bin_path(base_env_path):
"""Find and return the environment's binary path in a multiplatformy way."""
for subdir in ("bin", "Scripts"):
binpath = base_env_path / subdir
if binpath.exists():
return binpath
raise ValueError(f"Binary subdir not found in {base_env_path!r}")
================================================
FILE: fades/logger.py
================================================
# Copyright 2014-2018 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Logging set up."""
import logging
import logging.handlers
import os.path
from fades._version import __version__
FMT_SIMPLE = "*** fades *** %(asctime)s %(levelname)-8s %(message)s"
FMT_DETAILED = "*** fades *** %(asctime)s %(name)-18s %(levelname)-8s %(message)s"
FMT_SYSLOG = "[%(process)d] %(name)-18s %(levelname)-8s %(message)s"
SALUTATION = "Hi! This is fades {}, automatically managing your dependencies".format(__version__)
class SalutingStreamHandler(logging.StreamHandler):
"""A handler that salutes once before polluting user screen.
Note that the salutation is done in INFO level, to respect "verbose" modifiers.
"""
def __init__(self, logger):
"""Init."""
super().__init__()
self._already_saluted = False
self._logger = logger
def emit(self, record):
"""Call father's emit, but salute first (just once)."""
if not self._already_saluted:
self._already_saluted = True
self._logger.info(SALUTATION)
super().emit(record)
def set_up(verbose, quiet):
"""Set up the logging."""
logger = logging.getLogger('fades')
logger.setLevel(logging.DEBUG)
# select logging level according to user desire; also use a simpler
# formatting for non-verbose logging
if verbose:
log_level = logging.DEBUG
log_format = FMT_DETAILED
elif quiet:
log_level = logging.WARNING
log_format = FMT_SIMPLE
else:
log_level = logging.INFO
log_format = FMT_SIMPLE
# all to the stdout
handler = SalutingStreamHandler(logger)
handler.setLevel(log_level)
logger.addHandler(handler)
formatter = logging.Formatter(log_format)
handler.setFormatter(formatter)
# and to the syslog
for syslog_path in ('/dev/log', '/var/run/syslog'):
if not os.path.exists(syslog_path):
continue
try:
handler = logging.handlers.SysLogHandler(address=syslog_path)
except Exception:
# silently ignore that the user doesn't have a syslog active; can
# see all the info with "-v" anyway
pass
else:
logger.addHandler(handler)
formatter = logging.Formatter(FMT_SYSLOG)
handler.setFormatter(formatter)
break
return logger
================================================
FILE: fades/main.py
================================================
# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Main 'fades' modules."""
import argparse
import logging
import os
import platform
import signal
import sys
import subprocess
import tempfile
import fades
from fades import (
FadesError,
cache,
envbuilder,
file_options,
helpers,
parsing,
pipmanager,
pkgnamesdb,
)
from fades.logger import set_up as logger_set_up
# Get the logger here; it will be properly setup at bootstrap, but can be used from
# the rest of the module just fine
logger = logging.getLogger('fades')
# the signals to redirect to the child process (note: only these are
# allowed in Windows, see 'signal' doc).
REDIRECTED_SIGNALS = [
signal.SIGABRT,
signal.SIGFPE,
signal.SIGILL,
signal.SIGINT,
signal.SIGSEGV,
signal.SIGTERM,
]
HELP_EPILOG = """
The "child program" is the script that fades will execute. It's an
optional parameter, it will be the first thing received by fades that
is not a parameter. If no child program is indicated, a Python
interactive interpreter will be opened.
The "child options" (everything after the child program) are
parameters passed as is to the child program.
"""
AUTOIMPORT_HEADER = """
import sys
print("Python {} on {}".format(sys.version, sys.platform))
print('Type "help", "copyright", "credits" or "license" for more information.')
"""
AUTOIMPORT_MOD_IMPORTER = """
try:
import {module}
except ImportError:
print("::fades:: FAILED to autoimport {module!r}")
else:
print("::fades:: automatically imported {module!r}")
"""
AUTOIMPORT_MOD_SKIPPING = (
"""print("::fades:: autoimport skipped because not a PyPI package: {dependency!r}")\n""")
def get_autoimport_scriptname(dependencies, is_ipython):
"""Return the path of script that will import dependencies for interactive mode.
The script has:
- a safe import of the dependencies, taking in consideration that the module may be named
differently than the package, and printing a message accordingly
- if regular Python, also print the normal interactive interpreter first information lines,
that are not shown when starting it with `-i` (but IPython shows them anyway).
"""
fd, tempfilepath = tempfile.mkstemp(prefix='fadesinit-', suffix='.py')
fh = os.fdopen(fd, 'wt', encoding='utf8')
if not is_ipython:
fh.write(AUTOIMPORT_HEADER)
for repo, dependencies in dependencies.items():
for dependency in dependencies:
if repo == fades.REPO_PYPI:
package = dependency.name
if is_ipython and package == 'ipython':
# Ignore this artificially added dependency.
continue
module = pkgnamesdb.PACKAGE_TO_MODULE.get(package, package)
fh.write(AUTOIMPORT_MOD_IMPORTER.format(module=module))
else:
fh.write(AUTOIMPORT_MOD_SKIPPING.format(dependency=dependency))
fh.close()
return tempfilepath
def consolidate_dependencies(needs_ipython, child_program,
requirement_files, manual_dependencies):
"""Parse files, get deps and merge them. Deps read later overwrite those read earlier."""
if needs_ipython:
logger.debug("Adding ipython dependency because --ipython was detected")
ipython_dep = parsing.parse_manual(['ipython'])
else:
ipython_dep = {}
if child_program:
srcfile_deps = parsing.parse_srcfile(child_program)
logger.debug("Dependencies from source file: %s", srcfile_deps)
docstring_deps = parsing.parse_docstring(child_program)
logger.debug("Dependencies from docstrings: %s", docstring_deps)
else:
srcfile_deps = {}
docstring_deps = {}
all_dependencies = [ipython_dep, srcfile_deps, docstring_deps]
if requirement_files is not None:
for rf_path in requirement_files:
rf_deps = parsing.parse_reqfile(rf_path)
logger.debug('Dependencies from requirements file %r: %s', rf_path, rf_deps)
all_dependencies.append(rf_deps)
manual_deps = parsing.parse_manual(manual_dependencies)
logger.debug("Dependencies from parameters: %s", manual_deps)
all_dependencies.append(manual_deps)
# Merge dependencies
indicated_deps = {}
for dep in all_dependencies:
for repo, info in dep.items():
indicated_deps.setdefault(repo, set()).update(info)
return indicated_deps
def decide_child_program(args_executable, args_module, args_child_program):
"""Decide which the child program really is (if any)."""
if args_executable:
# If --exec given, check that it's just the executable name or an absolute path;
# relative paths are forbidden (as the location of the venv should not be known).
if os.path.sep in args_child_program and args_child_program[0] != os.path.sep:
logger.error(
"The parameter to --exec must be a file name (to be found "
"inside venv's bin directory), not a file path: %r",
args_child_program)
raise FadesError("File path given to --exec parameter")
# indicated --execute, local and not analyzable for dependencies
analyzable_child_program = None
child_program = args_child_program
elif args_module:
# If --module given, the module may be installed (nothing can be really checked),
# but surely it's not used as a source for dependencies.
analyzable_child_program = None
child_program = args_child_program
elif args_child_program is not None:
# normal case, the child program is to be analyzed (being it local or remote)
if args_child_program.startswith(("http://", "https://")):
args_child_program = helpers.download_remote_script(args_child_program)
else:
if not os.access(args_child_program, os.R_OK):
logger.error("'%s' not found. If you want to run an executable "
"file from a library installed in the virtualenv "
"check the `--exec` option in the help.",
args_child_program)
raise FadesError("child program not found.")
analyzable_child_program = args_child_program
child_program = args_child_program
else:
# not indicated executable, not child program, "interpreter" mode
analyzable_child_program = None
child_program = None
return analyzable_child_program, child_program
def detect_inside_virtualenv(prefix, real_prefix, base_prefix):
"""Tell if fades is running inside a virtualenv.
The params 'real_prefix' and 'base_prefix' may be None.
This is copied from pip code (slightly modified), see
https://github.com/pypa/pip/blob/281eb61b09d87765d7c2b92f6982b3fe76ccb0af/
pip/locations.py#L39
"""
if os.environ.get("SNAP"):
# snaps under core20 are really virtualenvs but we have full control of the
# system layout, "this is fine" (<insert meme>), skip this control
return False
if real_prefix is not None:
return True
if base_prefix is None:
return False
# if prefix is different than base_prefix, it's a venv
return prefix != base_prefix
def go():
"""Make the magic happen."""
parser = argparse.ArgumentParser(
prog='fades', epilog=HELP_EPILOG, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'-V', '--version', action='store_true',
help="show version and info about the system, and exit")
parser.add_argument(
'-d', '--dependency', action='append',
help="specify dependencies through command line (this option can be used multiple times)")
parser.add_argument(
'-r', '--requirement', action='append',
help="indicate files to read dependencies from (this option can be used multiple times)")
parser.add_argument(
'-p', '--python', action='store',
help="specify the Python interpreter to use; the default is: {}".format(sys.executable))
parser.add_argument(
'-i', '--ipython', action='store_true', help="use IPython shell when in interactive mode")
parser.add_argument(
'--system-site-packages', action='store_true', default=False,
help="give the virtual environment access to the system site-packages dir.")
parser.add_argument(
'--venv-options', action='append', default=[],
help="extra options to be supplied to the venv module "
"(this option can be used multiple times)")
parser.add_argument(
'-U', '--check-updates', action='store_true', help="check for packages updates")
parser.add_argument(
'--no-precheck-availability', action='store_true',
help="don't check if the packages exists in PyPI before actually try to install them")
parser.add_argument(
'--pip-options', action='append', default=[],
help="extra options to be supplied to pip (this option can be used multiple times)")
parser.add_argument(
'--python-options', action='append', default=[],
help="extra options to be supplied to python (this option can be used multiple times)")
parser.add_argument(
'--rm', dest='remove', metavar='UUID',
help="remove a virtualenv by UUID; see --where option to easily find out the UUID")
parser.add_argument(
'--clean-unused-venvs', action='store',
help="remove venvs that haven't been used for more than the indicated days and compact "
"usage stats file (all this takes place at the beginning of the execution)")
parser.add_argument(
'--where', '--get-venv-dir', action='store_true',
help="show the virtualenv base directory (including the venv's UUID) and quit")
parser.add_argument(
'-a', '--autoimport', action='store_true',
help="automatically import the specified dependencies in the interactive mode "
"(ignored otherwise).")
parser.add_argument(
'--freeze', action='store', metavar='FILEPATH',
help="dump all the dependencies and its versions to the specified filepath "
"(operating normally beyond that)")
parser.add_argument(
'--avoid-pip-upgrade', action='store_true',
help="disable the automatic pip upgrade that happens after the virtualenv is created "
"and before the dependencies begin to be installed.")
mutexg = parser.add_mutually_exclusive_group()
mutexg.add_argument(
'-v', '--verbose', action='store_true',
help="send all internal debugging lines to stderr, which may be very "
"useful to debug any problem that may arise")
mutexg.add_argument(
'-q', '--quiet', action='store_true',
help="don't show anything (unless it has a real problem), so the "
"original script stderr is not polluted at all")
mutexg = parser.add_mutually_exclusive_group()
mutexg.add_argument(
'-x', '--exec', dest='executable', action='store_true',
help="execute the child_program (must be present) in the context of the virtualenv")
mutexg.add_argument(
'-m', '--module', action='store_true',
help="run library module as a script (same behaviour than Python's -m parameter)")
parser.add_argument('child_program', nargs='?', default=None)
parser.add_argument('child_options', nargs=argparse.REMAINDER)
cli_args = parser.parse_args()
# update args from config file (if needed).
args = file_options.options_from_file(cli_args)
# validate input, parameters, and support some special options
if args.version:
print("Running 'fades' version", fades.__version__)
print(" Python:", sys.version_info)
print(" System:", platform.platform())
return 0
# The --exec and --module flags needs child_program to exist (this is not handled at
# argparse level because it's easier to collect the executable as the
# normal child_program, so everything after that are parameteres
# considered for the executable itself, not for fades).
if args.executable and not args.child_program:
parser.print_usage()
print("fades: error: argument -x/--exec needs child_program to be present")
return -1
if args.module and not args.child_program:
parser.print_usage()
print("fades: error: argument -m/--module needs child_program (module) to be present")
return -1
# set up the logger and dump basic version info
logger_set_up(args.verbose, args.quiet)
logger.debug("Running Python %s on %r", sys.version_info, platform.platform())
logger.debug("Starting fades v. %s", fades.__version__)
logger.debug("Arguments: %s", args)
# verify that the module is NOT being used from a virtualenv
_real_prefix = getattr(sys, 'real_prefix', None)
_base_prefix = getattr(sys, 'base_prefix', None)
if detect_inside_virtualenv(sys.prefix, _real_prefix, _base_prefix):
logger.error(
"fades is running from inside a virtualenv (%r), which is not supported", sys.prefix)
raise FadesError("Cannot run from a virtualenv")
if args.verbose and args.quiet:
logger.warning("Overriding 'quiet' option ('verbose' also requested)")
# start the virtualenvs manager
venvscache = cache.VEnvsCache(os.path.join(helpers.get_basedir(), 'venvs.idx'))
# start usage manager
usage_manager = envbuilder.UsageManager(
os.path.join(helpers.get_basedir(), 'usage_stats'), venvscache)
if args.clean_unused_venvs:
try:
max_days_to_keep = int(args.clean_unused_venvs)
except ValueError:
logger.error("clean_unused_venvs must be an integer.")
raise FadesError('clean_unused_venvs not an integer')
usage_manager.clean_unused_venvs(max_days_to_keep)
return 0
uuid = args.remove
if uuid:
venv_data = venvscache.get_venv(uuid=uuid)
if venv_data:
# remove this venv from the cache
env_path = venv_data.get('env_path')
if env_path:
envbuilder.destroy_venv(env_path, venvscache)
else:
logger.warning(
"Invalid 'env_path' found in virtualenv metadata: %r. "
"Not removing virtualenv.", env_path)
else:
logger.warning('No virtualenv found with uuid: %s.', uuid)
return 0
# decided which the child program really is
analyzable_child_program, child_program = decide_child_program(
args.executable, args.module, args.child_program)
# Group and merge dependencies
indicated_deps = consolidate_dependencies(
args.ipython, analyzable_child_program, args.requirement, args.dependency)
# Check for packages updates
if args.check_updates:
helpers.check_pypi_updates(indicated_deps)
# get the interpreter version requested for the child_program
interpreter, is_current = helpers.get_interpreter_version(args.python)
# options
pip_options = args.pip_options # pip_options mustn't store.
python_options = args.python_options
options = {}
options['venv_options'] = args.venv_options
if args.system_site_packages:
options['venv_options'].append("--system-site-packages")
create_venv = False
venv_data = venvscache.get_venv(indicated_deps, interpreter, uuid, options)
if venv_data:
env_path = venv_data['env_path']
# A venv was found in the cache check if its valid or re-generate it.
if not os.path.exists(env_path):
logger.warning("Missing directory (the virtualenv will be re-created): %r", env_path)
venvscache.remove(env_path)
create_venv = True
else:
create_venv = True
if create_venv:
# Check if the requested packages exists in pypi.
if not args.no_precheck_availability and indicated_deps.get('pypi'):
logger.info(
"Checking the availabilty of dependencies in PyPI. "
"You can use '--no-precheck-availability' to avoid it.")
if not helpers.check_pypi_exists(indicated_deps):
logger.error("An indicated dependency doesn't exist. Exiting")
raise FadesError("Required dependency does not exist")
# Create a new venv
venv_data, installed = envbuilder.create_venv(
indicated_deps, args.python, is_current, options, pip_options, args.avoid_pip_upgrade)
# store this new venv in the cache
venvscache.store(installed, venv_data, interpreter, options)
if args.where:
# all it was requested is the virtualenv's path, show it and quit (don't run anything)
print(venv_data['env_path'])
return 0
if args.freeze:
# beyond all the rest of work, dump the dependencies versions to a file
mgr = pipmanager.PipManager(venv_data['env_bin_path'])
mgr.freeze(args.freeze)
# run forest run!!
python_exe = 'ipython' if args.ipython else 'python'
python_exe = os.path.join(venv_data['env_bin_path'], python_exe)
# add the virtualenv /bin path to the child PATH.
environ_path = venv_data['env_bin_path']
if 'PATH' in os.environ:
environ_path += os.pathsep + os.environ['PATH']
os.environ['PATH'] = environ_path
# store usage information
usage_manager.store_usage_stat(venv_data, venvscache)
if child_program is None:
interactive = True
cmd = [python_exe] + python_options
# get possible extra python options and environement for auto import
if indicated_deps and args.autoimport:
temp_scriptpath = get_autoimport_scriptname(indicated_deps, args.ipython)
cmd += ['-i', temp_scriptpath]
logger.debug("Calling the interactive Python interpreter: %s", cmd)
proc = subprocess.Popen(cmd)
else:
interactive = False
if args.executable:
# Build the exec path relative to 'bin' dir; note that if child_program's path
# is absolute (starting with '/') the resulting exec_path will be just it,
# which is something fades supports
exec_path = os.path.join(venv_data['env_bin_path'], child_program)
cmd = [exec_path]
elif args.module:
cmd = [python_exe, '-m'] + python_options + [child_program]
else:
cmd = [python_exe] + python_options + [child_program]
# Incorporate the child options, always at the end, log and run.
cmd += args.child_options
logger.debug("Calling %s", cmd)
try:
proc = subprocess.Popen(cmd)
except FileNotFoundError:
logger.error("Command not found: %s", child_program)
raise FadesError("Command not found")
def _signal_handler(signum, _):
"""Handle signals received by parent process, send them to child.
The only exception is CTRL-C, that is generated *from* the interactive
interpreter (it's a keyboard combination!), so we swallow it for the
interpreter to not see it twice.
"""
if interactive and signum == signal.SIGINT:
logger.debug("Swallowing signal %s", signum)
else:
logger.debug("Redirecting signal %s to child", signum)
os.kill(proc.pid, signum)
# redirect the useful signals
for s in REDIRECTED_SIGNALS:
signal.signal(s, _signal_handler)
# wait child to finish, end
rc = proc.wait()
if rc:
logger.debug("Child process not finished correctly: returncode=%d", rc)
return rc
================================================
FILE: fades/multiplatform.py
================================================
# Copyright 2016 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General
# Public License version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Platform agnostic collection of utilities."""
import os
from contextlib import contextmanager
try:
import fcntl
@contextmanager
def filelock(filepath):
"""Context manager to lock over a file using best method: fcntl."""
with open(filepath, 'w') as fh:
fcntl.flock(fh, fcntl.LOCK_EX)
yield
fcntl.flock(fh, fcntl.LOCK_UN)
if os.path.exists(filepath):
os.remove(filepath)
except ImportError:
import time
@contextmanager
def filelock(filepath):
"""Context manager to lock over a file where fcntl doesn't exist."""
try:
while True:
try:
with open(filepath, "x"):
yield
break
except FileExistsError:
time.sleep(.5)
finally:
if os.path.exists(filepath):
os.remove(filepath)
================================================
FILE: fades/parsing.py
================================================
# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check https://github.com/PyAr/fades
"""Script parsing to get needed dependencies."""
import logging
import os
import re
from packaging.requirements import Requirement
from packaging.version import Version
from fades import REPO_PYPI, REPO_VCS
from fades.pkgnamesdb import MODULE_TO_PACKAGE
logger = logging.getLogger(__name__)
class _VCSSpecifier:
"""A simple specifier that works with VCSDependency."""
def contains(self, other):
"""VCS dependency does not handle versions."""
return other is None
class VCSDependency:
"""A dependency object for VCS urls (git, bzr, etc.).
It stores as unique identifier the whole URL; there may be a little
inefficiency because we may consider as different two urls for same
project but using different transports, but it's a small price for
not needing to parse and analyze url parts.
"""
def __init__(self, url):
"""Init."""
self.url = self.name = self.project_name = self.version = url
self.specifier = _VCSSpecifier()
def __str__(self):
"""Return the URL as this is the interface to get what pip will use."""
return self.url
def __repr__(self):
"""Repr."""
return "<VCSDependency: {!r}>".format(self.url)
def __eq__(self, other):
"""Tell if one VCSDependency is equal to other."""
if not isinstance(other, VCSDependency):
return False
return self.url == other.url
def __hash__(self):
"""Pair to __eq__ to make this hashable."""
return hash(self.url)
class NameVerDependency:
"""A dependency indicated by name and version."""
def __init__(self, name, version):
self.name = name
self.version = Version(version)
def __eq__(self, other):
return self.name == other.name and self.version == other.version
def __hash__(self):
return hash((self.name, self.version))
def __lt__(self, other):
assert not isinstance(self.version, str)
return (self.name, self.version) < (other.name, other.version)
def parse_fade_requirement(text):
"""Return a requirement and repo from the given text, already parsed and converted."""
text = text.strip()
if "::" in text:
repo_raw, requirement = text.split("::", 1)
try:
repo = {'pypi': REPO_PYPI, 'vcs': REPO_VCS}[repo_raw]
except KeyError:
logger.warning("Not understood fades repository: %r", repo_raw)
return
else:
if ":" in text and "/" in text:
repo = REPO_VCS
else:
repo = REPO_PYPI
requirement = text
if repo == REPO_VCS:
dependency = VCSDependency(requirement)
else:
dependency = Requirement(requirement)
return repo, dependency
def _parse_content(fh):
"""Parse the content of a script to find marked dependencies."""
content = iter(fh)
deps = {}
for line in content:
# quickly discard most of the lines
if 'fades' not in line:
continue
# discard other string with 'fades' that isn't a comment
if '#' not in line:
continue
# assure that it's a well commented line and no other stuff
line = line.strip()
index_of_last_fades = line.rfind('fades')
index_of_first_hash = line.index('#')
# discard when fades does not appear after #
if index_of_first_hash > index_of_last_fades:
continue
import_part, fades_part = line.rsplit("#", 1)
# discard other comments in the same line that aren't for fades
if "fades" not in fades_part:
import_part, fades_part = import_part.rsplit("#", 1)
fades_part = fades_part.strip()
if not fades_part.startswith("fades"):
continue
if not import_part:
# the fades comment was done at the beginning of the line,
# which means that the import info is in the next one
import_part = next(content).strip()
if import_part.startswith('#'):
continue
# Get the module.
import_tokens = import_part.split()
if import_tokens[0] == 'import':
module_path = import_tokens[1]
elif import_tokens[0] == 'from' and import_tokens[2] == 'import':
module_path = import_tokens[1]
else:
logger.debug("Not understood import info: %s", import_tokens)
continue
module = module_path.split(".")[0]
# The package has the same name (most of the times! if fades knows the conversion, use it).
if module in MODULE_TO_PACKAGE:
package = MODULE_TO_PACKAGE[module]
else:
package = module
# To match the "safe" name
package = package.replace('_', '-')
# get the fades info after 'fades' mark, if any
if len(fades_part) == 5 or fades_part[5:].strip()[0] in "<>=!":
# just the 'fades' mark, and maybe a version specification, the requirement is what
# was imported (maybe with that version comparison)
requirement = package + fades_part[5:]
elif fades_part[5] != " ":
# starts with fades but it's part of a longer weird word
logger.warning("Not understood fades info: %r", fades_part)
continue
else:
# more complex stuff, to be parsed as a normal requirement
requirement = fades_part[5:]
# parse and convert the requirement
parsed_req = parse_fade_requirement(requirement)
if parsed_req is None:
continue
repo, dependency = parsed_req
deps.setdefault(repo, []).append(dependency)
return deps
def _parse_docstring(fh):
"""Parse the docstrings of a script to find marked dependencies."""
find_fades = re.compile(r'\b(fades)\b:').search
for line in fh:
if line.startswith("'"):
quote = "'"
break
if line.startswith('"'):
quote = '"'
break
else:
return {}
if line[1] == quote:
# comment start with triple quotes
endquote = quote * 3
else:
endquote = quote
if endquote in line[len(endquote):]:
docstring_lines = [line[:line.index(endquote)]]
else:
docstring_lines = [line]
for line in fh:
if endquote in line:
docstring_lines.append(line[:line.index(endquote)])
break
docstring_lines.append(line)
docstring_lines = iter(docstring_lines)
for doc_line in docstring_lines:
if find_fades(doc_line):
break
else:
return {}
return _parse_requirement(list(docstring_lines))
def _parse_requirement(iterable):
"""Actually parse the requirements, from file or manually specified."""
deps = {}
for line in iterable:
line = line.strip()
if "#" in line:
line = line[:line.index("#")]
if not line:
continue
parsed_req = parse_fade_requirement(line)
if parsed_req is None:
continue
repo, dependency = parsed_req
deps.setdefault(repo, []).append(dependency)
return deps
def parse_manual(dependencies):
"""Parse an iterable and return specified dependencies."""
if dependencies is None:
return {}
return _parse_requirement(dependencies)
def _read_lines(filepath):
"""Read a req file to a list to support nested requirement files."""
with open(filepath, 'rt', encoding='utf8') as fh:
for line in fh:
line = line.strip()
if line.startswith("-r"):
logger.debug("Reading deps from nested requirement file: %s", line)
try:
nested_filename = line.split()[1]
except IndexError:
logger.warning(
"Invalid format to indicate a nested requirements file: '%r'", line)
else:
nested_filepath = os.path.join(
os.path.dirname(filepath), nested_filename)
yield from _read_lines(nested_filepath)
else:
yield line
def parse_reqfile(filepath):
"""Parse a requirement file and return the indicated dependencies."""
if filepath is None:
return {}
return _parse_requirement(_read_lines(filepath))
def parse_srcfile(filepath):
"""Parse a source file and return its marked dependencies."""
if filepath is None:
return {}
with open(filepath, 'rt', encoding='utf8') as fh:
return _parse_content(fh)
def parse_docstring(filepath):
"""Parse a source file and return its dependencies specified into docstrings."""
if filepath is None:
return {}
with open(filepath, 'rt', encoding='utf8') as fh:
return _parse_docstring(fh)
================================================
FILE: fades/pipmanager.py
================================================
# Copyright 2014-2020 Facundo Batista, Nicolás Demarchi
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further
gitextract_2mmkzg90/
├── .flake8
├── .github/
│ └── workflows/
│ ├── integtests.yaml
│ └── tests.yaml
├── .gitignore
├── .readthedocs.yaml
├── AUTHORS
├── COPYING
├── HOWTO_RELEASE.txt
├── LICENSE
├── MANIFEST.in
├── README.rst
├── bin/
│ ├── fades
│ └── fades.cmd
├── build_readme
├── docs/
│ ├── Makefile
│ ├── conf.py
│ ├── index.rst
│ ├── pydepmanag.rst
│ ├── readme.rst
│ └── requirements.txt
├── fades/
│ ├── __init__.py
│ ├── __main__.py
│ ├── _version.py
│ ├── cache.py
│ ├── envbuilder.py
│ ├── file_options.py
│ ├── helpers.py
│ ├── logger.py
│ ├── main.py
│ ├── multiplatform.py
│ ├── parsing.py
│ ├── pipmanager.py
│ └── pkgnamesdb.py
├── man/
│ └── fades.1
├── pkg/
│ ├── debian/
│ │ ├── changelog
│ │ ├── compat
│ │ ├── control
│ │ ├── copyright
│ │ ├── rules
│ │ └── watch
│ └── snap/
│ └── snapcraft.yaml
├── press.txt
├── requirements.txt
├── resources/
│ ├── gifs/
│ │ └── gifs.rst
│ ├── notes.txt
│ ├── slides.odp
│ ├── slides_LT.odp
│ └── video/
│ └── script.ods
├── setup.py
├── test
├── testdev
├── testdev.bat
└── tests/
├── __init__.py
├── conftest.py
├── examples/
│ ├── pypi_get_version_fail.json
│ └── pypi_get_version_ok.json
├── integtest.py
├── test_cache/
│ ├── __init__.py
│ ├── conftest.py
│ ├── test_caches.py
│ ├── test_comparisons.py
│ ├── test_remove.py
│ ├── test_selection.py
│ └── test_store.py
├── test_envbuilder.py
├── test_file_options.py
├── test_files/
│ ├── fades_as_part_of_other_word.py
│ ├── no_req.py
│ ├── req_all.py
│ ├── req_class.py
│ ├── req_def.py
│ ├── req_mixed_backends.py
│ ├── req_module.py
│ ├── req_module_2.py
│ └── req_module_3.py
├── test_helpers.py
├── test_infra.py
├── test_logger.py
├── test_main.py
├── test_multiplatform.py
├── test_parsing/
│ ├── test_docstrings.py
│ ├── test_file.py
│ ├── test_file_reqs.py
│ ├── test_manual.py
│ ├── test_reqs.py
│ └── test_vcs_dependency.py
├── test_pipmanager.py
└── test_pkgnamesdb.py
SYMBOL INDEX (427 symbols across 44 files)
FILE: fades/__init__.py
class FadesError (line 23) | class FadesError(Exception):
FILE: fades/cache.py
class VEnvsCache (line 32) | class VEnvsCache:
method __init__ (line 35) | def __init__(self, filepath):
method _venv_match (line 41) | def _venv_match(self, installed, requirements):
method _match_by_uuid (line 90) | def _match_by_uuid(self, current_venvs, uuid):
method _select_better_fit (line 99) | def _select_better_fit(self, matching_venvs):
method _match_by_requirements (line 129) | def _match_by_requirements(self, current_venvs, requirements, interpre...
method _select (line 152) | def _select(self, current_venvs, requirements=None, interpreter='', uu...
method get_venv (line 169) | def get_venv(self, requirements=None, interpreter='', uuid='', options...
method get_venvs_metadata (line 174) | def get_venvs_metadata(self):
method store (line 179) | def store(self, installed_stuff, metadata, interpreter, options):
method remove (line 193) | def remove(self, env_path):
method _read_cache (line 204) | def _read_cache(self):
method _write_cache (line 214) | def _write_cache(self, lines, append=False):
FILE: fades/envbuilder.py
class _FadesEnvBuilder (line 39) | class _FadesEnvBuilder(EnvBuilder):
method __init__ (line 47) | def __init__(self):
method create_with_external_venv (line 71) | def create_with_external_venv(self, interpreter, options):
method create_env (line 91) | def create_env(self, interpreter, is_current, options):
method post_setup (line 116) | def post_setup(self, context):
function create_venv (line 121) | def create_venv(requested_deps, interpreter, is_current, options, pip_op...
function destroy_venv (line 170) | def destroy_venv(env_path, venvscache=None):
class UsageManager (line 181) | class UsageManager:
method __init__ (line 184) | def __init__(self, stat_file_path, venvscache):
method store_usage_stat (line 191) | def store_usage_stat(self, venv_data, cache):
method _create_initial_usage_file_if_not_exists (line 196) | def _create_initial_usage_file_if_not_exists(self):
method _write_venv_usage (line 203) | def _write_venv_usage(self, file_, venv_data):
method _datetime_to_str (line 207) | def _datetime_to_str(self, datetime_):
method _str_to_datetime (line 210) | def _str_to_datetime(self, str_):
method clean_unused_venvs (line 213) | def clean_unused_venvs(self, max_days_to_keep):
method _get_compacted_dict_usage_from_file (line 243) | def _get_compacted_dict_usage_from_file(self):
method _write_compacted_dict_usage_to_file (line 247) | def _write_compacted_dict_usage_to_file(self, dict_usage):
FILE: fades/file_options.py
function options_from_file (line 33) | def options_from_file(args):
FILE: fades/helpers.py
class ExecutionError (line 56) | class ExecutionError(Exception):
method __init__ (line 59) | def __init__(self, retcode, cmd, collected_stdout):
method dump_to_log (line 66) | def dump_to_log(self, logger):
function logged_exec (line 73) | def logged_exec(cmd):
function _get_basedirectory (line 90) | def _get_basedirectory():
function _get_specific_dir (line 95) | def _get_specific_dir(dir_type):
function get_basedir (line 117) | def get_basedir():
function get_confdir (line 122) | def get_confdir():
function _get_interpreter_info (line 127) | def _get_interpreter_info(interpreter=None):
function get_interpreter_version (line 150) | def get_interpreter_version(requested_interpreter):
function get_latest_version_number (line 165) | def get_latest_version_number(project_name):
function check_pypi_updates (line 181) | def check_pypi_updates(dependencies):
function _pypi_head_package (line 218) | def _pypi_head_package(dependency):
function check_pypi_exists (line 246) | def check_pypi_exists(dependencies):
class _ScriptDownloader (line 262) | class _ScriptDownloader:
method __init__ (line 283) | def __init__(self, url):
method _decide (line 288) | def _decide(self):
method get (line 294) | def get(self):
method _download_raw (line 300) | def _download_raw(self, url=None):
method _download_linkode (line 321) | def _download_linkode(self):
method _download_pastebin (line 336) | def _download_pastebin(self):
method _download_gist (line 342) | def _download_gist(self):
function download_remote_script (line 349) | def download_remote_script(url):
function get_env_bin_path (line 363) | def get_env_bin_path(base_env_path):
FILE: fades/logger.py
class SalutingStreamHandler (line 33) | class SalutingStreamHandler(logging.StreamHandler):
method __init__ (line 39) | def __init__(self, logger):
method emit (line 45) | def emit(self, record):
function set_up (line 53) | def set_up(verbose, quiet):
FILE: fades/main.py
function get_autoimport_scriptname (line 87) | def get_autoimport_scriptname(dependencies, is_ipython):
function consolidate_dependencies (line 121) | def consolidate_dependencies(needs_ipython, child_program,
function decide_child_program (line 160) | def decide_child_program(args_executable, args_module, args_child_program):
function detect_inside_virtualenv (line 201) | def detect_inside_virtualenv(prefix, real_prefix, base_prefix):
function go (line 226) | def go():
FILE: fades/multiplatform.py
function filelock (line 28) | def filelock(filepath):
function filelock (line 41) | def filelock(filepath):
FILE: fades/parsing.py
class _VCSSpecifier (line 32) | class _VCSSpecifier:
method contains (line 35) | def contains(self, other):
class VCSDependency (line 40) | class VCSDependency:
method __init__ (line 49) | def __init__(self, url):
method __str__ (line 54) | def __str__(self):
method __repr__ (line 58) | def __repr__(self):
method __eq__ (line 62) | def __eq__(self, other):
method __hash__ (line 68) | def __hash__(self):
class NameVerDependency (line 73) | class NameVerDependency:
method __init__ (line 76) | def __init__(self, name, version):
method __eq__ (line 80) | def __eq__(self, other):
method __hash__ (line 83) | def __hash__(self):
method __lt__ (line 86) | def __lt__(self, other):
function parse_fade_requirement (line 91) | def parse_fade_requirement(text):
function _parse_content (line 116) | def _parse_content(fh):
function _parse_docstring (line 200) | def _parse_docstring(fh):
function _parse_requirement (line 240) | def _parse_requirement(iterable):
function parse_manual (line 259) | def parse_manual(dependencies):
function _read_lines (line 266) | def _read_lines(filepath):
function parse_reqfile (line 286) | def parse_reqfile(filepath):
function parse_srcfile (line 293) | def parse_srcfile(filepath):
function parse_docstring (line 301) | def parse_docstring(filepath):
FILE: fades/pipmanager.py
class PipManager (line 38) | class PipManager():
method __init__ (line 41) | def __init__(self, env_bin_path, pip_installed=False, options=None, av...
method install (line 51) | def install(self, dependency):
method get_version (line 84) | def get_version(self, dependency):
method _download_pip_installer (line 98) | def _download_pip_installer(self):
method _brute_force_install_pip (line 105) | def _brute_force_install_pip(self):
method freeze (line 119) | def freeze(self, filepath):
FILE: setup.py
function get_version (line 36) | def get_version():
class CustomInstall (line 50) | class CustomInstall(install):
method initialize_options (line 53) | def initialize_options(self):
method run (line 61) | def run(self):
method finalize_options (line 71) | def finalize_options(self):
FILE: tests/__init__.py
function get_tempfile (line 25) | def get_tempfile(testcase):
function create_tempfile (line 40) | def create_tempfile(testcase, lines):
function get_python_filepaths (line 50) | def get_python_filepaths(roots):
function get_reqs (line 61) | def get_reqs(*items):
FILE: tests/conftest.py
function tmp_file (line 23) | def tmp_file(tmp_path):
function create_tmpfile (line 29) | def create_tmpfile(tmp_path):
function pytest_addoption (line 43) | def pytest_addoption(parser):
FILE: tests/integtest.py
function test_assert_python_version (line 26) | def test_assert_python_version(pytestconfig):
FILE: tests/test_cache/__init__.py
function get_distrib (line 22) | def get_distrib(*dep_ver_pairs):
FILE: tests/test_cache/conftest.py
function venvscache (line 25) | def venvscache(tmpdir_factory):
FILE: tests/test_cache/test_caches.py
function test_missing_file_pytest (line 22) | def test_missing_file_pytest(tmp_file):
function test_empty_file_pytest (line 30) | def test_empty_file_pytest(tmp_file):
function test_some_file_content_pytest (line 39) | def test_some_file_content_pytest(tmp_file):
function test_get_by_uuid_pytest (line 50) | def test_get_by_uuid_pytest(tmp_file):
FILE: tests/test_cache/test_comparisons.py
function test_check_versions (line 57) | def test_check_versions(venvscache, req, installed, expected):
function test_best_fit (line 120) | def test_best_fit(venvscache, possible_venvs):
FILE: tests/test_cache/test_remove.py
function test_missing_file (line 26) | def test_missing_file(tmp_file):
function test_missing_env_in_cache (line 34) | def test_missing_env_in_cache(tmp_file):
function test_preserve_cache_data_ordering (line 47) | def test_preserve_cache_data_ordering(tmp_file):
function test_lock_cache_for_remove (line 63) | def test_lock_cache_for_remove(tmp_file):
FILE: tests/test_cache/test_selection.py
function test_empty (line 25) | def test_empty(venvscache):
function test_nomatch_repo_dependency (line 30) | def test_nomatch_repo_dependency(venvscache):
function test_nomatch_pypi_dependency (line 44) | def test_nomatch_pypi_dependency(venvscache):
function test_nomatch_vcs_dependency (line 58) | def test_nomatch_vcs_dependency(venvscache):
function test_nomatch_version (line 72) | def test_nomatch_version(venvscache):
function test_simple_pypi_match (line 86) | def test_simple_pypi_match(venvscache):
function test_simple_vcs_match (line 100) | def test_simple_vcs_match(venvscache):
function test_match_mixed_single (line 114) | def test_match_mixed_single(venvscache):
function test_match_mixed_multiple (line 141) | def test_match_mixed_multiple(venvscache):
function test_match_noversion (line 158) | def test_match_noversion(venvscache):
function test_middle_match (line 172) | def test_middle_match(venvscache):
function test_multiple_match_bigger_version (line 199) | def test_multiple_match_bigger_version(venvscache):
function test_multiple_deps_ok (line 228) | def test_multiple_deps_ok(venvscache):
function test_multiple_deps_just_one (line 242) | def test_multiple_deps_just_one(venvscache):
function test_not_too_crowded (line 256) | def test_not_too_crowded(venvscache):
function test_same_quantity_different_deps (line 270) | def test_same_quantity_different_deps(venvscache):
function test_no_requirements_some_installed (line 284) | def test_no_requirements_some_installed(venvscache):
function test_no_requirements_empty_venv (line 298) | def test_no_requirements_empty_venv(venvscache):
function test_simple_match_empty_options (line 312) | def test_simple_match_empty_options(venvscache):
function test_no_match_due_to_options (line 326) | def test_no_match_due_to_options(venvscache):
function test_match_due_to_options (line 340) | def test_match_due_to_options(venvscache):
function test_no_deps_but_options (line 360) | def test_no_deps_but_options(venvscache):
function test_match_uuid (line 380) | def test_match_uuid(venvscache):
FILE: tests/test_cache/test_store.py
function test_missing_file (line 22) | def test_missing_file(tmp_file):
function test_with_previous_content (line 35) | def test_with_previous_content(tmp_file):
FILE: tests/test_envbuilder.py
function get_req (line 35) | def get_req(text):
class EnvCreationTestCase (line 40) | class EnvCreationTestCase(unittest.TestCase):
class FakeManager (line 43) | class FakeManager:
method __init__ (line 45) | def __init__(self):
method install (line 49) | def install(self, dependency):
method get_version (line 52) | def get_version(self, dependency):
class FailInstallManager (line 55) | class FailInstallManager(FakeManager):
method install (line 56) | def install(self, dependency):
method setUp (line 59) | def setUp(self):
method test_create_simple (line 62) | def test_create_simple(self):
method test_create_vcs (line 95) | def test_create_vcs(self):
method test_unknown_repo (line 118) | def test_unknown_repo(self):
method test_non_existing_dep (line 136) | def test_non_existing_dep(self):
method test_different_versions (line 160) | def test_different_versions(self):
method test_create_system_site_pkgs_venv (line 184) | def test_create_system_site_pkgs_venv(self):
method test_create_pyvenv (line 194) | def test_create_pyvenv(self):
method test_create_virtual_environment (line 204) | def test_create_virtual_environment(self):
class EnvDestructionTestCase (line 214) | class EnvDestructionTestCase(unittest.TestCase):
method test_destroy_venv (line 216) | def test_destroy_venv(self):
method test_destroy_venv_if_env_path_not_found (line 240) | def test_destroy_venv_if_env_path_not_found(self):
class UsageManagerTestCase (line 250) | class UsageManagerTestCase(unittest.TestCase):
method setUp (line 252) | def setUp(self):
method get_usage_lines (line 266) | def get_usage_lines(self, manager):
method test_file_usage_dont_exists_then_it_is_created_and_initialized (line 275) | def test_file_usage_dont_exists_then_it_is_created_and_initialized(self):
method test_usage_record_is_recorded (line 286) | def test_usage_record_is_recorded(self):
method test_usage_file_is_compacted_when_though_no_venv_is_removed (line 298) | def test_usage_file_is_compacted_when_though_no_venv_is_removed(self):
method test_executionerror_exception (line 331) | def test_executionerror_exception(self):
method test_general_error_exception (line 342) | def test_general_error_exception(self):
method test_when_a_venv_is_removed_it_is_removed_from_everywhere (line 353) | def test_when_a_venv_is_removed_it_is_removed_from_everywhere(self):
FILE: tests/test_file_options.py
class OptionsFileTestCase (line 27) | class OptionsFileTestCase(unittest.TestCase):
method setUp (line 30) | def setUp(self):
method build_parser (line 38) | def build_parser(self, args):
method test_no_config_files (line 44) | def test_no_config_files(self):
method test_single_config_file_no_cli (line 53) | def test_single_config_file_no_cli(self, mocked_parser):
method test_single_config_file_with_cli (line 64) | def test_single_config_file_with_cli(self, mocked_parser):
method test_single_config_file_with_mergeable (line 76) | def test_single_config_file_with_mergeable(self, mocked_parser):
method test_single_config_file_complex_mergeable (line 89) | def test_single_config_file_complex_mergeable(self, mocked_parser):
method test_two_config_file_with_mergeable (line 102) | def test_two_config_file_with_mergeable(self, mocked_parser):
method test_two_config_file_with_booleans (line 118) | def test_two_config_file_with_booleans(self, mocked_parser):
method test_two_config_file_override_by_cli (line 131) | def test_two_config_file_override_by_cli(self, mocked_parser):
method test_three_config_file_override (line 144) | def test_three_config_file_override(self, mocked_parser):
FILE: tests/test_files/fades_as_part_of_other_word.py
function def_function (line 6) | def def_function():
FILE: tests/test_files/no_req.py
class FooClass (line 16) | class FooClass():
method foo (line 18) | def foo(self):
FILE: tests/test_files/req_all.py
class FooClass (line 18) | class FooClass():
method __init__ (line 23) | def __init__(self):
method create (line 26) | def create(self, interpreter):
FILE: tests/test_files/req_class.py
class FooClass (line 15) | class FooClass():
method __init__ (line 21) | def __init__(self):
FILE: tests/test_files/req_def.py
function def_function (line 6) | def def_function():
FILE: tests/test_files/req_module.py
class FooClass (line 19) | class FooClass():
method foo (line 21) | def foo(self):
FILE: tests/test_files/req_module_2.py
class FooClass (line 19) | class FooClass():
method foo (line 21) | def foo(self):
FILE: tests/test_files/req_module_3.py
class FooClass (line 10) | class FooClass():
method foo (line 12) | def foo(self):
FILE: tests/test_helpers.py
class GetInterpreterVersionTestCase (line 40) | class GetInterpreterVersionTestCase(unittest.TestCase):
method test_current_version (line 43) | def test_current_version(self):
method test_other_version (line 54) | def test_other_version(self):
method test_none_requested (line 65) | def test_none_requested(self):
class GetInterpreterInfoTestCase (line 78) | class GetInterpreterInfoTestCase(unittest.TestCase):
method setUp (line 81) | def setUp(self):
method test_none_requested (line 84) | def test_none_requested(self):
method test_requested_fullpath_nodigit (line 91) | def test_requested_fullpath_nodigit(self):
method test_requested_fullpath_with_major (line 98) | def test_requested_fullpath_with_major(self):
method test_requested_fullpath_with_minor (line 105) | def test_requested_fullpath_with_minor(self):
method test_requested_nodigit (line 112) | def test_requested_nodigit(self):
method test_requested_with_major (line 119) | def test_requested_with_major(self):
method test_requested_with_minor (line 126) | def test_requested_with_minor(self):
method test_requested_not_exists (line 133) | def test_requested_not_exists(self):
class GetLatestVersionNumberTestCase (line 146) | class GetLatestVersionNumberTestCase(unittest.TestCase):
method setUp (line 149) | def setUp(self):
method test_get_version_correct (line 152) | def test_get_version_correct(self):
method test_get_version_wrong (line 160) | def test_get_version_wrong(self):
method test_get_version_fail (line 172) | def test_get_version_fail(self):
class CheckPyPIUpdatesTestCase (line 180) | class CheckPyPIUpdatesTestCase(unittest.TestCase):
method setUp (line 183) | def setUp(self):
method test_check_pypi_updates_with_and_without_version (line 186) | def test_check_pypi_updates_with_and_without_version(self):
method test_check_pypi_updates_with_a_higher_version_of_a_package_simple (line 201) | def test_check_pypi_updates_with_a_higher_version_of_a_package_simple(...
method test_check_pypi_updates_with_a_higher_version_of_a_package_real_order (line 210) | def test_check_pypi_updates_with_a_higher_version_of_a_package_real_or...
method test_check_pypi_updates_with_the_latest_version_of_a_package (line 219) | def test_check_pypi_updates_with_the_latest_version_of_a_package(self):
class GetDirsTestCase (line 229) | class GetDirsTestCase(unittest.TestCase):
method test_basedir_xdg (line 234) | def test_basedir_xdg(self):
method _fake_snap_env_dir (line 238) | def _fake_snap_env_dir(self, direct):
method test_basedir_snap (line 243) | def test_basedir_snap(self):
method test_basedir_default (line 249) | def test_basedir_default(self):
method test_basedir_xdg_nonexistant (line 255) | def test_basedir_xdg_nonexistant(self):
method test_basedir_snap_nonexistant (line 262) | def test_basedir_snap_nonexistant(self):
method test_confdir_xdg (line 268) | def test_confdir_xdg(self):
method test_confdir_snap (line 272) | def test_confdir_snap(self):
method test_confdir_default (line 278) | def test_confdir_default(self):
method test_confdir_xdg_nonexistant (line 284) | def test_confdir_xdg_nonexistant(self):
method test_confdir_snap_nonexistant (line 291) | def test_confdir_snap_nonexistant(self):
class CheckPackageExistenceTestCase (line 298) | class CheckPackageExistenceTestCase(unittest.TestCase):
method setUp (line 301) | def setUp(self):
method test_exists (line 304) | def test_exists(self):
method test_all_exists (line 316) | def test_all_exists(self):
method test_doesnt_exists (line 328) | def test_doesnt_exists(self):
method test_one_doesnt_exists (line 340) | def test_one_doesnt_exists(self):
method test_error_hitting_pypi (line 354) | def test_error_hitting_pypi(self):
method test_status_code_error (line 363) | def test_status_code_error(self):
method test_redirect_response (line 373) | def test_redirect_response(self):
class ScriptDownloaderTestCase (line 386) | class ScriptDownloaderTestCase(unittest.TestCase):
method setUp (line 389) | def setUp(self):
method test_external_public_function (line 392) | def test_external_public_function(self):
method test_decide_linkode (line 412) | def test_decide_linkode(self):
method test_decide_pastebin (line 418) | def test_decide_pastebin(self):
method test_decide_gist (line 424) | def test_decide_gist(self):
method test_downloader_raw (line 430) | def test_downloader_raw(self):
method test_downloader_linkode (line 454) | def test_downloader_linkode(self):
method test_downloader_pastebin (line 483) | def test_downloader_pastebin(self):
method test_downloader_gist (line 510) | def test_downloader_gist(self):
method test_downloader_raw_with_redirection (line 537) | def test_downloader_raw_with_redirection(self):
function test_getbinpath_posix (line 567) | def test_getbinpath_posix(tmp_path):
function test_getbinpath_windows (line 574) | def test_getbinpath_windows(tmp_path):
function test_getbinpath_missing (line 581) | def test_getbinpath_missing(tmp_path):
FILE: tests/test_infra.py
function test_flake8_pytest (line 41) | def test_flake8_pytest(capsys):
function test_pep257_pytest (line 50) | def test_pep257_pytest():
function test_readme_sanity (line 61) | def test_readme_sanity():
function test_authors_ordering (line 73) | def test_authors_ordering():
FILE: tests/test_logger.py
function test_salutes_info (line 21) | def test_salutes_info(logs):
function test_salutes_once (line 30) | def test_salutes_once(logs):
FILE: tests/test_main.py
class VirtualenvCheckingTestCase (line 29) | class VirtualenvCheckingTestCase(unittest.TestCase):
method test_have_realprefix (line 32) | def test_have_realprefix(self):
method test_no_baseprefix (line 36) | def test_no_baseprefix(self):
method test_prefix_is_baseprefix (line 40) | def test_prefix_is_baseprefix(self):
method test_prefix_is_not_baseprefix (line 44) | def test_prefix_is_not_baseprefix(self):
class DepsGatheringTestCase (line 49) | class DepsGatheringTestCase(unittest.TestCase):
method test_needs_ipython (line 52) | def test_needs_ipython(self):
method test_child_program (line 58) | def test_child_program(self):
method test_requirement_files (line 66) | def test_requirement_files(self):
method test_manual_dependencies (line 75) | def test_manual_dependencies(self):
class DepsMergingTestCase (line 85) | class DepsMergingTestCase(unittest.TestCase):
method test_two_different (line 88) | def test_two_different(self):
method test_two_same_repo (line 101) | def test_two_same_repo(self):
method test_complex_case (line 113) | def test_complex_case(self):
method test_one_duplicated (line 128) | def test_one_duplicated(self):
method test_two_different_with_dups (line 140) | def test_two_different_with_dups(self):
class MiscTestCase (line 155) | class MiscTestCase(unittest.TestCase):
method test_version_show (line 158) | def test_version_show(self):
class ChildProgramDeciderTestCase (line 165) | class ChildProgramDeciderTestCase(unittest.TestCase):
method test_indicated_with_executable_flag (line 168) | def test_indicated_with_executable_flag(self):
method test_no_child_at_all (line 173) | def test_no_child_at_all(self):
method test_normal_child_program (line 178) | def test_normal_child_program(self):
method test_normal_child_program_not_found (line 184) | def test_normal_child_program_not_found(self):
method test_normal_child_program_no_access (line 188) | def test_normal_child_program_no_access(self):
method test_remote_child_program_simple (line 195) | def test_remote_child_program_simple(self):
method test_remote_child_program_ssl (line 206) | def test_remote_child_program_ssl(self):
method test_indicated_with_executable_flag_with_relative_path (line 217) | def test_indicated_with_executable_flag_with_relative_path(self):
method test_indicated_with_executable_flag_with_absolute_path (line 222) | def test_indicated_with_executable_flag_with_absolute_path(self):
method test_module (line 228) | def test_module(self):
function _autoimport_safe_call (line 238) | def _autoimport_safe_call(*args, **kwargs):
function test_autoimport_simple (line 249) | def test_autoimport_simple():
function test_autoimport_several_dependencies (line 260) | def test_autoimport_several_dependencies():
function test_autoimport_including_ipython (line 272) | def test_autoimport_including_ipython():
function test_autoimport_no_pypi_dep (line 287) | def test_autoimport_no_pypi_dep():
function test_autoimport_importer_mod_ok (line 299) | def test_autoimport_importer_mod_ok(capsys):
function test_autoimport_importer_mod_fail (line 306) | def test_autoimport_importer_mod_fail(capsys):
FILE: tests/test_multiplatform.py
class LockChecker (line 28) | class LockChecker(threading.Thread):
method __init__ (line 35) | def __init__(self, filepath):
method run (line 41) | def run(self):
class LockCacheTestCase (line 49) | class LockCacheTestCase(unittest.TestCase):
method setUp (line 52) | def setUp(self):
method tearDown (line 55) | def tearDown(self):
method wait (line 59) | def wait(self, lock_checker, attr_name):
method test_lock_alone (line 69) | def test_lock_alone(self):
method test_lock_intermixed (line 75) | def test_lock_intermixed(self):
method test_lock_exploding (line 92) | def test_lock_exploding(self):
FILE: tests/test_parsing/test_docstrings.py
function test_empty (line 9) | def test_empty():
function test_only_comment (line 18) | def test_only_comment():
function test_req_in_module_docstring_triple_doublequoute (line 24) | def test_req_in_module_docstring_triple_doublequoute():
function test_req_in_module_docstring_triple_singlequote (line 30) | def test_req_in_module_docstring_triple_singlequote():
function test_req_in_module_docstring_one_doublequote (line 36) | def test_req_in_module_docstring_one_doublequote():
function test_req_in_class_docstring (line 42) | def test_req_in_class_docstring():
function test_req_in_def_docstring (line 49) | def test_req_in_def_docstring():
function test_req_in_multi_docstring (line 56) | def test_req_in_multi_docstring():
function test_fades_word_as_part_of_text (line 63) | def test_fades_word_as_part_of_text():
function test_mixed_backends (line 69) | def test_mixed_backends():
FILE: tests/test_parsing/test_file.py
function test_nocomment (line 11) | def test_nocomment():
function test_simple_default (line 21) | def test_simple_default():
function test_double (line 29) | def test_double():
function test_version_same_default (line 39) | def test_version_same_default():
function test_version_different (line 48) | def test_version_different():
function test_version_same_no_spaces (line 57) | def test_version_same_no_spaces():
function test_version_same_two_spaces (line 66) | def test_version_same_two_spaces():
function test_version_same_one_space_before (line 75) | def test_version_same_one_space_before():
function test_version_same_two_space_before (line 84) | def test_version_same_two_space_before():
function test_version_same_one_space_after (line 93) | def test_version_same_one_space_after():
function test_version_same_two_space_after (line 102) | def test_version_same_two_space_after():
function test_version_greater (line 111) | def test_version_greater():
function test_version_greater_no_space (line 120) | def test_version_greater_no_space():
function test_version_greater_no_space_default (line 129) | def test_version_greater_no_space_default():
function test_version_greater_two_spaces (line 138) | def test_version_greater_two_spaces():
function test_version_greater_one_space_after (line 147) | def test_version_greater_one_space_after():
function test_version_greater_two_space_after (line 156) | def test_version_greater_two_space_after():
function test_version_greater_one_space_before (line 165) | def test_version_greater_one_space_before():
function test_version_greater_two_space_before (line 174) | def test_version_greater_two_space_before():
function test_version_same_or_greater (line 183) | def test_version_same_or_greater():
function test_version_same_or_greater_no_spaces (line 192) | def test_version_same_or_greater_no_spaces():
function test_version_same_or_greater_one_space_before (line 201) | def test_version_same_or_greater_one_space_before():
function test_version_same_or_greater_two_space_before (line 210) | def test_version_same_or_greater_two_space_before():
function test_version_same_or_greater_one_space_after (line 219) | def test_version_same_or_greater_one_space_after():
function test_version_same_or_greater_two_space_after (line 228) | def test_version_same_or_greater_two_space_after():
function test_continuation_line (line 237) | def test_continuation_line():
function test_from_import_simple (line 248) | def test_from_import_simple():
function test_import (line 257) | def test_import():
function test_from_import_complex (line 266) | def test_from_import_complex():
function test_allow_other_comments (line 275) | def test_allow_other_comments():
function test_allow_other_comments_reverse_default (line 284) | def test_allow_other_comments_reverse_default():
function test_strange_import (line 293) | def test_strange_import(logs):
function test_strange_fadesinfo (line 302) | def test_strange_fadesinfo(logs):
function test_strange_fadesinfo2 (line 310) | def test_strange_fadesinfo2(logs):
function test_projectname_noversion_implicit (line 318) | def test_projectname_noversion_implicit():
function test_projectname_noversion_explicit (line 327) | def test_projectname_noversion_explicit():
function test_projectname_version_explicit (line 336) | def test_projectname_version_explicit():
function test_projectname_version_nospace (line 345) | def test_projectname_version_nospace():
function test_projectname_version_space (line 354) | def test_projectname_version_space():
function test_projectname_pkgnamedb (line 363) | def test_projectname_pkgnamedb():
function test_projectname_pkgnamedb_version (line 372) | def test_projectname_pkgnamedb_version():
function test_projectname_pkgnamedb_othername_default (line 381) | def test_projectname_pkgnamedb_othername_default():
function test_projectname_pkgnamedb_version_othername (line 390) | def test_projectname_pkgnamedb_version_othername():
function test_comma_separated_import (line 399) | def test_comma_separated_import():
function test_other_lines_with_fades_string (line 408) | def test_other_lines_with_fades_string():
function test_commented_line (line 418) | def test_commented_line(logs):
function test_with_fades_commented_line (line 426) | def test_with_fades_commented_line(logs):
function test_with_commented_line (line 437) | def test_with_commented_line(logs):
function test_vcs_explicit (line 448) | def test_vcs_explicit():
function test_vcs_implicit (line 457) | def test_vcs_implicit():
function test_mixed (line 466) | def test_mixed():
function test_fades_and_hashtag_mentioned_in_code (line 477) | def test_fades_and_hashtag_mentioned_in_code():
function test_fades_and_hashtag_mentioned_in_code_mixed_with_imports (line 487) | def test_fades_and_hashtag_mentioned_in_code_mixed_with_imports():
function test_fades_user_strange_comment_with_hashtag_ignored (line 497) | def test_fades_user_strange_comment_with_hashtag_ignored():
FILE: tests/test_parsing/test_file_reqs.py
function test_requirement_files (line 9) | def test_requirement_files(create_tmpfile):
function test_nested_requirement_files (line 14) | def test_nested_requirement_files(create_tmpfile):
function test_nested_requirement_files_invalid_format (line 24) | def test_nested_requirement_files_invalid_format(logs, create_tmpfile):
function test_nested_requirement_files_not_pwd (line 32) | def test_nested_requirement_files_not_pwd(create_tmpfile):
function test_nested_requirement_files_first_line (line 42) | def test_nested_requirement_files_first_line(create_tmpfile):
function test_two_nested_requirement_files (line 51) | def test_two_nested_requirement_files(create_tmpfile):
FILE: tests/test_parsing/test_manual.py
function test_none (line 6) | def test_none():
function test_nothing (line 11) | def test_nothing():
function test_simple (line 16) | def test_simple():
function test_simple_default_pypi (line 21) | def test_simple_default_pypi():
function test_double (line 26) | def test_double():
function test_version (line 31) | def test_version():
function test_version_default (line 36) | def test_version_default():
function test_vcs_simple (line 41) | def test_vcs_simple():
function test_vcs_simple_default (line 47) | def test_vcs_simple_default():
function test_mixed (line 53) | def test_mixed():
FILE: tests/test_parsing/test_reqs.py
function test_empty (line 11) | def test_empty():
function test_simple (line 18) | def test_simple():
function test_simple_default (line 25) | def test_simple_default():
function test_double (line 32) | def test_double():
function test_version_same (line 42) | def test_version_same():
function test_version_same_default (line 51) | def test_version_same_default():
function test_version_different (line 60) | def test_version_different():
function test_version_same_no_spaces (line 69) | def test_version_same_no_spaces():
function test_version_greater_two_spaces (line 78) | def test_version_greater_two_spaces():
function test_version_same_or_greater (line 87) | def test_version_same_or_greater():
function test_comments (line 96) | def test_comments():
function test_strange_repo (line 107) | def test_strange_repo(logs):
function test_vcs_simple (line 115) | def test_vcs_simple():
function test_vcs_simple_default (line 122) | def test_vcs_simple_default():
function test_mixed (line 129) | def test_mixed():
FILE: tests/test_parsing/test_vcs_dependency.py
function test_string_representation (line 5) | def test_string_representation():
function test_contains (line 11) | def test_contains():
function test_equality (line 18) | def test_equality():
FILE: tests/test_pipmanager.py
function test_get_parsing_ok_pytest (line 31) | def test_get_parsing_ok_pytest():
function test_get_parsing_error (line 44) | def test_get_parsing_error(logs):
function test_real_case_levenshtein (line 62) | def test_real_case_levenshtein():
function test_install (line 75) | def test_install():
function test_install_without_pip_upgrade (line 88) | def test_install_without_pip_upgrade():
function test_install_multiword_dependency (line 96) | def test_install_multiword_dependency():
function test_install_with_options (line 104) | def test_install_with_options():
function test_install_with_options_using_equal (line 112) | def test_install_with_options_using_equal():
function test_install_raise_error (line 120) | def test_install_raise_error(logs):
function test_install_without_pip (line 129) | def test_install_without_pip():
function test_brute_force_install_pip_installer_exists (line 139) | def test_brute_force_install_pip_installer_exists(tmp_path):
function test_brute_force_install_pip_no_installer (line 157) | def test_brute_force_install_pip_no_installer(tmp_path):
function test_download_pip_installer (line 172) | def test_download_pip_installer(tmp_path):
function test_freeze (line 183) | def test_freeze(tmp_path):
FILE: tests/test_pkgnamesdb.py
function test_db_consistency (line 22) | def test_db_consistency():
Condensed preview — 88 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (488K chars).
[
{
"path": ".flake8",
"chars": 66,
"preview": "[flake8]\nmax-line-length=99\nexclude=.git\nselect=E,W,F,C,N\nignore=\n"
},
{
"path": ".github/workflows/integtests.yaml",
"chars": 3976,
"preview": "name: Integration Tests\n\non:\n push:\n branches: [ master ]\n pull_request:\n branches: [ master ]\n\njobs:\n\n archlin"
},
{
"path": ".github/workflows/tests.yaml",
"chars": 795,
"preview": "name: Tests\n\non:\n push:\n branches: [ master ]\n pull_request:\n branches: [ master ]\n\n # Allows you to run this w"
},
{
"path": ".gitignore",
"chars": 822,
"preview": "# Generated as a side effect of development\nREADME.html\n\n# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n"
},
{
"path": ".readthedocs.yaml",
"chars": 299,
"preview": "# Read the Docs configuration file for Sphinx projects\n# See https://docs.readthedocs.io/en/stable/config-file/v2.html f"
},
{
"path": "AUTHORS",
"chars": 884,
"preview": "Alejandro Dau <alejandro@dau.com.ar>\nAndrés Delfino <adelfino@gmail.com>\nAriel Rossanigo <arielrossanigo@gmail.com>\nBere"
},
{
"path": "COPYING",
"chars": 35068,
"preview": "\n\t\t GNU GENERAL PUBLIC LICENSE\n\t\t Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <"
},
{
"path": "HOWTO_RELEASE.txt",
"chars": 4394,
"preview": "Steps before a release is done\n------------------------------\n\nCheck all is crispy\n\n rm -rf build dist\n ./setup.py cle"
},
{
"path": "LICENSE",
"chars": 35122,
"preview": "GNU GENERAL PUBLIC LICENSE\n Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation,"
},
{
"path": "MANIFEST.in",
"chars": 71,
"preview": "include README.rst\ninclude COPYING\ninclude AUTHORS\ninclude man/fades.1\n"
},
{
"path": "README.rst",
"chars": 28249,
"preview": "What is fades?\n==============\n\n\n.. image:: https://github.com/PyAr/fades/actions/workflows/test.uaml/badge.svg\n :targ"
},
{
"path": "bin/fades",
"chars": 1487,
"preview": "#!/usr/bin/env python3\n\n#\n# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can "
},
{
"path": "bin/fades.cmd",
"chars": 795,
"preview": "::\n:: Copyright 2018 Facundo Batista, Nicolás Demarchi\n::\n:: This program is free software: you can redistribute it and/"
},
{
"path": "build_readme",
"chars": 112,
"preview": "FADES='./bin/fades -r requirements.txt'\npython3 setup.py --long-description | $FADES -x rst2html5 > README.html\n"
},
{
"path": "docs/Makefile",
"chars": 7405,
"preview": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS =\nSPHINXBUILD "
},
{
"path": "docs/conf.py",
"chars": 1013,
"preview": "# Configuration file for the Sphinx documentation builder.\n#\n# For the full list of built-in configuration values, see t"
},
{
"path": "docs/index.rst",
"chars": 460,
"preview": ".. fades documentation master file, created by\n sphinx-quickstart on Sat Dec 26 19:29:13 2015.\n You can adapt this f"
},
{
"path": "docs/pydepmanag.rst",
"chars": 2558,
"preview": "Python and the Management of Dependencies\n=========================================\n\nPython has an extensive standard li"
},
{
"path": "docs/readme.rst",
"chars": 27,
"preview": ".. include:: ../README.rst\n"
},
{
"path": "docs/requirements.txt",
"chars": 17,
"preview": "sphinx_rtd_theme\n"
},
{
"path": "fades/__init__.py",
"chars": 929,
"preview": "# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/__main__.py",
"chars": 180,
"preview": "\"\"\"Init file to allow execution of fades as a module.\"\"\"\n\nimport sys\n\nfrom fades import main, FadesError\n\ntry:\n rc = "
},
{
"path": "fades/_version.py",
"chars": 113,
"preview": "\"\"\"Holder of the fades version number.\"\"\"\n\nVERSION = (9, 0, 2)\n__version__ = '.'.join([str(x) for x in VERSION])\n"
},
{
"path": "fades/cache.py",
"chars": 8739,
"preview": "# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/envbuilder.py",
"chars": 10527,
"preview": "# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/file_options.py",
"chars": 2608,
"preview": "# Copyright 2016-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/helpers.py",
"chars": 13731,
"preview": "# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/logger.py",
"chars": 3056,
"preview": "# Copyright 2014-2018 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/main.py",
"chars": 20574,
"preview": "# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/multiplatform.py",
"chars": 1661,
"preview": "# Copyright 2016 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "fades/parsing.py",
"chars": 9683,
"preview": "# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/pipmanager.py",
"chars": 5256,
"preview": "# Copyright 2014-2020 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "fades/pkgnamesdb.py",
"chars": 1133,
"preview": "# Copyright 2015-2020 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "man/fades.1",
"chars": 8399,
"preview": ".TH FADES 1\n.SH NAME\nfades - A system that automatically handles the virtualenvs in the cases normally found when writin"
},
{
"path": "pkg/debian/changelog",
"chars": 160,
"preview": "fades (4-1) unstable; urgency=medium\n\n * Initial release. (Closes: #802806)\n\n -- Facundo Batista <facundo@taniquetil.c"
},
{
"path": "pkg/debian/compat",
"chars": 2,
"preview": "9\n"
},
{
"path": "pkg/debian/control",
"chars": 837,
"preview": "Source: fades\nSection: python\nPriority: extra\nBuild-Depends: debhelper (>= 9),\n dh-python,\n "
},
{
"path": "pkg/debian/copyright",
"chars": 426,
"preview": "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\nUpstream-Name: fades\nUpstream-Contact: Facundo"
},
{
"path": "pkg/debian/rules",
"chars": 249,
"preview": "#!/usr/bin/make -f\n\nexport PYBUILD_NAME=fades\n\n# Debian doesn't have dh-translations.\n%:\nifneq ($(shell dh -l | grep -xF"
},
{
"path": "pkg/debian/watch",
"chars": 135,
"preview": "version=3\nopts=uversionmangle=s/(rc|a|b|c)/~$1/ \\\nhttps://pypi.debian.net/fades/fades-(.+)\\.(?:zip|tgz|tbz|txz|(?:tar\\.("
},
{
"path": "pkg/snap/snapcraft.yaml",
"chars": 1895,
"preview": "name: fades\nsummary: system for automatically handling virtual environments\ndescription: |\n fades is a system that au"
},
{
"path": "press.txt",
"chars": 6195,
"preview": "Hello all,\n\nWe're glad to announce the release of fades 9.0.\n\nfades is a system that automatically handles the virtualen"
},
{
"path": "requirements.txt",
"chars": 67,
"preview": "flake8\nlogassert\npackaging\npydocstyle\npytest\npyuca\npyxdg\nrst2html5\n"
},
{
"path": "resources/gifs/gifs.rst",
"chars": 1746,
"preview": "Several small gifs showing specific fades functionality\n-------------------------------------------------------\n\nHow to "
},
{
"path": "resources/notes.txt",
"chars": 70,
"preview": "wmctrl -r :ACTIVE: -e 0,424,52,880,495\n\n\n 880 x 482 !!\n\n\nkazam\n"
},
{
"path": "setup.py",
"chars": 5500,
"preview": "#!/usr/bin/env python3\n\n# Copyright 2014-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you c"
},
{
"path": "test",
"chars": 421,
"preview": "#!/bin/bash\n#\n# Copyright 2014-2018 Facundo Batista, Nicolás Demarchi\n\nset -eu\n\nif [ $# -ne 0 ]; then\n TARGET_TESTS=\""
},
{
"path": "testdev",
"chars": 212,
"preview": "#!/bin/bash\n#\n# Copyright 2014-2016 Facundo Batista, Nicolás Demarchi\n\nset -eu\n\nif [ $# -ne 0 ]; then\n TARGET_TESTS=\""
},
{
"path": "testdev.bat",
"chars": 214,
"preview": "@echo off\n\nrem Copyright 2018 Facundo Batista, Nicolás Demarchi\n\nif not [%*] == [] (\n set TARGET_TESTS=\"%*\"\n) else (\n"
},
{
"path": "tests/__init__.py",
"chars": 2000,
"preview": "# Copyright 2017-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/conftest.py",
"chars": 1502,
"preview": "# Copyright 2019-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/examples/pypi_get_version_fail.json",
"chars": 31,
"preview": "{\"MALFORMED\": {\"json\": \"1.0\"}}\n"
},
{
"path": "tests/examples/pypi_get_version_ok.json",
"chars": 102350,
"preview": "{\n \"info\": {\n \"maintainer\": null,\n \"docs_url\": null,\n \"requires_python\": null,\n \"maintain"
},
{
"path": "tests/integtest.py",
"chars": 1126,
"preview": "# Copyright 2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_cache/__init__.py",
"chars": 967,
"preview": "# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_cache/conftest.py",
"chars": 1063,
"preview": "# Copyright 2015-2019 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_cache/test_caches.py",
"chars": 2421,
"preview": "# Copyright 2015-2022 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_cache/test_comparisons.py",
"chars": 4062,
"preview": "# Copyright 2015-2019 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_cache/test_remove.py",
"chars": 3632,
"preview": "# Copyright 2015-2019 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_cache/test_selection.py",
"chars": 12235,
"preview": "# Copyright 2015-2019 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_cache/test_store.py",
"chars": 1873,
"preview": "# Copyright 2015-2019 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_envbuilder.py",
"chars": 16440,
"preview": "# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_file_options.py",
"chars": 6426,
"preview": "# Copyright 2016 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_files/fades_as_part_of_other_word.py",
"chars": 187,
"preview": "import logging\n\nlogger = logging.getLogger(__name__)\n\n\ndef def_function():\n \"\"\"\n the fades sweetly flower.\n foo"
},
{
"path": "tests/test_files/no_req.py",
"chars": 605,
"preview": "# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_files/req_all.py",
"chars": 847,
"preview": "# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_files/req_class.py",
"chars": 650,
"preview": "# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_files/req_def.py",
"chars": 182,
"preview": "import logging\n\nlogger = logging.getLogger(__name__)\n\n\ndef def_function():\n \"\"\"Something.\n requirements for fades:"
},
{
"path": "tests/test_files/req_mixed_backends.py",
"chars": 96,
"preview": "\"\"\"\nBleh, groovy.\n\nfades:\n foo\n pypi::bar\n git+http://whatever\n vcs::anotherurl\n\"\"\"\n"
},
{
"path": "tests/test_files/req_module.py",
"chars": 620,
"preview": "# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_files/req_module_2.py",
"chars": 620,
"preview": "# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_files/req_module_3.py",
"chars": 398,
"preview": "# Copyright 2014 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_helpers.py",
"chars": 25498,
"preview": "# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_infra.py",
"chars": 2839,
"preview": "# Copyright 2017-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_logger.py",
"chars": 1446,
"preview": "# Copyright 2018 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_main.py",
"chars": 12368,
"preview": "# Copyright 2015-2024 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_multiplatform.py",
"chars": 2994,
"preview": "# Copyright 2016 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
},
{
"path": "tests/test_parsing/test_docstrings.py",
"chars": 2169,
"preview": "\"\"\"Check the docstring parsing.\"\"\"\nimport io\n\nfrom fades import parsing, REPO_PYPI, REPO_VCS\n\nfrom tests import get_reqs"
},
{
"path": "tests/test_parsing/test_file.py",
"chars": 12176,
"preview": "\"\"\"Check the imports parsing.\"\"\"\nimport io\n\nfrom logassert import Exact\n\nfrom fades import parsing, REPO_PYPI, REPO_VCS\n"
},
{
"path": "tests/test_parsing/test_file_reqs.py",
"chars": 2047,
"preview": "\"\"\"Check the requirements parsing from a reqs.txt file.\"\"\"\nimport os\n\nfrom fades import parsing, REPO_PYPI\n\nfrom tests i"
},
{
"path": "tests/test_parsing/test_manual.py",
"chars": 1535,
"preview": "\"\"\"Tests for the check of the manual parsing.\"\"\"\nfrom fades import parsing, REPO_PYPI, REPO_VCS\nfrom tests import get_re"
},
{
"path": "tests/test_parsing/test_reqs.py",
"chars": 3030,
"preview": "\"\"\"Check the requirements parsing.\"\"\"\nimport io\n\nfrom logassert import Multiple\n\nfrom fades import parsing, REPO_PYPI, R"
},
{
"path": "tests/test_parsing/test_vcs_dependency.py",
"chars": 808,
"preview": "\"\"\"Check the VCSDependency.\"\"\"\nfrom fades import parsing\n\n\ndef test_string_representation():\n \"\"\"This is particularly"
},
{
"path": "tests/test_pipmanager.py",
"chars": 7005,
"preview": "# Copyright 2015-2022 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/o"
},
{
"path": "tests/test_pkgnamesdb.py",
"chars": 958,
"preview": "# Copyright 2020 Facundo Batista, Nicolás Demarchi\n#\n# This program is free software: you can redistribute it and/or mod"
}
]
// ... and 3 more files (download for full content)
About this extraction
This page contains the full source code of the PyAr/fades GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 88 files (452.7 KB), approximately 114.9k tokens, and a symbol index with 427 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.