python-packaging

How to list dependencies for a python library without installing?

試著忘記壹切 提交于 2019-12-04 08:59:58
问题 Is there a way to get a list of dependencies for a given python package without installing it first? I can currently get a list of requirements, but it requires installing the packages. For example, I can use pip to show basic requirements info, but it doesn't include version information: $ pip show pytest Name: pytest Version: 3.0.6 ... Requires: colorama, setuptools, py I've tried a library called pipdeptree that includes much better output on requirements, but it also requires installation

Is `setup.cfg` deprecated?

天大地大妈咪最大 提交于 2019-12-03 13:37:05
It's not completely clear to me, what is the status of setup.cfg . I am looking for solutions for my other question about PEP 508 environment markers, and I became totally confused. To me it seems that setup.cfg is an improvement over setup.py , because it's declarative, does not involve running arbitrary code to make package installable, makes it harder to distribute malicious Python packages, makes it easier to run Python package registries etc. So, here in setuptools docs it's mentioned that setuptools got support for setup.cfg in 30.3.0 (8 Dec 2016) version, which is quite recent. So, this

How do I use a relative path in a Python module when the CWD has changed?

你离开我真会死。 提交于 2019-12-03 05:38:33
问题 I have a Python module which uses some resources in a subdirectory of the module directory. After searching around on stack overflow and finding related answers, I managed to direct the module to the resources by using something like import os os.path.join(os.path.dirname(__file__), 'fonts/myfont.ttf') This works fine when I call the module from elsewhere, but it breaks when I call the module after changing the current working directory. The problem is that the contents of __file__ are a

How to find a class or function in a Python module?

断了今生、忘了曾经 提交于 2019-12-02 03:03:37
I'm trying to find the function or class definition of gen_dataset_ops in tensorflow, which has its sourcecode here . I find many places where it is imported like so: from tensorflow.python.ops import gen_dataset_ops But I can't find where it is defined, I'd expect to find something like: def gen_dataset_ops(...): #Do something clever return I don't quite understand the anatomy of python modules in general, so I'm probably missing some basics here,.. any hint is welcome! tensorflow.python.ops.gen_dataset_ops is generated code. (That's why they put gen in front of the name.) You can't find it

python installing package with submodules

一世执手 提交于 2019-12-01 08:37:41
I have a custom project package with structure like: package-dir/ mypackage/ __init__.py submodule1/ __init__.py testmodule.py main.py requirements.txt setup.py using cd package-dir followed by $pip install -e . or pip install . as suggested by python-packaging as long as I access the package from package-dir For example : $cd project-dir $pip install . at this point this works: $python -c 'import mypackage; import submodule1' but This does not work $ cd some-other-dir $ python -c 'import mypackage; import submodule1' Traceback (most recent call last): File "<stdin>", line 1, in <module>

How should I handle importing third-party libraries within my setup.py script?

痴心易碎 提交于 2019-12-01 04:51:47
I'm developing a Python application and in the process of branching off a release. I've got a PyPI server set up on a company server and I've copied a source distribution of my package onto it. I checked that the package was being hosted on the server and then tried installing it on my local development machine. I ended up with this output: $ pip3 install --trusted-host 172.16.1.92 -i http://172.16.1.92:5001/simple/ <my-package> Collecting <my-package> Downloading http://172.16.1.92:5001/packages/<my-package>-0.2.0.zip Complete output from command python setup.py egg_info: Traceback (most

python installing package with submodules

北战南征 提交于 2019-12-01 03:52:49
问题 I have a custom project package with structure like: package-dir/ mypackage/ __init__.py submodule1/ __init__.py testmodule.py main.py requirements.txt setup.py using cd package-dir followed by $pip install -e . or pip install . as suggested by python-packaging as long as I access the package from package-dir For example : $cd project-dir $pip install . at this point this works: $python -c 'import mypackage; import submodule1' but This does not work $ cd some-other-dir $ python -c 'import

How should I handle importing third-party libraries within my setup.py script?

☆樱花仙子☆ 提交于 2019-12-01 01:44:19
问题 I'm developing a Python application and in the process of branching off a release. I've got a PyPI server set up on a company server and I've copied a source distribution of my package onto it. I checked that the package was being hosted on the server and then tried installing it on my local development machine. I ended up with this output: $ pip3 install --trusted-host 172.16.1.92 -i http://172.16.1.92:5001/simple/ <my-package> Collecting <my-package> Downloading http://172.16.1.92:5001

Installing nltk data dependencies in setup.py script

荒凉一梦 提交于 2019-11-30 07:25:46
问题 I use NLTK with wordnet in my project. I did the installation manually on my PC, with pip: pip3 install nltk --user in a terminal, then nltk.download() in a python shell to download wordnet. I want to automatize these with a setup.py file, but I don't know a good way to install wordnet. For the moment, I have this piece of code after the call to setup ( "nltk" is in the install_requires list of the call to setup ): import sys if 'install' in sys.argv: import nltk nltk.download("wordnet") Is

Python setuptools/distutils custom build for the `extra` package with Makefile

丶灬走出姿态 提交于 2019-11-30 06:41:45
Preamble: Python setuptools are used for the package distribution. I have a Python package (let us call it my_package ), that has several extra_require packages to it. Everything works just find (installation and build of the package, as well as extras, if were requested), as all extra_require were python packages themselves and pip correctly resolved everything. A simple pip install my_package worked like a charm. Setup: Now, for one of the extras (let us call it extra1 ) I need to call a binary of a non-python library X . Module X itself (source code) was added to the my_package codebase and