Skip to content

Commit

Permalink
Fix dists linux (#737)
Browse files Browse the repository at this point in the history
* do not include .so in sdist

* set the tag

* Add link to imagemagick install info for other linux distros

* call get_abi_tag() from wheel._bdist_wheel

* wheel is no longer the canonical location for bdist_wheel for latest setuptools

* wheel formatting

---------

Co-authored-by: Adam Taranto <adam.p.taranto@gmail.com>
  • Loading branch information
tanghaibao and Adamtaranto authored Jan 5, 2025
1 parent b3438a1 commit 517f937
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ computation related to assembly, annotation, and comparative genomics.
| ------- | ---------------------------------------------------------------- |
| Authors | Haibao Tang ([tanghaibao](http://github.com/tanghaibao)) |
| | Vivek Krishnakumar ([vivekkrish](https://github.com/vivekkrish)) |
| | Adam Taranto ([Adamtaranto](https://github.com/Adamtaranto)) |
| | Xingtan Zhang ([tangerzhang](https://github.com/tangerzhang)) |
| | Won Cheol Yim ([wyim-pgl](https://github.com/wyim-pgl)) |
| Email | <tanghaibao@gmail.com> |
Expand Down Expand Up @@ -106,7 +107,7 @@ full-fledged applications.

JCVI requires Python3 between v3.8 and v3.12.

Some graphics modules require the [ImageMagick](https://imagemagick.org/index.php) library.
Some graphics modules require the [ImageMagick](https://imagemagick.org/index.php) library.

On MacOS this can be installed using Conda (see next section). If you are using a linux system (i.e. Ubuntu) you can install ImageMagick using apt-get:

Expand All @@ -115,8 +116,10 @@ sudo apt-get update
sudo apt-get install libmagickwand-dev
```

See the [Wand](https://docs.wand-py.org/en/0.2.4/guide/install.html) docs for instructions on installing ImageMagick on other systems.

A few modules may ask for locations of external programs,
if the executable cannot be found in your `PATH`.
if the executable cannot be found in your `PATH`.

The external programs that are often used are:

Expand All @@ -130,14 +133,13 @@ You can use the the YAML files in this repo to create an environment with basic

If you are new to Conda, we recommend the [Miniforge](https://conda-forge.org/download/) distribution.


```bash
conda env create -f environment.yml

conda activate jcvi
```

Note: If you are using a Mac with an ARM64 (Apple Silicon) processor, some dependencies are not currently available from Bioconda for this architecture.
Note: If you are using a Mac with an ARM64 (Apple Silicon) processor, some dependencies are not currently available from Bioconda for this architecture.

You can instead create a virtual OSX64 (intel) env like this:

Expand Down Expand Up @@ -180,7 +182,7 @@ If installed successfully, you can check the version with:
jcvi --version
```

## Usage
## Usage

Use `python -m` to call any of the modules installed with JCVI.

Expand Down
16 changes: 16 additions & 0 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import subprocess

from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from setuptools.command.bdist_wheel import get_abi_tag, get_platform, tags


class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
# Set the custom wheel tag
build_data["tag"] = self._get_wheel_tag()
print(f"Using custom wheel tag: {build_data['tag']}")
# Run setup.py build_ext before main build
subprocess.check_call(["python", "setup.py", "build_ext", "--inplace"])
return super().initialize(version, build_data)

def _get_wheel_tag(self):
# Without the tag, the wheel will be named jcvi-0.0.0-py3-none-any.whl
impl_name = tags.interpreter_name()
impl_ver = tags.interpreter_version()
abi_tag = get_abi_tag()
plat_tag = get_platform(None)
plat_tag = ( # macosx_11.0 => macosx_11_0
plat_tag.lower().replace("-", "_").replace(".", "_").replace(" ", "_")
)
return f"{impl_name}{impl_ver}-{abi_tag}-{plat_tag}"
47 changes: 19 additions & 28 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
requires = [
"hatchling", # Build backend
"hatch-vcs", # Version control system plugin for dynamic versioning
"setuptools", # Setuptools for compiling C extensions
"cython", # Cython for compiling C extensions
"setuptools", # Setuptools for compiling C extensions
"wheel", # Wheel for packaging
"cython", # Cython for compiling C extensions
"numpy", # NumPy for numerical operations and C extension includes
]
build-backend = "hatchling.build"
Expand All @@ -16,19 +17,19 @@ name = "jcvi"
description = "Python utility libraries on genome assembly, annotation and comparative genomics"
readme = "README.md"
requires-python = ">=3.8"
license = {text = "BSD"}
license = { text = "BSD" }
authors = [
{name = "Haibao Tang", email = "tanghaibao@gmail.com"},
{name = "Vivek Krishnakumar"},
{name = "Jingping Li"}
{ name = "Haibao Tang", email = "tanghaibao@gmail.com" },
{ name = "Vivek Krishnakumar" },
{ name = "Adam Taranto" },
]

classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Bio-Informatics"
"Topic :: Scientific/Engineering :: Bio-Informatics",
]

dependencies = [
Expand Down Expand Up @@ -60,19 +61,13 @@ dependencies = [
"scipy",
"seaborn",
"Wand",
"webcolors"
"webcolors",
]

dynamic = ["version"]

[project.optional-dependencies]
tests = [
"mock",
"pytest-benchmark",
"pytest-cov",
"pytest",
"PyYAML",
]
tests = ["mock", "pytest-benchmark", "pytest-cov", "pytest", "PyYAML"]

[project.urls]
homepage = "http://github.com/tanghaibao/jcvi"
Expand All @@ -86,11 +81,6 @@ allow-direct-references = true

[tool.hatch.build]
packages = ["src"]
artifacts = [
"src/jcvi/**/*.so", # Linux/Mac shared objects
"src/jcvi/**/*.pyd", # Windows shared objects
"src/jcvi/**/*.c" # Generated C files
]

[tool.hatch.build.hooks.custom]
path = "build.py"
Expand All @@ -106,13 +96,14 @@ tag-pattern = "v*"
fallback-version = "0.0.0"

[tool.hatch.build.targets.sdist]
include = [
"src/**/*.py",
"src/**/*.pyx",
"README.md",
]

force-include = { "build.py" = "build.py", "setup.py" = "setup.py"}
include = ["src/**/*.py", "src/**/*.pyx", "README.md"]
force-include = { "build.py" = "build.py", "setup.py" = "setup.py" }
exclude = ["src/jcvi/**/*.so", "src/jcvi/**/*.pyd", "src/jcvi/**/*.c"]

[tool.hatch.build.targets.wheel]
packages = ["src/jcvi"]
packages = ["src/jcvi"]
artifacts = [
"src/jcvi/**/*.so", # Linux/Mac shared objects
"src/jcvi/**/*.pyd", # Windows shared objects
"src/jcvi/**/*.c", # Generated C files
]
1 change: 1 addition & 0 deletions src/jcvi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
__author__ = (
"Haibao Tang",
"Vivek Krishnakumar",
"Adam Taranto",
"Xingtan Zhang",
"Won Cheol Yim",
)
Expand Down

0 comments on commit 517f937

Please sign in to comment.