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

Python pip setup.cfg #562

Open
adamchainz opened this issue May 25, 2020 · 2 comments
Open

Python pip setup.cfg #562

adamchainz opened this issue May 25, 2020 · 2 comments

Comments

@adamchainz
Copy link

@adamchainz adamchainz commented May 25, 2020

I'm not sure this is exactly the right place to report, but it seems logical.

Python's packaging ecosystem has long used a setup.py file for package metadata. However, since 2016, it has been possible to place all the metadata instead in the setup.cfg file, avoiding the need for executable Python code. (docs).

Although metadata has been supported since 2016, it has seen slow adoption. For example, Django has moved to it recently in 3.1 (still in alpha): django/django@85efc14 .

It seems at the moment, semantic only attempts to parse metadata from setup.py files:

strat <- case find (\b -> blobPath b == (projectRootDir project Path.</> Path.relFile "setup.py")) (projectBlobs project) of

This is where I'm not so sure if this is the origin for the actual observed issue. The problem I'm chasing is that GitHub security alerts don't propagate from source repos using setup.cfg for their metadata, only those using setup.py. I'm guessing this is because they're parsed with semantic.

As reported to me by @davidism, maintainer of some popular Python projects: django/asgiref#161 (comment)

@patrickt
Copy link
Contributor

@patrickt patrickt commented May 25, 2020

We’re currently overhauling how Semantic.Graph works, so this code path will probably perish, but let’s keep this open to make sure we account for it during Python stack-graphing.

@davidism
Copy link

@davidism davidism commented May 25, 2020

To add a bit more information, I need to leave a minimal setup.py with name and install_requires in order for GitHub's dependency graph feature to work. You can see this in the various Pallets projects, such as Flask: https://github.com/pallets/flask/blob/330a3e3ddba712def955e7a2ccee92a205dfb656/setup.py

setup(
    name="Flask",
    install_requires=[
        "Werkzeug>=0.15",
        "Jinja2>=2.10.1",
        "itsdangerous>=0.24",
        "click>=5.1",
    ],
    extras_require={"dotenv": ["python-dotenv"]},
)

The equivalent sections in setup.cfg would be:

[metadata]
name = Flask

[options]
install_requires =
    Werkzeug>=0.15
    Jinja2>=2.10.1
    itsdangerous>=0.24
    click>=5.1

[options.extras_require]
dotenv =
    python-dotenv

The dependency graph doesn't understand extras_require and setup_requires right now, but I figured I might as well include it since extras layout is different.

jdufresne added a commit to jdufresne/asgiref that referenced this issue May 30, 2020
Use a declarative syntax to avoid mixing code and configuration.
Simplifies handling of long description and version by reducing some
boilerplate.

For details on this setuptools feature, see:
https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files

Django made the same move to setup.cfg in:
django/django@85efc14

The name argument remains in setup.py for compatibility with GitHub's
dependency/security features. See:
github/semantic#562

Additionally:

- Add 'Programming Language :: Python :: 3 :: Only' trove classifier.
- Remove unnecessary long_description_content_type from setup as
  reStructuredText is the default.
- Use HTTPs for GitHub URL in setup.
- Add project URLs to setup.
jdufresne added a commit to jdufresne/asgiref that referenced this issue May 30, 2020
Use a declarative syntax to avoid mixing code and configuration.
Simplifies handling of long description and version by reducing some
boilerplate.

For details on this setuptools feature, see:
https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files

Django made the same move to setup.cfg in:
django/django@85efc14

The name argument remains in setup.py for compatibility with GitHub's
dependency/security features. See:
github/semantic#562

Additionally:

- Add 'Programming Language :: Python :: 3 :: Only' trove classifier.
- Remove unnecessary long_description_content_type from setup as
  reStructuredText is the default.
- Use HTTPs for GitHub URL in setup.
- Add project URLs to setup.
andrewgodwin pushed a commit to django/asgiref that referenced this issue May 30, 2020
Use a declarative syntax to avoid mixing code and configuration.
Simplifies handling of long description and version by reducing some
boilerplate.

For details on this setuptools feature, see:
https://setuptools.readthedocs.io/en/latest/setuptools.html#configuring-setup-using-setup-cfg-files

Django made the same move to setup.cfg in:
django/django@85efc14

The name argument remains in setup.py for compatibility with GitHub's
dependency/security features. See:
github/semantic#562

Additionally:

- Add 'Programming Language :: Python :: 3 :: Only' trove classifier.
- Remove unnecessary long_description_content_type from setup as
  reStructuredText is the default.
- Use HTTPs for GitHub URL in setup.
- Add project URLs to setup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants