I have a git project named mylibrary, with this structure :
mylibrary
├── conda-recipe
│ ├── LICENSE.md
│ └── recipe.yaml
├── setup.py
├── src
│ └── mylibrary
│ ├── common
│ │ ├── indicator.py
│ │ └── init.py
│ ├── core
│ │ ├── group.py
│ │ ├── exceptions.py
│ │ ├── frequency.py
│ │ ├── init.py
│ │ ├── units.py
│ │ └── utils.py
│ ├── pkg1
│ │ ├── abc.py
│ │ └── init.py
│ ├── pkg2
│ │ ├── dv1.py
│ │ ├── dv2.py
│ │ └── init.py
│ ├── pkg3
│ │ ├── enstl.py
│ │ ├── enst2.py
│ │ ├── enst3.py
│ │ └── init.py
│ ├── init.py
│ ├── pkg4
│ │ ├── init.py
│ │ ├── sp1.py
│ │ └── sp2.py
│ ├── pkg5
│ │ ├── init.py
│ │ ├── ta1.py
│ │ ├── ta2.py
│ │ ├── ta3.py
│ │ └── ta4.py
└── tests
├── init.py
├── test_one.py
├── test_two.py
├── test_three.py
├── test_four.py
I want to create a python package with “boa build” command. The packaging works with the setup.py file and the recipe.yaml file. But : I have a problem with src named package. FInally what I want is to do an “import mylibrary” in another conda environment. The conda install works, but not the import because packages are stored in a src directory
Here is my setup.py file :
from setuptools import setup, find_packages
setup(
name=“mylibrary”,
version=“1.0.0”,
packages=find_packages(“src”),
package_dir={“”: “src”}
Content of recipe.yaml file :
context:
name: ‘{{ environ[“CONDA_PACKAGE_NAME”] }}’
version: ‘{{ environ[“CONDA_PACKAGE_VERSION”] }}’
package:
name: ‘{{ name|lower }}’
version: ‘{{ version }}’
source:
path: …/
build:
script: ‘{{ PYTHON }} -m pip install --no-deps --no-build-isolation .’
script: ‘{{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation’
noarch: python
number: 0
requirements:
host:
- python >=3.12
- setuptools >=61
- setuptools-scm >=6.2.3
- pip
run:
- python >=3.12
- bottleneck 1.3.8
- dask 2024.4.1
- flox 0.9.6
- h5netcdf 1.3.0
- netcdf4 1.6.5
- xarray 2024.3.0
Content of conda package :
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/direct_url.json
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/INSTALLER
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/METADATA
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/RECORD
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/REQUESTED
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/top_level.txt
lib/python3.12/site-packages/mylibrary-1.0.0.dist-info/WHEEL
lib/python3.12/site-packages/common/idic.py
lib/python3.12/site-packages/common/init.py
lib/python3.12/site-packages/common/pycache/idic.cpython-312.pyc
lib/python3.12/site-packages/common/pycache/init.cpython-312.pyc
lib/python3.12/site-packages/conf/init.py
lib/python3.12/site-packages/conf/pycache/init.cpython-312.pyc
lib/python3.12/site-packages/core/group.py
lib/python3.12/site-packages/core/exceptions.py
lib/python3.12/site-packages/core/frequency.py
lib/python3.12/site-packages/core/init.py
lib/python3.12/site-packages/core/pycache/attributes_group.cpython-312.pyc
lib/python3.12/site-packages/core/pycache/exceptions.cpython-312.pyc
lib/python3.12/site-packages/core/pycache/frequency.cpython-312.pyc
lib/python3.12/site-packages/core/pycache/init.cpython-312.pyc
lib/python3.12/site-packages/core/pycache/units.cpython-312.pyc
lib/python3.12/site-packages/core/pycache/utils.cpython-312.pyc
lib/python3.12/site-packages/core/units.py
lib/python3.12/site-packages/core/utils.py
lib/python3.12/site-packages/pkg1/abc.py
lib/python3.12/site-packages/pkg1/init.py
lib/python3.12/site-packages/pkg1/pycache/abc.cpython-312.pyc
lib/python3.12/site-packages/pkg1/pycache/init.cpython-312.pyc
lib/python3.12/site-packages/pkg2/dv1.py
lib/python3.12/site-packages/pkg2/dv2.py
…
I’d like to have all packages in src directory. And then I’d like to rename src to mylibrary, but it doesn’t work.
I’m not sure to understand really well the usage of packages and package_dir in setup() function.
Can you help me for that?
Thanks