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

pip-compile crashes on a setup.py that contains entry_points #572

Closed
daisylb opened this issue Oct 3, 2017 · 4 comments
Closed

pip-compile crashes on a setup.py that contains entry_points #572

daisylb opened this issue Oct 3, 2017 · 4 comments
Labels
awaiting response Awaiting response from a contributor support User support

Comments

@daisylb
Copy link

daisylb commented Oct 3, 2017

If my setup.py contains entry_points, I get an error.

Environment Versions
  1. OS Type: macOS 10.12.6
  2. Python version: Python 3.6.2
  3. pip version: pip 9.0.1
  4. pip-tools version: pip-compile, version 1.10.1
Steps to replicate
  1. Create a new directory
  2. Add a setup.py with the following content
  3. Run pip-compile
from setuptools import find_packages, setup

setup(
    name='myproject',
    description='My awesome project',
    url='https://example.com/',
    author='Adam Brenecki',
    author_email='adam@brenecki.id.au',
    license='Proprietary',
    setup_requires=["setuptools_scm>=1.11.1"],
    use_scm_version=True,
    packages=find_packages(),
    include_package_data=True,
    install_requires=[
        'dj-database-url',
        'django-csp',
        'django-form-utils',
        'django-redis',
        'django-stronghold',
        'django-widget-tweaks',
        'Django[argon2]',
        'psycopg2',
        'python-decouple',
        'raven',
        'waitress',
        'django-webpack-loader',
    ],
    extras_require={
        'dev': [
            'pre-commit',
            'prospector',
            'pytest',
            'pytest-django',
        ]
    },
    entry_points={
        'console_scripts': ['sl-admin=sl-admin.manage:main'],
    }
)
Expected result

A requirements.txt is produced. This is the result I get with the exact same setup.py but without entry_points.

Actual result
Traceback (most recent call last):
  File "/Users/adam/.pyenv/versions/3.6.2/bin/pip-compile", line 11, in <module>
    sys.exit(cli())
  File "/Users/adam/.local/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/adam/.local/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/adam/.local/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/adam/.local/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/adam/.pyenv/versions/3.6.2/lib/python3.6/site-packages/piptools/scripts/compile.py", line 167, in cli
    dist = run_setup(src_file)
  File "/Users/adam/.pyenv/versions/3.6.2/lib/python3.6/distutils/core.py", line 227, in run_setup
    script_name)
RuntimeError: 'distutils.core.setup()' was never called -- perhaps 'setup.py' is not a Distutils setup script?
@vphilippon
Copy link
Member

Out of curiosity, could you try this and see if the problem occurs:
echo "-e ." | pip-compile -o requirements.txt - (don't forget the - at the end, it's required to read from stdin)

In short, this will do a pip-compile of -e . instead of parsing the setup.py directly.
If it works, then the issue is likely with the way we handle the setup.py parsing, which is my guess.
It would also possibly give you a workaround until we fix it.

abravalheri added a commit to abravalheri/dummy-pipenv-example-for-pyscaffold that referenced this issue Jun 18, 2018
We have to use a `requirements.in` just to proxy `setup.cfg`, since an
error occurs when we rely on the implicit dependency (ref:
jazzband/pip-tools#572).

This way abstracted requirements are expressed via `setup.cfg` while
concrete dependencies are expressed via `requirements.txt`.

Basic workflow:
- Add abstract dependencies to `setup.cfg`
- Proxy `setup.cfg` using `requirements.in`
- Write dev dependencies to `dev-requirements.in`
- Use `pip-compile --output-file (dev-)requirements.txt (dev-)requirements.in`
  to compile the concrete dependencies
- Add the `requirements.{in,txt}` files to source control for repeatable
  installations: https://caremad.io/posts/2013/07/setup-vs-requirement/
- Use `pip-sync dev-requirements.txt requirements.txt` to install the
  packages into the current virtualenv
- Run commands normally inside the current virtualenv (e.g. `tox`)
- Don't expose test requirements directly to pip-tools. Instead, just
  rely on tox/pytest-runner to install them inside the test venv.
@abravalheri
Copy link
Contributor

@vphilippon, I was facing the same problem in this repository (pip-tools branch). Then I added a requirements.in file with -e . as suggested by you, and things worked fine.

So your guess seem to be consistent...

(thank you very much for the information and workaround!)

@atugushev
Copy link
Member

atugushev commented Sep 19, 2019

It looks like distutils.core.run_setup fails silently on exec(), so I've printed the error manually and got this:

 error in myproject setup command: ("EntryPoint must be in 'name=module:attrs [extras]' format", 'sl-admin=sl-admin.manage:main')

You've got an error in the module path in the entry points: change sl-admin.manage:main to sl_admin.manage:main and it'll work.

@atugushev atugushev added the support User support label Sep 19, 2019
@atugushev atugushev added the awaiting response Awaiting response from a contributor label Oct 17, 2019
@atugushev
Copy link
Member

I'll close this based on the above, but please let us know if it doesn't resolve your issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Awaiting response from a contributor support User support
Projects
None yet
Development

No branches or pull requests

4 participants