python-packaging

How do you compile a C library with multiple dependencies into a Python package? Cmake?

眉间皱痕 提交于 2020-01-12 08:12:07
问题 I have a Python package in python3.x I've been writing up which interacts with two C functions in a C library. At the moment, I've been using ctypes whereby I link directly to the shared library *.so , and then use the python script to interact with this. https://docs.python.org/3/library/ctypes.html#module-ctypes I'm now confused how to distribute this python package whereby users would install the python package on github or via pip. Somehow, upon installation, the C library would need to

How do you compile a C library with multiple dependencies into a Python package? Cmake?

我怕爱的太早我们不能终老 提交于 2020-01-12 08:10:07
问题 I have a Python package in python3.x I've been writing up which interacts with two C functions in a C library. At the moment, I've been using ctypes whereby I link directly to the shared library *.so , and then use the python script to interact with this. https://docs.python.org/3/library/ctypes.html#module-ctypes I'm now confused how to distribute this python package whereby users would install the python package on github or via pip. Somehow, upon installation, the C library would need to

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

徘徊边缘 提交于 2019-12-31 03:53:09
问题 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! 回答1: tensorflow.python

How to resolve “ValueError: attempted relative import beyond top-level package”

为君一笑 提交于 2019-12-29 08:20:33
问题 I have the following problem with my project, help me please! Here is the structure of my package: /pkg /pkg/__init__.py /pkg/sub1/__init__.py /pkg/sub2/__init__.py /pkg/sub1/foo1.py /pkg/sub2/foo2.py Here is implementation of foo1.py: from ..sub2 import foo2 def f(): print("Hello!") When I run foo1 I get error: ValueError: attempted relative import beyond top-level package . I can solve it doing the following adjustment: import sys import os sys.path.append(os.path.abspath(os.path.pardir))

How to build and distribute a Python/Cython package that depends on third party libFoo.so

守給你的承諾、 提交于 2019-12-29 05:18:28
问题 I've written a Python module that depends on some C extensions. Those C extensions depend in turn on several compiled C libraries. I'd like to be able to distribute this module bundled with all the dependencies. I've put together a minimal example (it can be found on GitHub in its entirety). The directory structure is: $ tree . . ├── README.md ├── poc │ ├── __init__.py │ ├── cython_extensions │ │ ├── __init__.py │ │ ├── cvRoberts_dns.c │ │ ├── cvRoberts_dns.h │ │ ├── helloworld.c │ │ ├──

Python Module Not Found Issues after moving directory

岁酱吖の 提交于 2019-12-25 09:25:53
问题 I am working on some repacking of a project that has a variety of different technologies involved. I am trying to move a python module into the project structure for storage in git and have all project files located together. The python code works in its on folder. I have empty __init__ in each folder and there are no problems with from Documents import * When I move the folder into my larger project, all of these imports fall apart. Can anyone please help me to understand what is different?

Python: weird import behaviour

余生颓废 提交于 2019-12-24 09:19:05
问题 I have a package with the following structure projectX ├── data ├── results └── projectX ├── stats │ ├── __init__.py │ ├── stats_worker.py │ └── stats_wroker2.py ├── __init__.py ├── main_worker.py └── interface.py Notice that the project folder and the source folder share the same name (projectX). The problem is a bit complex and needs some premises to be done Premises: I always launch the interface and always have launched the interface. No other script is called My problem first arose when

Is `setup.cfg` deprecated?

别说谁变了你拦得住时间么 提交于 2019-12-21 04:04:48
问题 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

What is 'extra' in pypi dependency?

大憨熊 提交于 2019-12-19 21:41:28
问题 In requires_dist section of a package's json response from pypi, it is given: requires_dist : [ "bcrypt; extra == 'bcrypt'", "argon2-cffi (>=16.1.0); extra == 'argon2'" ] can anyone make it clear the second statement of each dependency, extra == 'bcrypt' and extra == 'argon2' ? 回答1: Extras are dependencies you can install in addition to the regular dependencies, if you ask for them explicitly. See them as optional features. You can install these with the name after the == , with the name of

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

放肆的年华 提交于 2019-12-18 11:45:34
问题 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