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

requirements declared in `setup.cfg` and using environment makers are not correctly handled #1105

Closed
benoit-pierre opened this Issue Jul 26, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@benoit-pierre
Member

benoit-pierre commented Jul 26, 2017

> >setup.py <<\EOF
from setuptools import setup
setup(name='foo', install_requires='barbazquux; python_version < "3.4"')
EOF
> >setup.cfg <<\EOF
EOF
> python setup.py -q egg_info && cat foo.egg-info/requires.txt

[:python_version < "3.4"]
barbazquux
> >setup.py <<\EOF
from setuptools import setup
setup(name='foo')
EOF
> >setup.cfg <<\EOF
[options]
install_requires =
        barbazquux; python_version < "3.4"
EOF
> python setup.py -q egg_info && cat foo.egg-info/requires.txt
barbazquux; python_version < "3.4"

This is because parsing config files (like setup.cfg) is done after a Distribution initialization. Other issue stemming from this: #1054.

@benoit-pierre

This comment has been minimized.

Member

benoit-pierre commented Jul 26, 2017

 setuptools/dist.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git i/setuptools/dist.py w/setuptools/dist.py
index dfe700bd..0ba82f06 100644
--- i/setuptools/dist.py
+++ w/setuptools/dist.py
@@ -349,14 +349,14 @@ class Distribution(Distribution_parse_config_files, _Distribution):
                     "setuptools, pip, and PyPI. Please see PEP 440 for more "
                     "details." % self.metadata.version
                 )
-        if getattr(self, 'python_requires', None):
-            self.metadata.python_requires = self.python_requires
         self._finalize_requires()
 
     def _finalize_requires(self):
         """
         Fix environment markers in `install_requires` and `extras_require`.
         """
+        if getattr(self, 'python_requires', None):
+            self.metadata.python_requires = self.python_requires
         self._convert_extras_requirements()
         self._move_install_requirements_markers()
 
@@ -424,8 +424,7 @@ class Distribution(Distribution_parse_config_files, _Distribution):
         _Distribution.parse_config_files(self, filenames=filenames)
 
         parse_configuration(self, self.command_options)
-        if getattr(self, 'python_requires', None):
-            self.metadata.python_requires = self.python_requires
+        self._finalize_requires()
 
     def parse_command_line(self):
         """Process features after parsing command line options"""

@benoit-pierre benoit-pierre changed the title from parsing config files (like `setup.cfg`) is done after a `Distribution` initialization to requirements declared `setup.cfg` and using environment makers are not correctly handled Aug 1, 2017

@benoit-pierre benoit-pierre changed the title from requirements declared `setup.cfg` and using environment makers are not correctly handled to requirements declared in `setup.cfg` and using environment makers are not correctly handled Aug 1, 2017

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