Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setuptools doesn't install licenses #357

Closed
ghost opened this issue Mar 4, 2015 · 13 comments
Closed

setuptools doesn't install licenses #357

ghost opened this issue Mar 4, 2015 · 13 comments

Comments

@ghost
Copy link

ghost commented Mar 4, 2015

Originally reported by: notting (Bitbucket: notting, GitHub: notting)


  1. Most python software is licensed under MIT, BSD, or similar licenses
  2. These licenses require shipping a copy of the license with distributions of the software.

Ergo, setuptools should add the LICENSE or COPYING file to the egginfo/distinfo directory by default, so licenses get distributed automatically.


@jakirkham
Copy link
Contributor

Would it be possible to have a license_file keyword argument for setup? This file (or directory or list if multiple) could then just get copied over.

@agronholm
Copy link
Contributor

The license file already comes included in the sdist (barring any mishaps by the author). As for wheels, you can add license_file = LICENSE option in the [metadata] section in setup.cfg. This feature has not been documented but I will rectify that once I overhaul wheel's documentation.

@anntzer
Copy link

anntzer commented Oct 1, 2017

It appears that unless the license file is explicitly mentioned in the manifest, it will NOT be included (just tested with setuptools 36.5.0 / distutils from Py 3.6). This is also the behavior documented in https://docs.python.org/3.6/distutils/sourcedist.html#specifying-the-files-to-distribute.

But as you point out yourself, it is easy enough for setuptools to find that information: it should read it from setup.cfg's metadata.license_file, to avoid having to duplicate it.

@pganssle pganssle added Needs Triage Issues that need to be evaluated for severity and status. Needs Implementation Issues that are ready to be implemented. help wanted good first issue and removed Needs Triage Issues that need to be evaluated for severity and status. labels Oct 19, 2018
@pganssle
Copy link
Member

I think this is a reasonable enhancement. The new behavior should be that python setup.py sdist should include the license file if license_file is included in setup.cfg unless it is explicitly excluded in MANIFEST.in.

There's a case to be made for including anything called LICENSE or LICENSE.txt or LICENSE.md by default, as well, but I think that needs further discussion.

@dtaneli
Copy link
Contributor

dtaneli commented Oct 27, 2018

Working on this as part of PyPA Sprint Weekend at Bloomberg (2018)

dtaneli added a commit to dtaneli/setuptools that referenced this issue Oct 27, 2018
Addressing pypa#357

`python setup.py sdist` now includes the license file if `license_file`
is included in `setup.cfg` unless it is explicitly excluded in `MANIFEST.in`.

Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com>
dtaneli added a commit to dtaneli/setuptools that referenced this issue Oct 27, 2018
Addressing pypa#357

`python setup.py sdist` now includes the license file if `license_file`
is included in `setup.cfg` unless it is explicitly excluded in `MANIFEST.in`.

Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com>
dtaneli added a commit to dtaneli/setuptools that referenced this issue Oct 27, 2018
Addressing pypa#357

`python setup.py sdist` now includes the license file if `license_file`
is included in `setup.cfg` unless it is explicitly excluded in `MANIFEST.in`.

Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com>
dtaneli added a commit to dtaneli/setuptools that referenced this issue Oct 27, 2018
Addressing pypa#357

`python setup.py sdist` now includes the license file if `license_file`
is included in `setup.cfg` unless it is explicitly excluded in `MANIFEST.in`.

Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com>
dtaneli added a commit to dtaneli/setuptools that referenced this issue Oct 27, 2018
Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com>
mfripp added a commit to switch-model/staged-recipes that referenced this issue Jun 20, 2019
Eventually, we should get setuptools to include this in the .tar.gz file 
(see pypa/setuptools#357), and then we won't 
need to include it here.
kastman pushed a commit to kastman/staged-recipes that referenced this issue Jun 25, 2019
* add pip

* fix

* some gl fixes

* fix

* added trio-asyncio [skip appveyor]

* vendor -> vend

* fix url

* Update recipes/pylbm/meta.yaml

Co-Authored-By: Chris Burr <chrisburr@users.noreply.github.com>

* Update recipes/pylbm/meta.yaml

Co-Authored-By: Chris Burr <chrisburr@users.noreply.github.com>

* python-backtrace

* rm setuptools dep

* add license

* add LICENSE.txt to recipe folder

* better deps

* Removed recipes (atlite, python-backtrace) after converting into feedstocks. [ci skip]

* Removed recipe (pylbm) after converting into feedstock. [ci skip]

* Removed recipe (libhomfly) after converting into feedstock. [ci skip]

* fix stuff

* fixed meta

* Add libbraiding

* xontrib-readable-traceback

* add license

* Removed recipe (trio-asyncio) after converting into feedstock. [ci skip]

* Add C++ compiler

* trio-aiohttp

* Removed recipe (libbraiding) after converting into feedstock. [ci skip]

* fix test

* more fixes

* more fixes

* libxkbcommon

* added build

* forgot sha256

* another couple of thinks

* don't run pytest

The tests are not in the dist. They do pass in GitLab CI for this release:

https://gitlab.com/deltares/imod/imod-python/pipelines/57198406

* python req

* more deps

* more build

* add pkg-config

* cflags

* -lxcb

* xontrib-ssh-agent

* Added recipe for pycomlink based on example

* Initial work setting up GPI framework

* Removed recipe (xontrib-ssh-agent) after converting into feedstock. [ci skip]

* Fixed wrong sha256 has of source tab ball

Strangely the source tar ball downloaded via "curl -O URL" is different
(wrong in this case) from the hash of the file that is downloaded
via the browser. Or maybe I did something wrong...

* rm packages

* typo in license

Co-Authored-By: jakirkham <jakirkham@gmail.com>

* removed pip install flags

* Removed recipes (pycomlink, trio-aiohttp) after converting into feedstocks. [ci skip]

* Regenerate with upstreamed RPM skeleton fixes

* add yum_requirements.txt

* Removed recipe (libxkbcommon) after converting into feedstock. [ci skip]

* quart-trio

* added libxkbcommon

* xorg-libxinerama

* Removed recipe (imutils) after converting into feedstock. [ci skip]

* Removed recipe (quart-trio) after converting into feedstock. [ci skip]

* some minor fixes

* harfbuzz isn't built correctly to support mac here

* Add xrviz

* correct deps

* Removed recipe (imod) after converting into feedstock. [ci skip]

* Removed recipe (deepxde) after converting into feedstock. [ci skip]

* Removed recipe (kitty) after converting into feedstock. [ci skip]

* try again

* use release

* xkeyboard-config

* google-pasta

* remove extra about/home entry

* Removed recipe (google-pasta) after converting into feedstock. [ci skip]

* add rio-cogeo and supermercado

* don't build py<3.3

* remove rasterio from build

* Removed recipes (rio-cogeo, supermercado) after converting into feedstocks. [ci skip]

* add nbgitpuller

* Removed recipe (nbgitpuller) after converting into feedstock. [ci skip]

* Revert "Initial work setting up GPI framework"

This reverts commit d095a7d.

* Add several aio-libs projects

* aiohttp_jinja2 -> aiohttp-jinja2

* more underscore fixes

* Removed recipes (aiohttp-debugtoolbar, aiohttp-jinja2, aiohttp-security, aiohttp-session, aiomcache, aioredis, janus) after converting into feedstocks. [ci skip]

* Adding recipe for urbansim_defaults

* Add switch-model recipe

* Update requirements

* Fix test/source_files section

* Removed recipe (urbansim_defaults) after converting into feedstock. [ci skip]

* Recipe for coq-jupyter

* Add newline at end of meta.yaml

* Adding recipe for PyCRC

* Fix imports

* Removed recipe (pycrc) after converting into feedstock. [ci skip]

* Create pypd meta.yaml file

* Add pypd LICENSE

* Removed recipe (pypd) after converting into feedstock. [ci skip]

* Added GPI build recipe

* Removed python dependency in run

* Reordered sections in meta.yaml

* Changed XORG packages to conda-forge deps

* Don't use xvfb for testing on osx

* Fix case on selector for skipping windows

* windse recipe test 1

* Adding recipe for pyFirmata

* Removed recipe (coq-jupyter) after converting into feedstock. [ci skip]

* Use underscores in package name and pypi download path

* adding meta.yml for first go at recipe

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* try without dash in name

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* doh, needs to be yaml

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* Fix full license name

* Rename directory to switch_model, not switch-model

* missing yaml

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* add to other list

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* oh, its pyyaml

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* Don't build for Python 3

* Add license file

Eventually, we should get setuptools to include this in the .tar.gz file 
(see pypa/setuptools#357), and then we won't 
need to include it here.

* first successful build using .circleci/run_docker_build.sh

* removed empty lines at the end of windse/meta.yaml

* whoops, removed one line too many

* third times a charm?

* missing spython

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* skipping windows

* Removed recipe (pyfirmata) after converting into feedstock. [ci skip]

* Removed recipe (gpi-framework) after converting into feedstock. [ci skip]

* Update recipes/windse/meta.yaml

Co-Authored-By: Uwe L. Korn <xhochy@users.noreply.github.com>

* Add recipe for seekpath

* Use tests and license from .tar file (starting with 2.0.3.1)

* Remove `noarch` tag to avoid building for Python 3

* Removed recipe (seekpath) after converting into feedstock. [ci skip]

* Enforce python < 3 without using #skip

* correct Python version identifier

* Update sha256 for .tar.gz file

* New meta.yaml for pyeviews

* Add more commands to diagnose import error in tests.

* Another diagnostic command.

* Keep a copy of switch_model for run_tests.py

* Add switch entry point

* Update for Switch 2.0.4 (Python 3 compatible)

* Removed recipe (windse) after converting into feedstock. [ci skip]

* Add recipes for http3 and requests-async

* Fix licenses

* Removed recipe (ifcopenshell) after converting into feedstock. [ci skip]

* Removed recipes (http3, requests-async) after converting into feedstocks. [ci skip]

* Removed recipe (switch_model) after converting into feedstock. [ci skip]

* testing updated version

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* Removed recipe (xrviz) after converting into feedstock. [ci skip]

* dont support windows

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* remove redundancy

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* add sat-stac

* remove pyaml and spython

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* Removed recipe (sat-stac) after converting into feedstock. [ci skip]

* add sat-search

* Update recipes/xontrib-readable-traceback/meta.yaml

Co-Authored-By: Chris Burr <chrisburr@users.noreply.github.com>

* Update recipes/xontrib-readable-traceback/meta.yaml

Co-Authored-By: Chris Burr <chrisburr@users.noreply.github.com>

* python-backtrace

* Removed recipe (sat-search) after converting into feedstock. [ci skip]

* Update recipes/singularity-compose/meta.yaml

Co-Authored-By: Chris Burr <chrisburr@users.noreply.github.com>

* Removed recipe (xontrib-readable-traceback) after converting into feedstock. [ci skip]

* Removed recipe (singularity-compose) after converting into feedstock. [ci skip]

* Render with rpm2cpio removed

This change has already landed in conda-build. So here we are just
regenerating the conda-build recipe with this change.

* Comment out tests to workaround a conda-build bug

* added perl-xml-parser req

* New meta.yaml for pyeviews

* Delete meta.yaml

* libxkbfile

* Removed recipe (libxkbfile) after converting into feedstock. [ci skip]

* added libxslt dep

* pkg-config

* Updated recipe maintainer

* Updated run requirements

* Add myself as a maintainer

* move deps to build env

* Removed recipe (xkeyboard-config) after converting into feedstock. [ci skip]

* Initial recipe for sphinx_gmt

Missing the SHA hash and doesn't list GMT as a dependency.

* Add hash of the pypi tarball

* Remove noarch

* Add recipe for httpcore

This is a little confusing, because the package has changed name to http3,
but older versions were released as httpcore.

httpcore is a dependency to build request-async:

conda-forge/requests-async-feedstock#2 (comment)

* Removed recipe (httpcore) after converting into feedstock. [ci skip]

* Add bespon and codebraid

* adding deid recipe

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* typo

Signed-off-by: Vanessa Sochat <vsochat@stanford.edu>

* Add codebraid python version restriction

* Removed recipes (codebraid, deid) after converting into feedstocks. [ci skip]

* Removed recipe (bespon) after converting into feedstock. [ci skip]

* Add LICENSE

* add recipe for pyreportjasper

* Added license file name on meta.yaml

* Require `openssl` version `1.1.1a`                 [skip ci]

Appears we are not able to install some dependencies without `openssl`
version `1.1.1a` installed (`1.1.1b` is already included). This tries
forcing `openssl` to version `1.1.1a` to fix the issue.

* Force `openssl` to `1.1.1a` first                  [ci skip]

* Drop `openssl` install hacks                       [ci skip]

These don't seem to work as expected either despite getting the
seemingly required version of `openssl` installed. So just go ahead and
drop them.

* Add noarch back

* Add recipe for pyjson5.

* Add entry point metadata.

* Removed recipes (libnl-cos6-x86_64, pyeviews, sphinx_gmt, vdom) after converting into feedstocks. [ci skip]

* MSAL package

* Rerender with latest conda-smithy

* PsychoPy 3.x, add entrypoint, remove lots of test imports

* Update recipe
@EvgenKo423
Copy link

I want to note that the license files only get included in a source distribution, but they are NOT installed with the package! On the other hand, when you build a wheel the license files are copied into the .dist-info folder AND get installed with the package as well. It also looks like the behavior originally requested in this issue, as the license files should be distributed with every copy of the software.

@pganssle
Copy link
Member

pganssle commented Mar 2, 2021

@EvgenKo423 Installation via setup.py install is not, as far as I know, supported. You should build a wheel and install that, or use a front-end that does it for you, in which case the problem is solved, no?

@EvgenKo423
Copy link

No. Many packages on PyPI only provide a source distribution. I've tried building a source distribution of my own package with a license_files option and installing it via pip install -U path\to\sdist.tar.gz and the license file was just dropped with the rest of the sources after installation.

It's clearly not a pip's job to deal with installation details, it just calls the setup.py install command you mentioned in a bizarre way.

@jakirkham
Copy link
Contributor

It's possible to build a wheel from a sdist. Setuptools will package licenses in the sdist as long as the package author listed them in their setup.py or setup.cfg

@pganssle
Copy link
Member

pganssle commented Mar 2, 2021

@EvgenKo423 At this point the way it works in pip (and the supported workflow) is source (sdist, repo) → wheel → installation.

setuptools (or any other PEP 517 back-end) is responsible for the source → wheel portion and pip (or any other PEP 517 front-end) is responsible for the wheel → installation portion. If setuptools builds a wheel that contains a license file in such a way that PEP 517 front-ends don't include the license and you think that it should include the license, then that is a problem (and a separate issue to be raised). If the problem only occurs when you run setup.py install, then following the official guidance of "do not invoke setup.py install directly", there will be no problem.

Hope that clears up the confusion. I recognize that invoking setup.py has been the official guidance for a long time, but we've also been actively discouraging people from using setup.py install for at least as long as I've been involved in the project (3-4 years), and have not actively supported it for at least that long. I realize this comes as a surprise for many people, and the reason we haven't been raising big loud warnings about this is that the advice is a bit more nuanced than that and at the moment it's difficult to 1. differentiate between valid and invalid uses of setup.py install and 2. communicate to users exactly what they should do in each situation. If there were more resources devoted to this project we could likely make progress more rapidly on the blockers for these issues, but as it is doing so is difficult and things mostly work and people's workflows are mostly evolving towards doing the right thing anyway, so 🤷.

@jaraco
Copy link
Member

jaraco commented Mar 3, 2021

I've tried building a source distribution of my own package with a license_files option and installing it via pip install -U path\to\sdist.tar.gz and the license file was just dropped with the rest of the sources after installation.

I was unable to reproduce this behavior. To confirm, when installing a package from source using pip, the license file does get installed:

draft $ pip download --no-binary setuptools setuptools
Collecting setuptools
  Downloading setuptools-54.0.0.tar.gz (2.1 MB)
     |████████████████████████████████| 2.1 MB 1.8 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Saved ./setuptools-54.0.0.tar.gz
Successfully downloaded setuptools
draft $ pip-run -q ./setuptools-54.0.0.tar.gz -- -c "import importlib.metadata as md; print(md.distribution('setuptools').read_text('LICENSE')[:10])"
Copyright 

@jakirkham
Copy link
Contributor

@EvgenKo423 are you able to share a minimal reproducer? That might help point out what issues are being encountered and also help people here to provide more relevant advice for your use case 🙂

@EvgenKo423
Copy link

EvgenKo423 commented Mar 10, 2021

It all falls down to pip.
It only happens for setup.py-style sources without wheel installed. It should be happening with pyproject.toml without build-backend as per PEP 517, but the legacy build process is never invoked and I'm not sure if it's worth fixing as it has been there since at least pip==19.1.1 and would cause the issue I'm talking about for more people.


Installation via setup.py install is not, as far as I know, supported. You should build a wheel and install that, or use a front-end that does it for you, in which case the problem is solved, no?

Many users don't have your knowledge, I guess (but thanks for mentioning PEP 517).
pypa/pip#7709 and pypa/pip#8102 are the warnings you at PyPA were looking for, but it would be cool to have them since those were implemented in a first place, for those who are "in a tank".
If people have an existing Python install and just update the packages they will have no idea.

I currently have a pip==19.1.1, setuptools==43 @ Python 3.4 (don't ask why) and at this point the way it works for me is pip calling setup.py install and no mention of wheels whatsoever...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants