python-packaging

Python packaging: Boost library as dependency

孤者浪人 提交于 2021-02-20 19:12:53
问题 Assume that someone wants to package a Python (Cython) library that depends on the C++ boost library. What is the best way to configure the setup.py so that the user is properly informed that it is required to install the boost library (i.e., apt-get install libboost-dev in Ubuntu, etc in other OSes)? Or is it a better practice to include the boost library in the python package distribution? 回答1: The question is better asked as What is the best way to distribute a Python extension including

relative position and content of namespace packages in Python >= 3.3

拜拜、爱过 提交于 2021-02-19 03:48:45
问题 I read the docs and quite some stackoverflow posts, but did not find an explicit answer to my doubts. I think I understand what namespace packages are for. I am only interested in Python>=3.3 and the implicit namespace packages - folders without the __init__.py . Questions Are namespace packages supposed to contain only other packages, or modules (i.e. .py files) are also "allowed"? Are namespace packages supposed to be used only as "container" packages, or can they also be contained in

Check whether a python package has been installed in 'editable' (egg-link) mode or not?

江枫思渺然 提交于 2021-02-19 02:15:38
问题 Is there any way to check whether a Python package has been installed normally ( pip install / setup.py install ) or in editable/egg-link mode ( pip install -e / setup.py develop )? I know I could check whether the path to the package contains site-packages which would most likely mean it's a "non-editable" install, but this feels extremely dirty and I would rather avoid this. The reason I'm trying to check this is that my application is checking for config files in various places, such as

How to edit a wheel package (.whl)?

孤街醉人 提交于 2021-02-19 01:34:27
问题 I have a python wheel package, when extracted I find some python code, I'd like to edit this code and re-generate the same .whl package again and test it to see the edits .. How do I do that? 回答1: You usually don't. Normally you get the source package instead of the wheel (or use development mode to install the package in editable form) and rebuild the wheel from that, e.g. by running python setup.py bdist_wheel . Have a look at https://packaging.python.org/distributing/ for a lot of

How to prevent *.exe from installing into all my pyvenv3.5 venv (and what describes their purpose)?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-10 19:51:33
问题 An initial pyvenv3.5 venv at create time is about 9.5MB on disk, before adding any custom content. Over 9% (!) of the venv disk-overhead are *.exe files, but all lack execute permission mode. One example: lib/python3.5/site-packages/setuptools/gui-32.exe . The linux file command says they are: executable for MS Windows . It looks like an obscure OS I'm certain my many pyvenv will never run on, and on which I'm unable to test. What are the repercussions if I just delete them? In initial tests

Add custom action to setup.py

狂风中的少年 提交于 2021-02-10 15:52:41
问题 I have the project with such structure: Project/ Project/ __init__.py config.py setup.py .gitignore config.py contains two variables ( LOGIN , PASS ) and is added to .gitignore . I would like to add custom action to setup.py then run python setup.py install than triggered creating config.py with some inputs("Please write your login/pass") prior to installation of package. How to do it right? 回答1: It is not a good idea to do any customization at install time . It is good practice to do

Add custom action to setup.py

為{幸葍}努か 提交于 2021-02-10 15:48:38
问题 I have the project with such structure: Project/ Project/ __init__.py config.py setup.py .gitignore config.py contains two variables ( LOGIN , PASS ) and is added to .gitignore . I would like to add custom action to setup.py then run python setup.py install than triggered creating config.py with some inputs("Please write your login/pass") prior to installation of package. How to do it right? 回答1: It is not a good idea to do any customization at install time . It is good practice to do

Add custom action to setup.py

南楼画角 提交于 2021-02-10 15:44:43
问题 I have the project with such structure: Project/ Project/ __init__.py config.py setup.py .gitignore config.py contains two variables ( LOGIN , PASS ) and is added to .gitignore . I would like to add custom action to setup.py then run python setup.py install than triggered creating config.py with some inputs("Please write your login/pass") prior to installation of package. How to do it right? 回答1: It is not a good idea to do any customization at install time . It is good practice to do

How to import a module but ignoring the package's __init__.py?

时间秒杀一切 提交于 2021-02-07 14:18:57
问题 I'm trying to import a function which is in a module inside a package in Python, but when I try: from package.module import some_function Python executes the package's _ init _.py but it can't happen. Is there a way to import the function telling Python to ignore the package's _ init _.py? 回答1: The answer is No, you can't import a python package without the __init__.py being executed. By definition, to make a package, you must put in that directory a __init__.py. But, you can make an empty _

Wheel Incompatibility between Python Minor Versions

自作多情 提交于 2021-02-05 11:14:19
问题 I'm releasing a package on PyPi which will support Python 3.6+, and would like to build as few wheels as possible. I've read up on Python's packaging system for wheels and looked at the NumPy project for an example. Reading PEP 513 and PEP 571 was also insightful. Here's the question: why are wheels forwards-incompatible with Python minor version changes? Upgrading from 3.5 to 3.6, for example, brings f-strings. But it seems like a wheel built with Python 3.5 (not using f-strings) should be