pip - `git+file` doesn't work with setup.cfg - python

I want to refer to dependency on the local filesystem in setup.cfg.
When I perform the following on the command line:
$ pip install git+file:///Users/Dev/Projects/dakia/#subdirectory=server
It works flawlessly, as described in the manual.
But if I specify the same in setup.cfg, like so:
[options]
dakia # git+file:///Users/Dev/Projects/dakia/#subdirectory=server
It fails with the following trace:
$ pip install -v -e .[dev]
Created temporary directory: /private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-ephem-wheel-cache-_4jzvm87
Created temporary directory: /private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck
Created requirements tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
Created temporary directory: /private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-install-gwp9chgb
Obtaining file:///Users/dev/Projects/dara/server
Added file:///Users/dev/Projects/dara/server to build tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
Running setup.py (path:/Users/dev/Projects/dara/server/setup.py) egg_info for package from file:///Users/dev/Projects/dara/server
Running command python setup.py egg_info
Traceback (most recent call last):
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in __init__
super(Requirement, self).__init__(requirement_string)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 101, in __init__
raise InvalidRequirement("Invalid URL given")
pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid URL given
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/dev/Projects/dara/server/setup.py", line 3, in <module>
setup()
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/__init__.py", line 137, in _install_setup_requires
dist.parse_config_files(ignore_option_errors=True)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/dist.py", line 701, in parse_config_files
self._finalize_requires()
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/dist.py", line 505, in _finalize_requires
self._move_install_requirements_markers()
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/setuptools/dist.py", line 544, in _move_install_requirements_markers
inst_reqs = list(pkg_resources.parse_requirements(spec_inst_reqs))
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3094, in parse_requirements
yield Requirement(line)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3103, in __init__
raise RequirementParseError(str(e))
pkg_resources.RequirementParseError: Invalid URL given
Cleaning up...
Removed file:///Users/dev/Projects/dara/server from build tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
Removed build tracker '/private/var/folders/p6/hs3yrbfn0tn96llkwpjl1q4h0000gn/T/pip-req-tracker-p7l48gck'
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Exception information:
Traceback (most recent call last):
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 153, in _main
status = self.run(options, args)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 382, in run
resolver.resolve(requirement_set)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 201, in resolve
self._resolve_one(requirement_set, req)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 365, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/legacy_resolve.py", line 295, in _get_abstract_dist_for
req, self.require_hashes, self.use_user_site, self.finder,
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 258, in prepare_editable_requirement
req, self.req_tracker, finder, self.build_isolation,
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 49, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/distributions/source/legacy.py", line 39, in prepare_distribution_metadata
self.req.prepare_metadata()
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 563, in prepare_metadata
self.metadata_directory = metadata_generator(self)
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/operations/generate_metadata.py", line 124, in _generate_metadata_legacy
command_desc='python setup.py egg_info',
File "/Users/dev/.pyenv/versions/anaconda3-2018.12/lib/python3.7/site-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess
raise InstallationError(exc_msg)
pip._internal.exceptions.InstallationError: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How do I make git+file urls work with setup.cfg?
Is that not possible? If so, why?
I don't think this post needs any more explanation, but SO won't let me post without a certain amount of text.

I don't think the sub-directory is supported.
Without a sub-directory then it could look something like this in your setup.cfg:
[options]
install_requires =
dakia
dependency_links =
git+file:///Users/Dev/Projects/dakia#egg=dakia
https://setuptools.readthedocs.io/en/latest/setuptools.html#dependencies-that-aren-t-in-pypi

Related

pip3 "build" will not install

when I try to install build with
sudo pip3 install build
the following error occurs:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 386, in run
use_user_site=options.use_user_site,
File "/usr/lib/python3/dist-packages/pip/_internal/req/__init__.py", line 49, in install_given_reqs
**kwargs
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 760, in install
use_user_site=use_user_site, pycompile=pycompile,
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 382, in move_wheel_files
warn_script_location=warn_script_location,
File "/usr/lib/python3/dist-packages/pip/_internal/wheel.py", line 215, in move_wheel_files
prefix=prefix,
File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 153, in distutils_scheme
d.parse_config_files()
File "/usr/lib/python3.7/distutils/dist.py", line 406, in parse_config_files
parser.read(filename)
File "/usr/lib/python3.7/configparser.py", line 696, in read
self._read(fp, filename)
File "/usr/lib/python3.7/configparser.py", line 1091, in _read
fpname, lineno)
configparser.DuplicateOptionError: While reading from 'setup.cfg' [line 10]: option 'url' in section 'metadata' already exists
while installing the collected packages. The install never completes; pip says it was never installed. I would greatly appreciate any help troubleshooting.
In the off chance anyone else has this problem, I found a temporary fix that will probably make python stop working in a few days.. I went to ln 1088-1090 of /usr/lib/python3.7/configparser.py and replaced that bit about raising an exception after an if statement with
while (self._strict and
(sectname, optname) in elements_added):
elements_added.pop()
This seemed to have fixed the problem, albeit not in the most pretty method, as installation pf build and use of sdist now works ok.

flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "D" due to invalid syntax upon install

I installed flake8 and flake8 docstrings globally using this:
sudo pip install flake8 flake8-docstrings
I tried to launch flake8 but i am faced with this error:
flake8 --version
Traceback (most recent call last):
File "/usr/local/bin/flake8", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/flake8/main/cli.py", line 18, in main
app.run(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 393, in run
self._run(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 380, in _run
self.initialize(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 363, in initialize
self.find_plugins()
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 199, in find_plugins
self.check_plugins.load_plugins()
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 410, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 297, in map
yield func(self.plugins[name], *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 408, in load_plugin
return plugin.load_plugin()
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 165, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "D" due to invalid syntax (checker.py, line 668).
I fixed it by downgrading pydocstyle to 3.0.0.
pip install pydocstyle=3.0.0

pip3 not installing packages

I enter the following line into terminal:
pip3 install numpy
this gives me:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 931, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout, stderr)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
Im thinking its a path issue but im not really sure.
This is a bug with the distro package vendored by pip. The bug has been solved but the latest version of pip uses and very old version of distro which doesn't have this bug fix applied.
For now, you can simply try to make the executable available in the path.

buildozer fails with pure python library (pint)

I'm trying to create a kivy application, and I'd like to include the pint library so I added pint to my buildozer.spec file:
requirements = kivy, hostpython2, pint
However, when running
buildozer android_new debug deploy
I get an error (see the log below). Everything works fine if I remove pint from the requirements, but I don't understand why this would cause errors since pint is a pure python module with no dependencies.
I don't understand the errors in the log file, but I did see that ImportError: cannot import name HTTPSHandler so I tried including HTTPSHandler in the requirements as well, but that didn't fix anything.
[INFO]: # Installing pure Python modules
[INFO]: The requirements (pint) don't have recipes, attempting to install them with pip
[INFO]: If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]: -> directory context /Users/me/Personal/grocery/.buildozer/android/platform/build/build
[INFO]: -> running virtualenv --python=python2.7 venv
('name is', None, <class 'pythonforandroid.recipes.six.SixRecipe'>)
('name is', 'jnius', <class 'pythonforandroid.recipes.pyjnius.PyjniusRecipe'>)
('name is', None, <class 'pythonforandroid.recipes.kivy.KivyRecipe'>)
('path is', '/Users/me/.buildozer/android/platform/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86/bin/:/Users/me/.buildozer/android/platform/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/:/Users/me/.buildozer/android/platform/android-ndk-r9c:/Users/me/.buildozer/android/platform/android-sdk-20/tools:/Users/me/.buildozer/android/platform/apache-ant-1.9.4/bin:/Users/me/anaconda/envs/grocery/bin:/Users/me/Downloads/google-cloud-sdk/bin:/Users/me/instantclient_11_2:/Users/me/anaconda/bin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/Application/sDocker.app/Contents/Resources/bin')
objs_paths are ['/Users/me/Personal/grocery/.buildozer/android/platform/build/build/bootstrap_builds/sdl2-python2/collated_objects']
Copying libraries
Traceback (most recent call last):
File "/Users/me/anaconda/envs/grocery/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Users/me/anaconda/envs/grocery/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/me/Personal/grocery/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 837, in <module>
main()
File "/Users/me/Personal/grocery/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 834, in main
ToolchainCL()
File "/Users/me/Personal/grocery/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 489, in __init__
getattr(self, args.subparser_name.replace('-', '_'))(args)
File "/Users/me/Personal/grocery/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 147, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/Users/me/Personal/grocery/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 190, in build_dist_from_args
build_recipes(build_order, python_modules, ctx)
File "pythonforandroid/build.py", line 582, in build_recipes
File "pythonforandroid/build.py", line 601, in run_pymodules_install
File "pythonforandroid/logger.py", line 173, in shprint
File "/Users/me/anaconda/envs/grocery/lib/python2.7/site-packages/sh.py", line 565, in next
self.wait()
File "/Users/me/anaconda/envs/grocery/lib/python2.7/site-packages/sh.py", line 500, in wait
self.handle_command_exit_code(exit_code)
File "/Users/me/anaconda/envs/grocery/lib/python2.7/site-packages/sh.py", line 516, in handle_command_exit_code
raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_1:
RAN: '/Users/me/anaconda/bin/virtualenv --python=python2.7 venv'
STDOUT:
Running virtualenv with interpreter /Users/me/anaconda/envs/grocery/bin/python2.7
New python executable in /Users/me/Personal/grocery/.buildozer/android/platform/build/build/venv/bin/python2.7
Not overwriting existing python script /Users/me/Personal/grocery/.buildozer/android/platform/build/build/venv/bin/python (you must use /Users/me/Personal/grocery/.buildozer/android/platform/build/build/venv/bin/python2.7)
Installing setuptools, pip, wheel...
Complete output from command /Users/joshuabrownin...d/venv/bin/python2.7 - setuptools pip wheel:
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/__init__.py", line 16, in <module>
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/vcs/subversion.py", line 9, in <module>
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/index.py", line 30, in <module>
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/wheel.py", line 39, in <module>
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 14, in <module>
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv_support/pip-8.1.2-py2.py3-none-any.whl/pip/_vendor/distlib/compat.py", line 31, in <module>
ImportError: cannot import name HTTPSHandler
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv.py", line 2327, in <module>
main()
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv.py", line 711, in main
symlink=options.symlink)
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv.py", line 944, in create_environment
download=download,
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv.py", line 900, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/Users/me/anaconda/lib/python2.7/site-packages/virtualenv-15.0.3-py2.7.egg/virtualenv.py", line 795, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/joshuabrownin...d/venv/bin/python2.7 - setuptools pip wheel failed with error code 1
STDERR:
# Command failed: python -m pythonforandroid.toolchain create --dist_name=easierGroceries --bootstrap=sdl2 --requirements=kivy,pint,hostpython2 --arch armeabi-v7a --copy-libs --local-recipes /Users/me/Personal/groecery/.buildozer/android/platform/python-for-android/recipes --color=always --storage-dir=/Users/me/Personal/grocery/.buildozer/android/platform/build
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
It seems like the error was caused by using a conda environment. When I used the default python installation (on my Mac OSX) the problem was resolved.

Can't create virtualenv with jython 2.7b2 as an interpreter

I want to execute some Java code from Python so I've decided to install standard python interpreter, jython and join them together using pyro4. Pyro4 requires python > 2.5 so I choose to use jython 2.7b. Here are steps I made to make this happen:
wget -i jython-installer-2.7-b2.jar http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7-b1/jython-installer-2.7-b2.jar
java -jar jython-installer-2.7-b2.jar
jython2.7b2/bin/virtualenv-2.7 oscar
And this is what I'm getting back:
Cannot find file /home/mnowotka/jython2.7b2/Include (bad symlink)
New jython executable in oscar/bin/jython
Installing setuptools.................
Complete output from command /home/mnowotka/oscar/bin/jython -c "#!python
\"\"\"Bootstra...sys.argv[1:])
" /home/mnowotka/jytho...ols-0.6c11-py2.7.egg:
Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
File "<string>", line 278, in <module>
File "<string>", line 210, in main
File "<string>", line 161, in download_setuptools
File "/home/mnowotka/jython2.7b2/Lib/socket.py", line 1651, in read
data = self._sock.recv(recv_size)
File "/home/mnowotka/jython2.7b2/Lib/httplib.py", line 567, in read
s = self.fp.read(amt)
File "/home/mnowotka/jython2.7b2/Lib/socket.py", line 1669, in read
data = self._sock.recv(recv_size)
File "/home/mnowotka/jython2.7b2/Lib/socket.py", line 174, in handle_exception
raise _map_exception(jlx)
socket.error: [Errno 32] Socket closed
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
File "jython2.7b2/bin/virtualenv-2.7", line 3, in <module>
virtualenv.main()
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 970, in main
create_environment(home_dir,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 1090, in create_environment
install_setuptools(py_executable, unzip=unzip_setuptools,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 610, in install_setuptools
_install_req(py_executable, unzip,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 579, in _install_req
call_subprocess(cmd, show_stdout=False,
File "/home/mnowotka/jython2.7b2/Lib/site-packages/virtualenv.py", line 1055, in call_subprocess
raise OSError(
OSError: Command /home/mnowotka/oscar/bin/jython -c "#!python
\"\"\"Bootstra...sys.argv[1:])
Does it mean that jython 2.7b2 is not quite ready yet or I'm doing something wrong?
Use this ez_setup.py to install setuptools:
added setuptools-egg and md5

Categories