Skip to content

Commit 01c3d79

Browse files
committed
fix(publish): use virtual env
1 parent c10995d commit 01c3d79

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

lib/prepare.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ async function installPackages(packages: string[], options?: Options) {
6060
}
6161

6262
async function createVenv(envDir: string, options?: Options): Promise<Options> {
63-
await spawn('python3', ['-m', 'venv', envDir], options);
6463
const envPath = path.resolve(envDir, 'bin');
64+
if (!fs.existsSync(envPath)) {
65+
await spawn('python3', ['-m', 'venv', envDir], options);
66+
}
6567
if (os.platform() == 'win32') {
6668
return {
6769
...options,

lib/publish.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Options, ResultPromise } from 'execa';
22
import type { Context } from './@types/semantic-release';
33
import { DefaultConfig } from './default-options';
4+
import { createVenv } from './prepare';
45
import { PluginConfig } from './types';
56
import { pipe, spawn } from './util.js';
67

@@ -47,8 +48,20 @@ function publishPackage(
4748

4849
async function publish(pluginConfig: PluginConfig, context: Context) {
4950
const { logger } = context;
50-
const { srcDir, distDir, pypiPublish, gpgSign, gpgIdentity, repoUrl } =
51-
new DefaultConfig(pluginConfig);
51+
const {
52+
srcDir,
53+
distDir,
54+
pypiPublish,
55+
gpgSign,
56+
gpgIdentity,
57+
repoUrl,
58+
envDir,
59+
} = new DefaultConfig(pluginConfig);
60+
61+
let options = pipe(context);
62+
if (envDir) {
63+
options = await createVenv(envDir, options);
64+
}
5265

5366
if (pypiPublish !== false) {
5467
logger.log(`Publishing package to ${repoUrl}`);
@@ -58,7 +71,7 @@ async function publish(pluginConfig: PluginConfig, context: Context) {
5871
process.env['PYPI_REPO_URL'] ?? repoUrl,
5972
gpgSign,
6073
gpgIdentity,
61-
pipe(context),
74+
options,
6275
);
6376
await result;
6477
} else {

0 commit comments

Comments
 (0)